Spaces:
Runtime error
Runtime error
| #!/usr/bin/env python | |
| """ | |
| Lightweight helper to download the COCO FAISS index + caption array | |
| into ./scripts/ the first time the Space boots. | |
| """ | |
| import pathlib, subprocess, sys | |
| FILES = { | |
| "coco_caption_clip.index": | |
| "https://huggingface.co/datasets/stephenebert/coco-faiss-assets/resolve/main/coco_caption_clip.index", | |
| "coco_caption_texts.npy": | |
| "https://huggingface.co/datasets/stephenebert/coco-faiss-assets/resolve/main/coco_caption_texts.npy", | |
| } | |
| DEST = pathlib.Path(__file__).resolve().parent | |
| def fetch(url, out): | |
| cmd = ["curl", "-L", "--progress-bar", "-o", str(out), url] | |
| print("β€΅οΈ ", " ".join(cmd), flush=True) | |
| subprocess.check_call(cmd) | |
| for fname, url in FILES.items(): | |
| path = DEST / fname | |
| if path.exists(): | |
| print(f"βοΈ {fname} already present") | |
| continue | |
| print(f"β¬οΈ Downloading {fname} β¦") | |
| fetch(url, path) | |
| print("β All assets ready") | |