cvikl's picture
Space: code only; data fetched from HF dataset repo at startup
82d2327
Raw
History Blame Contribute Delete
836 Bytes
"""
Fetch data/ from the companion HF dataset repo if not already present.
Used by the Docker entrypoint on Hugging Face Spaces, where the Space repo
holds only code (1 GB limit) and the dataset repo holds images + features.
"""
import os
from pathlib import Path
DATASET_REPO = os.environ.get("DATA_REPO", "cvikl/religious-artwork-analysis-data")
DATA = Path("data")
def main():
if (DATA / "artwork_metadata.csv").exists() and any((DATA / "images").glob("*.jpg")):
print("data/ already present, skipping download")
return
from huggingface_hub import snapshot_download
print(f"Downloading {DATASET_REPO} into data/ ...")
snapshot_download(repo_id=DATASET_REPO, repo_type="dataset",
local_dir=DATA, max_workers=8)
print("Data ready.")
if __name__ == "__main__":
main()