AlGe commited on
Commit
2eaf831
·
verified ·
1 Parent(s): 927b18e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +35 -3
app.py CHANGED
@@ -1,4 +1,36 @@
1
-
2
- from gradio_client import Client
3
  import gradio as gr
4
- iface = gr.Interface.load("spaces/radames/Enhance-This-HiDiffusion-SDXL")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
+ import requests
3
+ from PIL import Image
4
+ from io import BytesIO
5
+
6
+ # Define the function to call the existing Gradio space API
7
+ def enhance_image(input_image):
8
+ # Convert the image to bytes
9
+ img_byte_arr = BytesIO()
10
+ input_image.save(img_byte_arr, format='PNG')
11
+ img_bytes = img_byte_arr.getvalue()
12
+
13
+ # Prepare the payload
14
+ payload = {'data': [img_bytes]}
15
+
16
+ # Call the existing Gradio space API
17
+ api_url = "https://radames/Enhance-This-HiDiffusion-SDXL/api/predict"
18
+ response = requests.post(api_url, files={'file': img_bytes})
19
+
20
+ if response.status_code == 200:
21
+ output_image = Image.open(BytesIO(response.content))
22
+ return output_image
23
+ else:
24
+ return None
25
+
26
+ # Create the Gradio interface
27
+ interface = gr.Interface(
28
+ fn=enhance_image,
29
+ inputs=gr.inputs.Image(type="pil", label="Input Image"),
30
+ outputs=gr.outputs.Image(type="pil", label="Enhanced Image"),
31
+ title="Enhance This HiDiffusion SDXL",
32
+ description="Upload an image to enhance it using HiDiffusion SDXL."
33
+ )
34
+
35
+ # Launch the app
36
+ interface.launch()