""" Download the Religious Artwork Dataset from Kaggle into data/. Requires the Kaggle API (pip install kaggle) and either ~/.kaggle/kaggle.json or the KAGGLE_API_TOKEN environment variable (create a token at https://www.kaggle.com/settings). Usage: python data/download.py """ import shutil import subprocess import sys import zipfile from pathlib import Path DATASET = "zigaklun/religious-artwork-dataset" DATA = Path(__file__).resolve().parent def main(): zip_path = DATA / "religious-artwork-dataset.zip" if not zip_path.exists(): print(f"Downloading {DATASET} (~6 GB) ...") r = subprocess.run(["kaggle", "datasets", "download", "-d", DATASET, "-p", str(DATA)]) if r.returncode != 0: sys.exit("kaggle CLI failed — is your Kaggle API token set up?") print("Unpacking ...") with zipfile.ZipFile(zip_path) as z: z.extractall(DATA) # Kaggle nests the image folder: images/images/*.jpg -> flatten to images/ nested = DATA / "images" / "images" if nested.is_dir(): for f in nested.iterdir(): shutil.move(str(f), DATA / "images" / f.name) nested.rmdir() n = len(list((DATA / "images").glob("*.jpg"))) print(f"Done. data/artwork_metadata.csv + data/images/ ({n} images, expected 3997)") if __name__ == "__main__": main()