noumanjavaid commited on
Commit
d1b69a7
·
verified ·
1 Parent(s): 9b51272

Update vton.py

Browse files
Files changed (1) hide show
  1. vton.py +8 -0
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"