Extract base image filepath from URL if path field is missing
Browse files
app.py
CHANGED
|
@@ -162,6 +162,10 @@ def edit_image(image_input: dict | str, prompt: str) -> dict | None:
|
|
| 162 |
# Extract file path from Gradio image dictionary or string
|
| 163 |
if isinstance(image_input, dict):
|
| 164 |
image_path = image_input.get("path")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 165 |
else:
|
| 166 |
image_path = image_input
|
| 167 |
|
|
|
|
| 162 |
# Extract file path from Gradio image dictionary or string
|
| 163 |
if isinstance(image_input, dict):
|
| 164 |
image_path = image_input.get("path")
|
| 165 |
+
if not image_path:
|
| 166 |
+
url = image_input.get("url")
|
| 167 |
+
if url and "/gradio_api/file=" in url:
|
| 168 |
+
image_path = url.split("/gradio_api/file=")[-1]
|
| 169 |
else:
|
| 170 |
image_path = image_input
|
| 171 |
|