Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,36 +1,21 @@
|
|
|
|
1 |
import gradio as gr
|
2 |
-
import
|
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 |
-
|
9 |
-
|
10 |
-
|
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.Image(type="pil", label="Input Image"),
|
30 |
-
outputs=gr.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()
|
|
|
1 |
+
# Let's re-evaluate the implementation using the guide for making predictions with the Gradio client
|
2 |
import gradio as gr
|
3 |
+
from gradio.client import Client
|
|
|
|
|
4 |
|
5 |
+
# Define the function to call the existing Gradio space API using the Gradio client
|
6 |
def enhance_image(input_image):
|
7 |
+
client = Client("radames/Enhance-This-HiDiffusion-SDXL")
|
8 |
+
result = client.predict(input_image, api_name="/predict")
|
9 |
+
return result
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
|
11 |
# Create the Gradio interface
|
12 |
interface = gr.Interface(
|
13 |
fn=enhance_image,
|
14 |
+
inputs=gr.inputs.Image(type="pil", label="Input Image"),
|
15 |
+
outputs=gr.outputs.Image(type="pil", label="Enhanced Image"),
|
16 |
title="Enhance This HiDiffusion SDXL",
|
17 |
description="Upload an image to enhance it using HiDiffusion SDXL."
|
18 |
)
|
19 |
|
20 |
# Launch the app
|
21 |
+
interface.launch()
|