Spaces:
Sleeping
Sleeping
File size: 930 Bytes
ce53f55 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
#!/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")
|