scripts: publish what the READMEs tell you to run
Browse files- scripts/build_testset_page.py +149 -0
scripts/build_testset_page.py
ADDED
|
@@ -0,0 +1,149 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Example page for the probe test set: the README's claims, shown.
|
| 2 |
+
|
| 3 |
+
A README can assert that the overlay lands on the sensor. A page with 72 of
|
| 4 |
+
them lets a reader check. Static stills, not clips: the question here is where
|
| 5 |
+
ground truth IS, not how it moves — the clips already exist under /probes/.
|
| 6 |
+
"""
|
| 7 |
+
from __future__ import annotations
|
| 8 |
+
|
| 9 |
+
import argparse
|
| 10 |
+
import json
|
| 11 |
+
import shutil
|
| 12 |
+
import sys
|
| 13 |
+
from pathlib import Path
|
| 14 |
+
|
| 15 |
+
sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
|
| 16 |
+
|
| 17 |
+
SRC = Path("/media/yxma/Disk1/twm/probe_testset")
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
def _sessions_note(man, runs):
|
| 21 |
+
"""State what the POLICY is and what this DRAW happened to contain.
|
| 22 |
+
|
| 23 |
+
An earlier version of this page said "2026-05-19 is excluded" long after
|
| 24 |
+
that decision was reversed. The draw happened not to select it, and the
|
| 25 |
+
prose turned an accident of sampling into a stated policy — a reader would
|
| 26 |
+
have concluded the session is unusable. Both facts are now read from the
|
| 27 |
+
manifest, so the page cannot outlive the decision.
|
| 28 |
+
"""
|
| 29 |
+
used = sorted({r["episode"].split("/")[0] for r in runs})
|
| 30 |
+
elig = sorted(man.get("trusted_sessions", []))
|
| 31 |
+
excl = man.get("excluded_sessions") or {}
|
| 32 |
+
parts = [f"Start frames are drawn from <b>held-out intervals</b> of "
|
| 33 |
+
f"<code>splits.json</code> — never training frames."]
|
| 34 |
+
parts.append(f"Eligible sessions: {', '.join(elig)}. "
|
| 35 |
+
f"This draw happened to select {', '.join(used)}"
|
| 36 |
+
+ (f"; {', '.join(sorted(set(elig) - set(used)))} was not sampled "
|
| 37 |
+
f"this time, which is chance, not a judgement about it."
|
| 38 |
+
if set(elig) - set(used) else "."))
|
| 39 |
+
if excl:
|
| 40 |
+
parts.append("Excluded by policy: " + "; ".join(
|
| 41 |
+
f"<b>{k}</b> — {v}" for k, v in excl.items()))
|
| 42 |
+
resid = man.get("world_residual", {})
|
| 43 |
+
noted = [k for k, v in resid.items() if v and v.get("yaw_deg") is None
|
| 44 |
+
and v.get("in_plane_mm") is None and k in used]
|
| 45 |
+
if "2026-05-19" in elig:
|
| 46 |
+
parts.append("<b>2026-05-19</b> had its OptiTrack world redefined "
|
| 47 |
+
"mid-collection; the release applies a translation-only "
|
| 48 |
+
"correction and the residual yaw about the table normal is "
|
| 49 |
+
"<b>unmeasured</b> (about 16 px at the workspace). It is "
|
| 50 |
+
"included with that stated in <code>world_residual</code> "
|
| 51 |
+
"rather than dropped — a bounded, declared error is "
|
| 52 |
+
"not a reason to discard a fifth of the sessions.")
|
| 53 |
+
return " ".join(parts)
|
| 54 |
+
|
| 55 |
+
|
| 56 |
+
def main() -> int:
|
| 57 |
+
ap = argparse.ArgumentParser()
|
| 58 |
+
ap.add_argument("--out", default="/media/yxma/Disk1/twm/testset_page")
|
| 59 |
+
args = ap.parse_args()
|
| 60 |
+
out = Path(args.out)
|
| 61 |
+
if out.exists():
|
| 62 |
+
shutil.rmtree(out)
|
| 63 |
+
out.mkdir(parents=True)
|
| 64 |
+
shutil.copytree(SRC / "overlays", out / "overlays")
|
| 65 |
+
shutil.copy(SRC / "overlay_example.jpg", out / "overlay_example.jpg")
|
| 66 |
+
|
| 67 |
+
man = json.loads((SRC / "manifest.json").read_text())
|
| 68 |
+
runs = [json.loads((SRC / p["meta"]).read_text()) for p in man["probes"]]
|
| 69 |
+
allp = [q for r in runs for q in r["probes"]]
|
| 70 |
+
tr = [q["amplitude"] for q in allp if q["amplitude_unit"] == "m"]
|
| 71 |
+
ro = [q["amplitude"] for q in allp if q["amplitude_unit"] == "deg"]
|
| 72 |
+
pc = [q["speed_percentile"] for q in allp]
|
| 73 |
+
sep = min(q["min_separation_m"] for q in allp)
|
| 74 |
+
px = man["overlay_error_budget_px"]["camera_reprojection"]
|
| 75 |
+
|
| 76 |
+
cards = [
|
| 77 |
+
(f"{len(allp)}", f"probes · {len(runs)} start frames"),
|
| 78 |
+
(f"{min(tr):.2f}–{max(tr):.2f} m",
|
| 79 |
+
f"translation · {min(ro):.0f}–{max(ro):.0f}° rotation"),
|
| 80 |
+
(f"p{min(pc):.0f}–p{max(pc):.0f}", "speed vs the dataset"),
|
| 81 |
+
(f"~{max(px.values()):.0f} px", "worst reprojection noise floor"),
|
| 82 |
+
(f"{sep:.3f} m", "closest the hands come (rule 0.12)"),
|
| 83 |
+
]
|
| 84 |
+
sec = []
|
| 85 |
+
for r in runs:
|
| 86 |
+
tiles = "".join(
|
| 87 |
+
f"<figure><img loading='lazy' src='overlays/run{r['run']}_{q['name']}.jpg'>"
|
| 88 |
+
f"<figcaption>{q['name']} · {q['amplitude']:g}"
|
| 89 |
+
f"{'m' if q['amplitude_unit'] == 'm' else '°'} · "
|
| 90 |
+
f"{q['horizon_s']:.2f}s · p{q['speed_percentile']:.0f}</figcaption>"
|
| 91 |
+
f"</figure>" for q in r["probes"])
|
| 92 |
+
sec.append(
|
| 93 |
+
f"<h2>run{r['run']} — {r['episode']}, rows "
|
| 94 |
+
f"{r['context_rows'][0]}–{r['context_rows'][-1]} "
|
| 95 |
+
f"<small>moving {r['moving_side']}, holding {r['held_side']}</small></h2>"
|
| 96 |
+
f"<div class='grid'>{tiles}</div>")
|
| 97 |
+
|
| 98 |
+
html = """<!doctype html><html lang="en"><head><meta charset="utf-8">
|
| 99 |
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
| 100 |
+
<title>React probe test set</title><style>
|
| 101 |
+
:root{--bg:#0b1020;--fg:#e8eefb;--dim:#8ea0c2;--line:#1e2a45;--card:#111a2e;--accent:#ffc46b}
|
| 102 |
+
*{box-sizing:border-box}body{margin:0;background:var(--bg);color:var(--fg);
|
| 103 |
+
font:16px/1.6 'IBM Plex Sans',system-ui,sans-serif}
|
| 104 |
+
.wrap{max-width:1400px;margin:0 auto;padding:28px 20px 70px}
|
| 105 |
+
h1{font-size:28px;margin:0 0 8px}h2{font-size:16px;color:var(--accent);margin:30px 0 8px}
|
| 106 |
+
h2 small{color:var(--dim);font-weight:400}
|
| 107 |
+
p{color:var(--dim);max-width:78ch}code{background:#0d1526;padding:1px 5px;border-radius:4px}
|
| 108 |
+
a{color:var(--accent)}
|
| 109 |
+
.cards{display:grid;grid-template-columns:repeat(auto-fit,minmax(170px,1fr));gap:10px;margin:20px 0}
|
| 110 |
+
.card{background:var(--card);border:1px solid var(--line);border-radius:10px;padding:12px 14px}
|
| 111 |
+
.card b{display:block;font-size:22px;color:var(--accent);font-weight:650}
|
| 112 |
+
.card span{color:var(--dim);font-size:12px}
|
| 113 |
+
.grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(300px,1fr));gap:10px}
|
| 114 |
+
figure{margin:0;background:var(--card);border:1px solid var(--line);border-radius:9px;padding:7px}
|
| 115 |
+
img{width:100%;border-radius:5px;display:block}
|
| 116 |
+
figcaption{color:var(--dim);font-size:12px;margin-top:5px}
|
| 117 |
+
.hero{background:var(--card);border:1px solid var(--line);border-radius:12px;padding:10px;margin:18px 0}
|
| 118 |
+
</style></head><body><div class="wrap">
|
| 119 |
+
<h1>React probe test set</h1>
|
| 120 |
+
<p>__N__ commanded action sequences over __R__ start frames, for scoring a tactile
|
| 121 |
+
world model's rollouts against ground truth that is <b>geometric, not photometric</b>.
|
| 122 |
+
Nobody performed these motions, so there is no ground-truth future image — what
|
| 123 |
+
is ground truth is where the sensor <i>would be</i>, and its projection into each
|
| 124 |
+
camera. Full method and usage in the
|
| 125 |
+
<a href="README.md">README</a>; per-probe clips are under
|
| 126 |
+
<a href="../probes/index.html">/probes/</a>.</p>
|
| 127 |
+
<div class="hero"><img src="overlay_example.jpg">
|
| 128 |
+
<figcaption style="color:var(--dim);font-size:13px;margin-top:8px">Yellow: commanded
|
| 129 |
+
ground truth. Red: a deliberately wrong rollout, offset 25 mm in world x —
|
| 130 |
+
it reads 18–19 px against a ~6 px noise floor. Dimmed: the hand that
|
| 131 |
+
must stay still.</figcaption></div>
|
| 132 |
+
<div class="cards">__CARDS__</div>
|
| 133 |
+
<p>__SESSIONS__</p>
|
| 134 |
+
__SECS__
|
| 135 |
+
</div></body></html>"""
|
| 136 |
+
html = (html.replace("__N__", str(len(allp)))
|
| 137 |
+
.replace("__R__", str(len(runs)))
|
| 138 |
+
.replace("__CARDS__", "".join(
|
| 139 |
+
f"<div class='card'><b>{a}</b><span>{b}</span></div>" for a, b in cards))
|
| 140 |
+
.replace("__SESSIONS__", _sessions_note(man, runs))
|
| 141 |
+
.replace("__SECS__", "".join(sec)))
|
| 142 |
+
(out / "index.html").write_text(html)
|
| 143 |
+
shutil.copy(SRC / "README.md", out / "README.md")
|
| 144 |
+
print(f"{len(allp)} overlays -> {out}/index.html")
|
| 145 |
+
return 0
|
| 146 |
+
|
| 147 |
+
|
| 148 |
+
if __name__ == "__main__":
|
| 149 |
+
raise SystemExit(main())
|