Spaces:
Sleeping
Sleeping
chips
commited on
Commit
·
7fc69e4
1
Parent(s):
c77be6c
troubleshooting
Browse files- app.py +24 -15
- base_generator.py +1 -1
app.py
CHANGED
@@ -95,34 +95,43 @@ async def run_virtual_tryon_pipeline(
|
|
95 |
r.set(request_id, "checking incoming data...")
|
96 |
front_type = ""
|
97 |
back_type = ""
|
98 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
99 |
return {"error": "Missing garment images"}
|
100 |
-
|
101 |
-
|
|
|
|
|
102 |
front_type = "single"
|
103 |
else:
|
104 |
-
front_type = "
|
105 |
-
|
106 |
-
|
|
|
|
|
|
|
107 |
else:
|
108 |
-
|
109 |
-
|
110 |
-
back_type = "single"
|
111 |
-
else:
|
112 |
-
back_type = "double"
|
113 |
print(f"front_type: {front_type}")
|
114 |
print(f"back_type: {back_type}")
|
115 |
front_final_image = ""
|
116 |
back_final_image = ""
|
117 |
|
118 |
if front_type == "double":
|
119 |
-
front_final_image = await combine_images_side_by_side(
|
120 |
if back_type == "double":
|
121 |
-
back_final_image = await combine_images_side_by_side(
|
122 |
if front_type == "single":
|
123 |
-
front_final_image =
|
124 |
if back_type == "single":
|
125 |
-
back_final_image =
|
126 |
r.set(request_id, "Garment images combined")
|
127 |
#Check incoming data. do we have the required data. Are the images what we expect? (ie flatlay image file etc.)
|
128 |
#lets use openai for this. Also, return errors where needed
|
|
|
95 |
r.set(request_id, "checking incoming data...")
|
96 |
front_type = ""
|
97 |
back_type = ""
|
98 |
+
|
99 |
+
# Read all files once at the start
|
100 |
+
top_garment_data = await top_garment_image.read() if top_garment_image else None
|
101 |
+
bottom_garment_data = await bottom_garment_image.read() if bottom_garment_image else None
|
102 |
+
top_back_garment_data = await top_back_garment_image.read() if top_back_garment_image else None
|
103 |
+
bottom_back_garment_data = await bottom_back_garment_image.read() if bottom_back_garment_image else None
|
104 |
+
|
105 |
+
if top_garment_data is None and bottom_garment_data is None:
|
106 |
return {"error": "Missing garment images"}
|
107 |
+
|
108 |
+
if top_garment_data and bottom_garment_data:
|
109 |
+
front_type = "double"
|
110 |
+
elif top_garment_data or bottom_garment_data:
|
111 |
front_type = "single"
|
112 |
else:
|
113 |
+
front_type = "none"
|
114 |
+
|
115 |
+
if top_back_garment_data and bottom_back_garment_data:
|
116 |
+
back_type = "double"
|
117 |
+
elif top_back_garment_data or bottom_back_garment_data:
|
118 |
+
back_type = "single"
|
119 |
else:
|
120 |
+
back_type = "none"
|
121 |
+
|
|
|
|
|
|
|
122 |
print(f"front_type: {front_type}")
|
123 |
print(f"back_type: {back_type}")
|
124 |
front_final_image = ""
|
125 |
back_final_image = ""
|
126 |
|
127 |
if front_type == "double":
|
128 |
+
front_final_image = await combine_images_side_by_side(top_garment_data, bottom_garment_data)
|
129 |
if back_type == "double":
|
130 |
+
back_final_image = await combine_images_side_by_side(top_back_garment_data, bottom_back_garment_data)
|
131 |
if front_type == "single":
|
132 |
+
front_final_image = top_garment_data or bottom_garment_data
|
133 |
if back_type == "single":
|
134 |
+
back_final_image = top_back_garment_data or bottom_back_garment_data
|
135 |
r.set(request_id, "Garment images combined")
|
136 |
#Check incoming data. do we have the required data. Are the images what we expect? (ie flatlay image file etc.)
|
137 |
#lets use openai for this. Also, return errors where needed
|
base_generator.py
CHANGED
@@ -52,7 +52,7 @@ def on_queue_update(update):
|
|
52 |
def create_image(character_lora, character_keyword, outfit_desc, pose_id, num_outputs):
|
53 |
seed = random.randint(0, 1000000)
|
54 |
print(f"seed: {seed}")
|
55 |
-
prompt = "Fashion model {character_keyword} wearing {outfit_desc}. posing in front of white background"
|
56 |
|
57 |
result = fal_client.subscribe(
|
58 |
"fal-ai/flux-general",
|
|
|
52 |
def create_image(character_lora, character_keyword, outfit_desc, pose_id, num_outputs):
|
53 |
seed = random.randint(0, 1000000)
|
54 |
print(f"seed: {seed}")
|
55 |
+
prompt = f"Fashion model {character_keyword} wearing {outfit_desc}. posing in front of white background"
|
56 |
|
57 |
result = fal_client.subscribe(
|
58 |
"fal-ai/flux-general",
|