Datasets:
Download scripts/rescore.py from perpetual-research/splatbench: direct link, hf CLI and curl.
- Browser
- Download file 2.36 kB
-
https://huggingface.co/datasets/perpetual-research/splatbench/resolve/main/scripts/rescore.py
- Command line
-
hf download hf://datasets/perpetual-research/splatbench/scripts/rescore.py
-
curl -L -o rescore.py https://huggingface.co/datasets/perpetual-research/splatbench/resolve/main/scripts/rescore.py
2.36 kB
| """Re-render and re-score submitted scenes from the episode tables: an independent check of the recorded scores. | |
| uv run python scripts/rescore.py --setting medium_effort | |
| uv run python scripts/rescore.py --episode gpt-6-astra__nerf_lego__sculpt__eval | |
| The stored Gaussians are rounded to 3 decimals, as the environment logs them, so a re-score can differ from the | |
| recorded score by a little (medium effort: mean |difference| 0.02 points, largest 0.22). | |
| """ | |
| import argparse | |
| import json | |
| from pathlib import Path | |
| import numpy as np | |
| import pyarrow.parquet as pq | |
| import torch | |
| from splatbench.render import empty_gaussians | |
| from splatbench.scene import Scene | |
| from splatbench.score import evaluate, splat_score | |
| ap = argparse.ArgumentParser() | |
| ap.add_argument("--data", default="data") | |
| ap.add_argument("--setting", default="medium_effort", | |
| choices=["medium_effort", "high_effort", "max_effort", "early_submit_refused", "one_shot"]) | |
| ap.add_argument("--episode", default=None) | |
| ap.add_argument("--limit", type=int, default=None) | |
| ap.add_argument("--device", default="cuda" if torch.cuda.is_available() else "cpu") | |
| a = ap.parse_args() | |
| rows = pq.read_table(Path(a.data) / "episodes" / f"{a.setting}.parquet", | |
| columns=["episode_id", "task_id", "score", "final_gaussians"]).to_pylist() | |
| if a.episode: | |
| rows = [r for r in rows if r["episode_id"] == a.episode] | |
| rows = rows[:a.limit] if a.limit else rows | |
| scenes, diffs = {}, [] | |
| for r in rows: | |
| scene = r["task_id"].split("__")[0] | |
| if scene not in scenes: | |
| sd = Path(a.data) / "bench" / "scenes" / scene | |
| scenes[scene] = (Scene.load(sd), json.loads((sd / "norm.json").read_text())) | |
| sc, norm = scenes[scene] | |
| G = r["final_gaussians"] | |
| f = lambda k: torch.tensor([g[k] for g in G], dtype=torch.float32, device=a.device) | |
| gs = dict(means=f("pos"), scales=f("scale"), quats=f("quat"), colors=f("color"), opacities=f("opacity")) if G \ | |
| else empty_gaussians(a.device) | |
| s = splat_score(evaluate(gs, sc, "test", a.device, with_lpips=True)["mean"], norm["test"])["score"] | |
| diffs.append(s - r["score"]) | |
| print(f"{r['episode_id']:58s} recorded {r['score']:7.2f} re-scored {s:7.2f} difference {s - r['score']:+.3f}", flush=True) | |
| d = np.abs(np.array(diffs)) | |
| print(f"{len(d)} episodes: mean |difference| {d.mean():.3f}, largest {d.max():.3f}") | |