Spaces:
Running
Running
Update vton.py
Browse files
vton.py
CHANGED
@@ -35,10 +35,18 @@ def virtual_try_on(garm_img_data, human_img_data, garment_des):
|
|
35 |
)
|
36 |
|
37 |
# The model returns a list of URLs, get the first one
|
|
|
|
|
|
|
38 |
output_url = output[0]
|
39 |
|
|
|
|
|
|
|
|
|
40 |
# Download the image from the URL
|
41 |
response = requests.get(output_url)
|
|
|
42 |
|
43 |
# Save the output image
|
44 |
output_path = "output.jpg"
|
|
|
35 |
)
|
36 |
|
37 |
# The model returns a list of URLs, get the first one
|
38 |
+
if not output or not isinstance(output, list):
|
39 |
+
raise ValueError("Invalid response from the model")
|
40 |
+
|
41 |
output_url = output[0]
|
42 |
|
43 |
+
# Validate URL scheme
|
44 |
+
if not output_url.startswith(('http://', 'https://')):
|
45 |
+
output_url = 'https://' + output_url
|
46 |
+
|
47 |
# Download the image from the URL
|
48 |
response = requests.get(output_url)
|
49 |
+
response.raise_for_status() # Raise an exception for bad status codes
|
50 |
|
51 |
# Save the output image
|
52 |
output_path = "output.jpg"
|