Spaces:
Running
Running
Upload server.py
Browse files
server.py
CHANGED
|
@@ -185,16 +185,30 @@ async def edit_image(
|
|
| 185 |
fn_index=2
|
| 186 |
)
|
| 187 |
|
|
|
|
| 188 |
output_image_data = result[0]
|
| 189 |
|
| 190 |
# Some models return a list of images as the first element
|
| 191 |
if isinstance(output_image_data, list) and len(output_image_data) > 0:
|
| 192 |
output_image_data = output_image_data[0]
|
| 193 |
|
|
|
|
| 194 |
if isinstance(output_image_data, dict):
|
| 195 |
-
|
| 196 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 197 |
gradio_temp_path = output_image_data
|
|
|
|
|
|
|
|
|
|
| 198 |
|
| 199 |
output_filename = f"{model}_edited_{uuid.uuid4()}.webp"
|
| 200 |
final_output_path = os.path.join(OUTPUT_DIR, output_filename)
|
|
|
|
| 185 |
fn_index=2
|
| 186 |
)
|
| 187 |
|
| 188 |
+
print(f"DEBUG: Result from {model}: {result}")
|
| 189 |
output_image_data = result[0]
|
| 190 |
|
| 191 |
# Some models return a list of images as the first element
|
| 192 |
if isinstance(output_image_data, list) and len(output_image_data) > 0:
|
| 193 |
output_image_data = output_image_data[0]
|
| 194 |
|
| 195 |
+
gradio_temp_path = None
|
| 196 |
if isinstance(output_image_data, dict):
|
| 197 |
+
# Try common Gradio keys for image paths
|
| 198 |
+
gradio_temp_path = output_image_data.get('path') or output_image_data.get('name') or output_image_data.get('url')
|
| 199 |
+
|
| 200 |
+
# Special case: nested 'image' key (found in some models)
|
| 201 |
+
if not gradio_temp_path and 'image' in output_image_data:
|
| 202 |
+
img_val = output_image_data['image']
|
| 203 |
+
if isinstance(img_val, str):
|
| 204 |
+
gradio_temp_path = img_val
|
| 205 |
+
elif isinstance(img_val, dict):
|
| 206 |
+
gradio_temp_path = img_val.get('path') or img_val.get('name')
|
| 207 |
+
elif isinstance(output_image_data, str):
|
| 208 |
gradio_temp_path = output_image_data
|
| 209 |
+
|
| 210 |
+
if not gradio_temp_path:
|
| 211 |
+
raise Exception(f"Could not extract image path from result: {output_image_data}")
|
| 212 |
|
| 213 |
output_filename = f"{model}_edited_{uuid.uuid4()}.webp"
|
| 214 |
final_output_path = os.path.join(OUTPUT_DIR, output_filename)
|