Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -6,7 +6,18 @@ import os
|
|
| 6 |
# Initialize the client
|
| 7 |
client = Client("radames/Enhance-This-HiDiffusion-SDXL")
|
| 8 |
|
| 9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
# Use the client to predict the result
|
| 11 |
result = client.predict(image_path, prompt, api_name="/predict")
|
| 12 |
return result
|
|
@@ -15,7 +26,7 @@ def enhance_image(image_path, prompt):
|
|
| 15 |
iface = gr.Interface(
|
| 16 |
fn=enhance_image,
|
| 17 |
inputs=[
|
| 18 |
-
gr.Image(type="pil", label="Input Image"
|
| 19 |
gr.Textbox(lines=2, placeholder="Enter prompt here", label="Prompt")
|
| 20 |
],
|
| 21 |
outputs=gr.Image(type="pil", label="Enhanced Image"),
|
|
|
|
| 6 |
# Initialize the client
|
| 7 |
client = Client("radames/Enhance-This-HiDiffusion-SDXL")
|
| 8 |
|
| 9 |
+
# Custom preprocessing function to save uploaded image to a temporary file
|
| 10 |
+
def preprocess_image(image):
|
| 11 |
+
# Create a temporary directory
|
| 12 |
+
temp_dir = tempfile.mkdtemp()
|
| 13 |
+
# Save the image to a temporary file
|
| 14 |
+
image_path = os.path.join(temp_dir, "input_image.jpg")
|
| 15 |
+
image.save(image_path)
|
| 16 |
+
return image_path
|
| 17 |
+
|
| 18 |
+
def enhance_image(image, prompt):
|
| 19 |
+
# Preprocess the image
|
| 20 |
+
image_path = preprocess_image(image)
|
| 21 |
# Use the client to predict the result
|
| 22 |
result = client.predict(image_path, prompt, api_name="/predict")
|
| 23 |
return result
|
|
|
|
| 26 |
iface = gr.Interface(
|
| 27 |
fn=enhance_image,
|
| 28 |
inputs=[
|
| 29 |
+
gr.Image(type="pil", label="Input Image"),
|
| 30 |
gr.Textbox(lines=2, placeholder="Enter prompt here", label="Prompt")
|
| 31 |
],
|
| 32 |
outputs=gr.Image(type="pil", label="Enhanced Image"),
|