Download code/scripts/bootstrap_imagenet100.py from reneeice/sparse-adversarial-research-archive: direct link, hf CLI and curl.
- Browser
- Download file 917 Bytes
-
https://huggingface.co/datasets/reneeice/sparse-adversarial-research-archive/resolve/main/code/scripts/bootstrap_imagenet100.py
- Command line
-
hf download hf://datasets/reneeice/sparse-adversarial-research-archive/code/scripts/bootstrap_imagenet100.py
-
curl -L -o bootstrap_imagenet100.py https://huggingface.co/datasets/reneeice/sparse-adversarial-research-archive/resolve/main/code/scripts/bootstrap_imagenet100.py
917 Bytes
| from __future__ import annotations | |
| import os | |
| import sys | |
| from pathlib import Path | |
| sys.path.insert(0, str(Path(__file__).resolve().parents[1])) | |
| from perturbnet.constants import IMAGENET100_REPO_ID, IMAGENET100_SPLIT | |
| from perturbnet.imagenet100_bootstrap import load_imagenet100 | |
| def main() -> int: | |
| dataset = load_imagenet100(repo_id=IMAGENET100_REPO_ID, split=IMAGENET100_SPLIT) | |
| print( | |
| f"ImageNet-100 ready: repo={IMAGENET100_REPO_ID} split={IMAGENET100_SPLIT} " | |
| f"images={int(dataset.num_rows)}" | |
| ) | |
| return 0 | |
| if __name__ == "__main__": | |
| try: | |
| exit_code = main() | |
| except Exception as exc: | |
| print(f"ImageNet-100 bootstrap failed: {exc}", file=sys.stderr) | |
| exit_code = 1 | |
| # Hard-exit: pyarrow/datasets can leave non-joinable IO threads that | |
| # deadlock normal interpreter shutdown. | |
| sys.stdout.flush() | |
| sys.stderr.flush() | |
| os._exit(exit_code) | |