Update image_fetcher.py
Browse files- image_fetcher.py +3 -0
image_fetcher.py
CHANGED
|
@@ -10,6 +10,7 @@ import time
|
|
| 10 |
# Setup /tmp directory for Hugging Face
|
| 11 |
IMAGE_DIR = "/tmp/images"
|
| 12 |
os.makedirs(IMAGE_DIR, exist_ok=True)
|
|
|
|
| 13 |
|
| 14 |
# Headers
|
| 15 |
def get_headers():
|
|
@@ -55,6 +56,7 @@ async def search_and_download(session, prompt, sem):
|
|
| 55 |
url = item.get("image")
|
| 56 |
result = await fetch_image(session, url, name)
|
| 57 |
if "Saved" in result:
|
|
|
|
| 58 |
return result
|
| 59 |
return f"No valid image for: {prompt}"
|
| 60 |
except Exception as e:
|
|
@@ -68,4 +70,5 @@ async def main(prompts):
|
|
| 68 |
results = await asyncio.gather(*tasks)
|
| 69 |
for res in results:
|
| 70 |
print(res)
|
|
|
|
| 71 |
|
|
|
|
| 10 |
# Setup /tmp directory for Hugging Face
|
| 11 |
IMAGE_DIR = "/tmp/images"
|
| 12 |
os.makedirs(IMAGE_DIR, exist_ok=True)
|
| 13 |
+
image_nlst=[]
|
| 14 |
|
| 15 |
# Headers
|
| 16 |
def get_headers():
|
|
|
|
| 56 |
url = item.get("image")
|
| 57 |
result = await fetch_image(session, url, name)
|
| 58 |
if "Saved" in result:
|
| 59 |
+
image_nlst.append(result.lstrip("Saved:"))
|
| 60 |
return result
|
| 61 |
return f"No valid image for: {prompt}"
|
| 62 |
except Exception as e:
|
|
|
|
| 70 |
results = await asyncio.gather(*tasks)
|
| 71 |
for res in results:
|
| 72 |
print(res)
|
| 73 |
+
return image_nlst
|
| 74 |
|