minor change in download images
Browse filesused iterator to signal which url failed
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()]
|
89 |
images = []
|
90 |
-
for
|
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))
|