File size: 917 Bytes
152228b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
33
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)