Spaces:
Sleeping
Sleeping
im
commited on
Commit
·
f341903
1
Parent(s):
def5cea
ok for commit
Browse files- app.py +9 -2
- flagged/log.csv +2 -0
app.py
CHANGED
@@ -109,10 +109,16 @@ def download_image_as_pil(url: str, timeout: int = 10) -> Image.Image:
|
|
109 |
return None
|
110 |
|
111 |
# Embedding function for a batch of images
|
112 |
-
def batch_process_images(image_urls:
|
|
|
|
|
|
|
|
|
|
|
|
|
113 |
embeddings = []
|
114 |
results = []
|
115 |
-
for url in
|
116 |
try:
|
117 |
# Download image
|
118 |
image = download_image_as_pil(url)
|
@@ -136,6 +142,7 @@ def batch_process_images(image_urls: list):
|
|
136 |
results.append({"image_url": url, "error": str(e)})
|
137 |
return results
|
138 |
|
|
|
139 |
# Gradio Interface
|
140 |
iface = gr.Interface(
|
141 |
fn=batch_process_images,
|
|
|
109 |
return None
|
110 |
|
111 |
# Embedding function for a batch of images
|
112 |
+
def batch_process_images(image_urls: str):
|
113 |
+
# Split the input string by commas and strip whitespace
|
114 |
+
urls = [url.strip() for url in image_urls.split(",") if url.strip()]
|
115 |
+
|
116 |
+
if not urls:
|
117 |
+
return {"error": "No valid image URLs provided."}
|
118 |
+
|
119 |
embeddings = []
|
120 |
results = []
|
121 |
+
for url in urls:
|
122 |
try:
|
123 |
# Download image
|
124 |
image = download_image_as_pil(url)
|
|
|
142 |
results.append({"image_url": url, "error": str(e)})
|
143 |
return results
|
144 |
|
145 |
+
|
146 |
# Gradio Interface
|
147 |
iface = gr.Interface(
|
148 |
fn=batch_process_images,
|
flagged/log.csv
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
Batch Image URLs,Embedding Results,flag,username,timestamp
|
2 |
+
"https://cdn.shopify.com/s/files/1/0522/2239/4534/files/CT21355-22_1024x1024.webp, https://cdn.shopify.com/s/files/1/0522/2239/4534/files/00907857-C6B0-4D2A-8AEA-688BDE1E67D7_1024x1024.jpg","[{""image_url"": ""h"", ""error"": ""Failed to download image""}, {""image_url"": ""t"", ""error"": ""Failed to download image""}, {""image_url"": ""t"", ""error"": ""Failed to download image""}, {""image_url"": ""p"", ""error"": ""Failed to download image""}, {""image_url"": ""s"", ""error"": ""Failed to download image""}, {""image_url"": "":"", ""error"": ""Failed to download image""}, {""image_url"": ""/"", ""error"": ""Failed to download image""}, {""image_url"": ""/"", ""error"": ""Failed to download image""}, {""image_url"": ""c"", ""error"": ""Failed to download image""}, {""image_url"": ""d"", ""error"": ""Failed to download image""}, {""image_url"": ""n"", ""error"": ""Failed to download image""}, {""image_url"": ""."", ""error"": ""Failed to download image""}, {""image_url"": ""s"", ""error"": ""Failed to download image""}, {""image_url"": ""h"", ""error"": ""Failed to download image""}, {""image_url"": ""o"", ""error"": ""Failed to download image""}, {""image_url"": ""p"", ""error"": ""Failed to download image""}, {""image_url"": ""i"", ""error"": ""Failed to download image""}, {""image_url"": ""f"", ""error"": ""Failed to download image""}, {""image_url"": ""y"", ""error"": ""Failed to download image""}, {""image_url"": ""."", ""error"": ""Failed to download image""}, {""image_url"": ""c"", ""error"": ""Failed to download image""}, {""image_url"": ""o"", ""error"": ""Failed to download image""}, {""image_url"": ""m"", ""error"": ""Failed to download image""}, {""image_url"": ""/"", ""error"": ""Failed to download image""}, {""image_url"": ""s"", ""error"": ""Failed to download image""}, {""image_url"": ""/"", ""error"": ""Failed to download image""}, {""image_url"": ""f"", ""error"": ""Failed to download image""}, {""image_url"": ""i"", ""error"": ""Failed to download image""}, {""image_url"": ""l"", ""error"": ""Failed to download image""}, {""image_url"": ""e"", ""error"": ""Failed to download image""}, {""image_url"": ""s"", ""error"": ""Failed to download image""}, {""image_url"": ""/"", ""error"": ""Failed to download image""}, {""image_url"": ""1"", ""error"": ""Failed to download image""}, {""image_url"": ""/"", ""error"": ""Failed to download image""}, {""image_url"": ""0"", ""error"": ""Failed to download image""}, {""image_url"": ""5"", ""error"": ""Failed to download image""}, {""image_url"": ""2"", ""error"": ""Failed to download image""}, {""image_url"": ""2"", ""error"": ""Failed to download image""}, {""image_url"": ""/"", ""error"": ""Failed to download image""}, {""image_url"": ""2"", ""error"": ""Failed to download image""}, {""image_url"": ""2"", ""error"": ""Failed to download image""}, {""image_url"": ""3"", ""error"": ""Failed to download image""}, {""image_url"": ""9"", ""error"": ""Failed to download image""}, {""image_url"": ""/"", ""error"": ""Failed to download image""}, {""image_url"": ""4"", ""error"": ""Failed to download image""}, {""image_url"": ""5"", ""error"": ""Failed to download image""}, {""image_url"": ""3"", ""error"": ""Failed to download image""}, {""image_url"": ""4"", ""error"": ""Failed to download image""}, {""image_url"": ""/"", ""error"": ""Failed to download image""}, {""image_url"": ""f"", ""error"": ""Failed to download image""}, {""image_url"": ""i"", ""error"": ""Failed to download image""}, {""image_url"": ""l"", ""error"": ""Failed to download image""}, {""image_url"": ""e"", ""error"": ""Failed to download image""}, {""image_url"": ""s"", ""error"": ""Failed to download image""}, {""image_url"": ""/"", ""error"": ""Failed to download image""}, {""image_url"": ""C"", ""error"": ""Failed to download image""}, {""image_url"": ""T"", ""error"": ""Failed to download image""}, {""image_url"": ""2"", ""error"": ""Failed to download image""}, {""image_url"": ""1"", ""error"": ""Failed to download image""}, {""image_url"": ""3"", ""error"": ""Failed to download image""}, {""image_url"": ""5"", ""error"": ""Failed to download image""}, {""image_url"": ""5"", ""error"": ""Failed to download image""}, {""image_url"": ""-"", ""error"": ""Failed to download image""}, {""image_url"": ""2"", ""error"": ""Failed to download image""}, {""image_url"": ""2"", ""error"": ""Failed to download image""}, {""image_url"": ""_"", ""error"": ""Failed to download image""}, {""image_url"": ""1"", ""error"": ""Failed to download image""}, {""image_url"": ""0"", ""error"": ""Failed to download image""}, {""image_url"": ""2"", ""error"": ""Failed to download image""}, {""image_url"": ""4"", ""error"": ""Failed to download image""}, {""image_url"": ""x"", ""error"": ""Failed to download image""}, {""image_url"": ""1"", ""error"": ""Failed to download image""}, {""image_url"": ""0"", ""error"": ""Failed to download image""}, {""image_url"": ""2"", ""error"": ""Failed to download image""}, {""image_url"": ""4"", ""error"": ""Failed to download image""}, {""image_url"": ""."", ""error"": ""Failed to download image""}, {""image_url"": ""w"", ""error"": ""Failed to download image""}, {""image_url"": ""e"", ""error"": ""Failed to download image""}, {""image_url"": ""b"", ""error"": ""Failed to download image""}, {""image_url"": ""p"", ""error"": ""Failed to download image""}, {""image_url"": "","", ""error"": ""Failed to download image""}, {""image_url"": "" "", ""error"": ""Failed to download image""}, {""image_url"": ""h"", ""error"": ""Failed to download image""}, {""image_url"": ""t"", ""error"": ""Failed to download image""}, {""image_url"": ""t"", ""error"": ""Failed to download image""}, {""image_url"": ""p"", ""error"": ""Failed to download image""}, {""image_url"": ""s"", ""error"": ""Failed to download image""}, {""image_url"": "":"", ""error"": ""Failed to download image""}, {""image_url"": ""/"", ""error"": ""Failed to download image""}, {""image_url"": ""/"", ""error"": ""Failed to download image""}, {""image_url"": ""c"", ""error"": ""Failed to download image""}, {""image_url"": ""d"", ""error"": ""Failed to download image""}, {""image_url"": ""n"", ""error"": ""Failed to download image""}, {""image_url"": ""."", ""error"": ""Failed to download image""}, {""image_url"": ""s"", ""error"": ""Failed to download image""}, {""image_url"": ""h"", ""error"": ""Failed to download image""}, {""image_url"": ""o"", ""error"": ""Failed to download image""}, {""image_url"": ""p"", ""error"": ""Failed to download image""}, {""image_url"": ""i"", ""error"": ""Failed to download image""}, {""image_url"": ""f"", ""error"": ""Failed to download image""}, {""image_url"": ""y"", ""error"": ""Failed to download image""}, {""image_url"": ""."", ""error"": ""Failed to download image""}, {""image_url"": ""c"", ""error"": ""Failed to download image""}, {""image_url"": ""o"", ""error"": ""Failed to download image""}, {""image_url"": ""m"", ""error"": ""Failed to download image""}, {""image_url"": ""/"", ""error"": ""Failed to download image""}, {""image_url"": ""s"", ""error"": ""Failed to download image""}, {""image_url"": ""/"", ""error"": ""Failed to download image""}, {""image_url"": ""f"", ""error"": ""Failed to download image""}, {""image_url"": ""i"", ""error"": ""Failed to download image""}, {""image_url"": ""l"", ""error"": ""Failed to download image""}, {""image_url"": ""e"", ""error"": ""Failed to download image""}, {""image_url"": ""s"", ""error"": ""Failed to download image""}, {""image_url"": ""/"", ""error"": ""Failed to download image""}, {""image_url"": ""1"", ""error"": ""Failed to download image""}, {""image_url"": ""/"", ""error"": ""Failed to download image""}, {""image_url"": ""0"", ""error"": ""Failed to download image""}, {""image_url"": ""5"", ""error"": ""Failed to download image""}, {""image_url"": ""2"", ""error"": ""Failed to download image""}, {""image_url"": ""2"", ""error"": ""Failed to download image""}, {""image_url"": ""/"", ""error"": ""Failed to download image""}, {""image_url"": ""2"", ""error"": ""Failed to download image""}, {""image_url"": ""2"", ""error"": ""Failed to download image""}, {""image_url"": ""3"", ""error"": ""Failed to download image""}, {""image_url"": ""9"", ""error"": ""Failed to download image""}, {""image_url"": ""/"", ""error"": ""Failed to download image""}, {""image_url"": ""4"", ""error"": ""Failed to download image""}, {""image_url"": ""5"", ""error"": ""Failed to download image""}, {""image_url"": ""3"", ""error"": ""Failed to download image""}, {""image_url"": ""4"", ""error"": ""Failed to download image""}, {""image_url"": ""/"", ""error"": ""Failed to download image""}, {""image_url"": ""f"", ""error"": ""Failed to download image""}, {""image_url"": ""i"", ""error"": ""Failed to download image""}, {""image_url"": ""l"", ""error"": ""Failed to download image""}, {""image_url"": ""e"", ""error"": ""Failed to download image""}, {""image_url"": ""s"", ""error"": ""Failed to download image""}, {""image_url"": ""/"", ""error"": ""Failed to download image""}, {""image_url"": ""0"", ""error"": ""Failed to download image""}, {""image_url"": ""0"", ""error"": ""Failed to download image""}, {""image_url"": ""9"", ""error"": ""Failed to download image""}, {""image_url"": ""0"", ""error"": ""Failed to download image""}, {""image_url"": ""7"", ""error"": ""Failed to download image""}, {""image_url"": ""8"", ""error"": ""Failed to download image""}, {""image_url"": ""5"", ""error"": ""Failed to download image""}, {""image_url"": ""7"", ""error"": ""Failed to download image""}, {""image_url"": ""-"", ""error"": ""Failed to download image""}, {""image_url"": ""C"", ""error"": ""Failed to download image""}, {""image_url"": ""6"", ""error"": ""Failed to download image""}, {""image_url"": ""B"", ""error"": ""Failed to download image""}, {""image_url"": ""0"", ""error"": ""Failed to download image""}, {""image_url"": ""-"", ""error"": ""Failed to download image""}, {""image_url"": ""4"", ""error"": ""Failed to download image""}, {""image_url"": ""D"", ""error"": ""Failed to download image""}, {""image_url"": ""2"", ""error"": ""Failed to download image""}, {""image_url"": ""A"", ""error"": ""Failed to download image""}, {""image_url"": ""-"", ""error"": ""Failed to download image""}, {""image_url"": ""8"", ""error"": ""Failed to download image""}, {""image_url"": ""A"", ""error"": ""Failed to download image""}, {""image_url"": ""E"", ""error"": ""Failed to download image""}, {""image_url"": ""A"", ""error"": ""Failed to download image""}, {""image_url"": ""-"", ""error"": ""Failed to download image""}, {""image_url"": ""6"", ""error"": ""Failed to download image""}, {""image_url"": ""8"", ""error"": ""Failed to download image""}, {""image_url"": ""8"", ""error"": ""Failed to download image""}, {""image_url"": ""B"", ""error"": ""Failed to download image""}, {""image_url"": ""D"", ""error"": ""Failed to download image""}, {""image_url"": ""E"", ""error"": ""Failed to download image""}, {""image_url"": ""1"", ""error"": ""Failed to download image""}, {""image_url"": ""E"", ""error"": ""Failed to download image""}, {""image_url"": ""6"", ""error"": ""Failed to download image""}, {""image_url"": ""7"", ""error"": ""Failed to download image""}, {""image_url"": ""D"", ""error"": ""Failed to download image""}, {""image_url"": ""7"", ""error"": ""Failed to download image""}, {""image_url"": ""_"", ""error"": ""Failed to download image""}, {""image_url"": ""1"", ""error"": ""Failed to download image""}, {""image_url"": ""0"", ""error"": ""Failed to download image""}, {""image_url"": ""2"", ""error"": ""Failed to download image""}, {""image_url"": ""4"", ""error"": ""Failed to download image""}, {""image_url"": ""x"", ""error"": ""Failed to download image""}, {""image_url"": ""1"", ""error"": ""Failed to download image""}, {""image_url"": ""0"", ""error"": ""Failed to download image""}, {""image_url"": ""2"", ""error"": ""Failed to download image""}, {""image_url"": ""4"", ""error"": ""Failed to download image""}, {""image_url"": ""."", ""error"": ""Failed to download image""}, {""image_url"": ""j"", ""error"": ""Failed to download image""}, {""image_url"": ""p"", ""error"": ""Failed to download image""}, {""image_url"": ""g"", ""error"": ""Failed to download image""}]",,,2025-01-18 01:08:09.984056
|