Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -35,14 +35,14 @@ def process_image(prompt, image, style, upscale_factor, inpaint):
|
|
| 35 |
|
| 36 |
# Check if the result is valid
|
| 37 |
if result and hasattr(result, 'images') and len(result.images) > 0:
|
| 38 |
-
return result.images[0]
|
| 39 |
else:
|
| 40 |
-
return "Error: No image returned from model."
|
| 41 |
|
| 42 |
except Exception as e:
|
| 43 |
error_message = f"Error in process_image function: {e}"
|
| 44 |
print(error_message)
|
| 45 |
-
return error_message
|
| 46 |
|
| 47 |
# Define the Gradio interface
|
| 48 |
with gr.Blocks() as demo:
|
|
@@ -54,13 +54,14 @@ with gr.Blocks() as demo:
|
|
| 54 |
upscale_input = gr.Slider(minimum=1, maximum=4, step=1, label="Upscale Factor")
|
| 55 |
inpaint_input = gr.Checkbox(label="Enable Inpainting")
|
| 56 |
|
| 57 |
-
|
|
|
|
| 58 |
|
| 59 |
generate_button = gr.Button("Generate Image")
|
| 60 |
generate_button.click(
|
| 61 |
process_image,
|
| 62 |
inputs=[prompt_input, image_input, style_input, upscale_input, inpaint_input],
|
| 63 |
-
outputs=output
|
| 64 |
)
|
| 65 |
|
| 66 |
# Launch the interface
|
|
|
|
| 35 |
|
| 36 |
# Check if the result is valid
|
| 37 |
if result and hasattr(result, 'images') and len(result.images) > 0:
|
| 38 |
+
return result.images[0], None # Return image and no error
|
| 39 |
else:
|
| 40 |
+
return None, "Error: No image returned from model." # Return no image and an error message
|
| 41 |
|
| 42 |
except Exception as e:
|
| 43 |
error_message = f"Error in process_image function: {e}"
|
| 44 |
print(error_message)
|
| 45 |
+
return None, error_message # Return no image and the error message
|
| 46 |
|
| 47 |
# Define the Gradio interface
|
| 48 |
with gr.Blocks() as demo:
|
|
|
|
| 54 |
upscale_input = gr.Slider(minimum=1, maximum=4, step=1, label="Upscale Factor")
|
| 55 |
inpaint_input = gr.Checkbox(label="Enable Inpainting")
|
| 56 |
|
| 57 |
+
output_image = gr.Image(label="Generated Image", type="pil")
|
| 58 |
+
error_output = gr.Textbox(label="Error Details", lines=4, placeholder="Error details will appear here")
|
| 59 |
|
| 60 |
generate_button = gr.Button("Generate Image")
|
| 61 |
generate_button.click(
|
| 62 |
process_image,
|
| 63 |
inputs=[prompt_input, image_input, style_input, upscale_input, inpaint_input],
|
| 64 |
+
outputs=[output_image, error_output] # Handle both image and error output
|
| 65 |
)
|
| 66 |
|
| 67 |
# Launch the interface
|