DMMP commited on
Commit
df48a43
·
verified ·
1 Parent(s): 2c57ebf

minor change in download images

Browse files

used iterator to signal which url failed

Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -85,9 +85,9 @@ def download_images(image_urls: str) -> list:
85
  Returns:
86
  List of PIL.Image.Image objects wrapped by gr.Image
87
  """
88
- urls = [u.strip() for u in image_urls.split(",") if u.strip()] # strip() removes whitespaces
89
  images = []
90
- for __, url in enumerate(urls, start=1): # enumerate seems not needed... keeping it for now
91
  try:
92
  # Fetch the image bytes
93
  resp = requests.get(url, timeout=10)
@@ -98,8 +98,8 @@ def download_images(image_urls: str) -> list:
98
  images.append(img)
99
 
100
  except Exception as e:
101
- print(f"Failed to download from {url}: {e}")
102
-
103
  wrapped = []
104
  for img in images:
105
  wrapped.append(gr.Image(value=img))
 
85
  Returns:
86
  List of PIL.Image.Image objects wrapped by gr.Image
87
  """
88
+ urls = [u.strip() for u in image_urls.split(",") if u.strip()] # strip() removes whitespaces
89
  images = []
90
+ for n_url, url in enumerate(urls, start=1): # enumerate seems not needed... keeping it for now
91
  try:
92
  # Fetch the image bytes
93
  resp = requests.get(url, timeout=10)
 
98
  images.append(img)
99
 
100
  except Exception as e:
101
+ print(f"Failed to download from url {n_url} ({url}): {e}")
102
+
103
  wrapped = []
104
  for img in images:
105
  wrapped.append(gr.Image(value=img))