File size: 836 Bytes
82d2327
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
"""
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()