Spaces:
Paused
Paused
Ali Mohsin
commited on
Commit
Β·
dbb02ac
1
Parent(s):
d9371aa
fixes
Browse files
app.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
| 1 |
import os
|
| 2 |
import base64
|
| 3 |
import io
|
|
|
|
| 4 |
from typing import List, Optional, Any, Dict
|
| 5 |
|
| 6 |
import gradio as gr
|
|
@@ -952,8 +953,8 @@ def gradio_recommend(
|
|
| 952 |
print(f"π DEBUG: Error in compose_outfits result: {res[0]}")
|
| 953 |
return [], res[0]
|
| 954 |
|
| 955 |
-
# Prepare stitched previews
|
| 956 |
-
strips: List[
|
| 957 |
print(f"π DEBUG: Preparing stitched previews for {len(res)} outfits...")
|
| 958 |
for i, r in enumerate(res):
|
| 959 |
idxs = []
|
|
@@ -971,12 +972,19 @@ def gradio_recommend(
|
|
| 971 |
print(f"π DEBUG: Extracted {len(imgs)} images from indices {idxs}")
|
| 972 |
if imgs:
|
| 973 |
strip = _stitch_strip(imgs)
|
| 974 |
-
strips.append(strip)
|
| 975 |
print(f"π DEBUG: Created stitched image: {strip.size}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 976 |
else:
|
| 977 |
print(f"β οΈ DEBUG: No images extracted for outfit {i+1}")
|
| 978 |
|
| 979 |
-
print(f"π DEBUG: Returning {len(strips)} stitched
|
| 980 |
return strips, {"outfits": res}
|
| 981 |
|
| 982 |
|
|
|
|
| 1 |
import os
|
| 2 |
import base64
|
| 3 |
import io
|
| 4 |
+
import tempfile
|
| 5 |
from typing import List, Optional, Any, Dict
|
| 6 |
|
| 7 |
import gradio as gr
|
|
|
|
| 953 |
print(f"π DEBUG: Error in compose_outfits result: {res[0]}")
|
| 954 |
return [], res[0]
|
| 955 |
|
| 956 |
+
# Prepare stitched previews - save to temp files for Gradio API compatibility
|
| 957 |
+
strips: List[str] = [] # Changed to List[str] for file paths
|
| 958 |
print(f"π DEBUG: Preparing stitched previews for {len(res)} outfits...")
|
| 959 |
for i, r in enumerate(res):
|
| 960 |
idxs = []
|
|
|
|
| 972 |
print(f"π DEBUG: Extracted {len(imgs)} images from indices {idxs}")
|
| 973 |
if imgs:
|
| 974 |
strip = _stitch_strip(imgs)
|
|
|
|
| 975 |
print(f"π DEBUG: Created stitched image: {strip.size}")
|
| 976 |
+
|
| 977 |
+
# Save to temporary file (Gradio will convert to URL)
|
| 978 |
+
temp_file = tempfile.NamedTemporaryFile(delete=False, suffix='.png', dir='/tmp')
|
| 979 |
+
strip.save(temp_file.name, 'PNG')
|
| 980 |
+
temp_file.close()
|
| 981 |
+
|
| 982 |
+
strips.append(temp_file.name) # Return file path instead of PIL Image
|
| 983 |
+
print(f"π DEBUG: Saved to temp file: {temp_file.name}")
|
| 984 |
else:
|
| 985 |
print(f"β οΈ DEBUG: No images extracted for outfit {i+1}")
|
| 986 |
|
| 987 |
+
print(f"π DEBUG: Returning {len(strips)} stitched image file paths and {len(res)} outfit results")
|
| 988 |
return strips, {"outfits": res}
|
| 989 |
|
| 990 |
|