Spaces:
Sleeping
Sleeping
Add parameter validation logic in /vton/
Browse files
app.py
CHANGED
|
@@ -307,8 +307,27 @@ async def vton_run(
|
|
| 307 |
denoise_steps: int = 30,
|
| 308 |
seed: int = 42
|
| 309 |
):
|
| 310 |
-
|
| 311 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 312 |
|
| 313 |
results = quick_tryon(target_human, target_cloth, input_prompt)
|
| 314 |
|
|
|
|
| 307 |
denoise_steps: int = 30,
|
| 308 |
seed: int = 42
|
| 309 |
):
|
| 310 |
+
# Validate file parameters
|
| 311 |
+
if not upload_human or not upload_human.filename:
|
| 312 |
+
return {"error": "Human image file is required"}
|
| 313 |
+
if not upload_cloth or not upload_cloth.filename:
|
| 314 |
+
return {"error": "Cloth image file is required"}
|
| 315 |
+
|
| 316 |
+
# Validate file contents
|
| 317 |
+
human_content = await upload_human.read()
|
| 318 |
+
cloth_content = await upload_cloth.read()
|
| 319 |
+
|
| 320 |
+
if not human_content:
|
| 321 |
+
return {"error": "Human image file is empty"}
|
| 322 |
+
if not cloth_content:
|
| 323 |
+
return {"error": "Cloth image file is empty"}
|
| 324 |
+
|
| 325 |
+
# Reset file pointers for reading
|
| 326 |
+
await upload_human.seek(0)
|
| 327 |
+
await upload_cloth.seek(0)
|
| 328 |
+
|
| 329 |
+
target_human = Image.open(io.BytesIO(human_content))
|
| 330 |
+
target_cloth = Image.open(io.BytesIO(cloth_content))
|
| 331 |
|
| 332 |
results = quick_tryon(target_human, target_cloth, input_prompt)
|
| 333 |
|