#!/usr/bin/env python3 """Portable held-out (NV) index for FORGE3DBench rest-658 (copy of the FB150 branch of build_heldout_index.py). Input : heldout_rest658.json (absolute-path index written by prepare_heldout_rest658.py; schema of heldout_fb150.json) Output: heldout_index/heldout_rest658.json = {object: [{tag, cam, vis, px, px_ok, files, src: "heldout", kind: "heldout"}, ...]} = ALL 20 non-input scene cams per object (13,160 records); files=False -> empty modal mask, no png/npz (files live in data/rest658_heldout.tar.gz.part* -> rest658_heldout/{inputs,renders}) No record is filtered here; the protocol filter (vis >= --min-vis 0.2, px >= --min-px 400, files) is applied by eval_rest658_wrapper.py at run time. """ import argparse, json from pathlib import Path def main(): ap = argparse.ArgumentParser() ap.add_argument("--src", type=Path, default=Path("/lp-dev/jonghoon/mv-mesh/.debug/hub_rest658_heldout/heldout_rest658.json")) ap.add_argument("--out", type=Path, default=Path(__file__).resolve().parent / "heldout_index") a = ap.parse_args() a.out.mkdir(parents=True, exist_ok=True) fb = json.loads(a.src.read_text()) d = {o: [dict(tag=r["tag"], cam=r["cam"], vis=r["vis"], px=r["px"], px_ok=r["px_ok"], files=r["files"], src="heldout", kind="heldout") for r in v] for o, v in fb.items()} (a.out / "heldout_rest658.json").write_text(json.dumps(d, separators=(",", ":"))) n = [len(v) for v in d.values()] print("rest658 objects", len(d), "records", sum(n), "min/obj", min(n)) v = [len([r for r in x if r["vis"] >= 0.2 and r["px"] >= 400 and r["files"]]) for x in d.values()] print("rest658 protocol (vis>=0.20 & px>=400): records", sum(v), "min/obj", min(v), "objs with 0:", sum(x == 0 for x in v)) if __name__ == "__main__": main()