Datasets:
Download scripts/prepare_datasets.py from perpetual-research/splatbench: direct link, hf CLI and curl.
- Browser
- Download file 2 kB
-
https://huggingface.co/datasets/perpetual-research/splatbench/resolve/main/scripts/prepare_datasets.py
- Command line
-
hf download hf://datasets/perpetual-research/splatbench/scripts/prepare_datasets.py
-
curl -L -o prepare_datasets.py https://huggingface.co/datasets/perpetual-research/splatbench/resolve/main/scripts/prepare_datasets.py
2 kB
| """Rebuild the NeRF-Synthetic and captured objects of the task set from their public sources. | |
| uv run python scripts/prepare_datasets.py # all nine | |
| uv run python scripts/prepare_datasets.py --names nerf_lego # one object | |
| Sources: NeRF-Synthetic (lego, chair, hotdog, ficus, mic, drums) from a Hugging Face mirror, Tanks and Temples | |
| (Ignatius, Caterpillar) from the NSVF release, BlendedMVS (jade) from a Hugging Face mirror. Downloads go to | |
| data/raw/. Each object is normalized to +Z up inside [-0.9, 0.9]^3 with 8 reference and 8 held-out views at 256 px. | |
| """ | |
| import argparse | |
| import sys | |
| import traceback | |
| from splatbench.datasets import load_bmvs, load_nerf_synthetic, load_nsvf_tt | |
| from splatbench.prep import prepare_scene | |
| LOADERS = { | |
| "nerf_lego": lambda: load_nerf_synthetic("lego"), | |
| "nerf_chair": lambda: load_nerf_synthetic("chair"), | |
| "nerf_hotdog": lambda: load_nerf_synthetic("hotdog"), | |
| "nerf_ficus": lambda: load_nerf_synthetic("ficus"), | |
| "nerf_mic": lambda: load_nerf_synthetic("mic"), | |
| "nerf_drums": lambda: load_nerf_synthetic("drums"), | |
| "tt_ignatius": lambda: load_nsvf_tt("Ignatius"), | |
| "tt_caterpillar": lambda: load_nsvf_tt("Caterpillar", select="mask"), | |
| "bmvs_jade": lambda: load_bmvs("jade"), | |
| } | |
| ap = argparse.ArgumentParser() | |
| ap.add_argument("--out", default="data/bench") | |
| ap.add_argument("--names", nargs="*", default=list(LOADERS)) | |
| ap.add_argument("--iters", type=int, default=2000) | |
| ap.add_argument("--device", default="cuda") | |
| a = ap.parse_args() | |
| failed = [] | |
| for name in a.names: | |
| try: | |
| sc = LOADERS[name]() | |
| assert sc.name == name, (sc.name, name) | |
| prepare_scene(sc, a.out, iters=a.iters, device=a.device, log=lambda s: print(s, flush=True)) | |
| except Exception as e: # one failing object must not block the others | |
| failed.append(name) | |
| print(f"[{name}] FAILED: {type(e).__name__}: {e}", flush=True) | |
| traceback.print_exc() | |
| print("done; failed:", failed, file=sys.stderr) | |