Buckets:
| """cwm3/probes/aide_hm_late.py — P4 (AIDE): High-Motion clips x late horizons (h = 4, 5) x body part, from the STORED pred_test.npz files | |
| (read-only; aide/results/runs/<run>/pred_test.npz), protocol GT = cache S10 test rows (driver `first`, grid `floor`), HM = top 60 clips by | |
| the mean of the 4 future transitions (aide/eval/metrics.hm_mask). Clip bootstrap 95 % CI (10k) and paired Δ vs zero-velocity. | |
| -> results/tables/latent_aide_hm_late.md | |
| """ | |
| from __future__ import annotations | |
| import os | |
| import sys | |
| import time | |
| from pathlib import Path | |
| os.environ.setdefault("OMP_NUM_THREADS", "4") | |
| import numpy as np # noqa: E402 | |
| CWM3 = Path(__file__).resolve().parents[1] | |
| sys.path.insert(0, str(CWM3)) | |
| sys.path.insert(0, str(Path(__file__).resolve().parent)) | |
| from aide.data import protocol as P # noqa: E402 | |
| from aide.eval import metrics as M # noqa: E402 | |
| from aide.eval.harness import load_split, align, zero_velocity # noqa: E402 | |
| import importlib.util as _ilu # noqa: E402 | |
| _spec = _ilu.spec_from_file_location("probes_common", Path(__file__).resolve().parent / "common.py") # cwm3/common (runmeta) shadows the name | |
| C = _ilu.module_from_spec(_spec) | |
| _spec.loader.exec_module(C) | |
| GROUPS = {"zero_velocity": ["zero_velocity"], "zv_shrink_val": ["zv_shrink_val"], | |
| "simlpe_kp": ["simlpe_kp_s42_v2", "simlpe_kp_s123_v2", "simlpe_kp_s456_v2"], | |
| "cwm3d_kp": ["cwm3d_kp_s42_v2", "cwm3d_kp_s123_v2", "cwm3d_kp_s456_v2"], | |
| "cwm3d_vis (extra)": ["cwm3d_vis_s42_v2", "cwm3d_vis_s123_v2", "cwm3d_vis_s456_v2"], | |
| "driverwm_repro (extra)": ["driverwm_repro_s42_v2", "driverwm_repro_s123_v2", "driverwm_repro_s456_v2"]} | |
| RUNS = CWM3 / "aide" / "results" / "runs" | |
| def main(): | |
| t0 = time.time() | |
| d = load_split("test") | |
| gt = d["S10"][:, P.T_OBS:] | |
| hm, thr, score = M.hm_mask(gt) | |
| zv = zero_velocity(d["S10"]) | |
| err_zv = M.joint_errors(zv, gt) | |
| out = {"hm_n": int(hm.sum()), "hm_threshold": thr, "groups": {}} | |
| rows_h, rows_p = [], [] | |
| for g, runs in GROUPS.items(): | |
| errs = [] | |
| for r in runs: | |
| p = RUNS / r / "pred_test.npz" | |
| if not p.exists(): | |
| continue | |
| z = np.load(p, allow_pickle=False) | |
| pred = np.asarray(z["pred"], np.float64)[align(z, d["clip_id"])] | |
| errs.append(M.joint_errors(pred, gt)) | |
| if not errs: | |
| continue | |
| e = np.mean(errs, 0) # seed-mean per (clip, h, joint) error | |
| rec = {"n_seeds": len(errs)} | |
| for h in (4, 5): | |
| for part, idx in P.PARTS.items(): | |
| pc = e[hm, h - 1][:, idx].mean(1) # per HM clip | |
| pz = err_zv[hm, h - 1][:, idx].mean(1) | |
| lo, hi = M.bootstrap_ci(pc, 10000, 0) | |
| dd = M.paired_diff(pc, pz, 10000, 0) | |
| rec[f"hm_h{h}_{part}"] = {"value": float(pc.mean()), "ci": [lo, hi], "d_vs_zv": dd, "all_value": float(e[:, h - 1][:, idx].mean())} | |
| pc = e[hm, h - 1].mean(1) | |
| pz = err_zv[hm, h - 1].mean(1) | |
| lo, hi = M.bootstrap_ci(pc, 10000, 0) | |
| rec[f"hm_h{h}_all"] = {"value": float(pc.mean()), "ci": [lo, hi], "d_vs_zv": M.paired_diff(pc, pz, 10000, 0), "all_value": float(e[:, h - 1].mean())} | |
| out["groups"][g] = rec | |
| for h in (4, 5): | |
| rows_h.append([g, len(errs), h] + [f"{rec[f'hm_h{h}_{k}']['value']:.1f} [{rec[f'hm_h{h}_{k}']['ci'][0]:.1f}, {rec[f'hm_h{h}_{k}']['ci'][1]:.1f}]" for k in ("all", "body", "face", "lhand", "rhand")]) | |
| rows_p.append([g, h] + [(f"{rec[f'hm_h{h}_{k}']['d_vs_zv']['mean']:+.1f} [{rec[f'hm_h{h}_{k}']['d_vs_zv']['ci_lo']:+.1f}, {rec[f'hm_h{h}_{k}']['d_vs_zv']['ci_hi']:+.1f}]" if g != "zero_velocity" else "0") | |
| for k in ("all", "body", "face", "lhand", "rhand")]) | |
| print(g, {k: round(v["value"], 1) for k, v in rec.items() if isinstance(v, dict)}) | |
| C.write_json(C.OUT / "aide_hm_late_latest.json", out) | |
| L = [f"# AIDE — High-Motion clips at late horizons (P4)", "", | |
| f"Generated {C.stamp()} by `probes/aide_hm_late.py` from the stored `aide/results/runs/*/pred_test.npz` (official test split, n=609; HM = top {out['hm_n']} clips " | |
| f"by mean GT displacement over the 4 future transitions, threshold {thr:.2f} px; driver `{P.DRIVER_RULE}`, grid `{P.SAMPLE_GRID}`). Learned groups are seed means of " | |
| "per-clip errors (3 seeds); CIs are clip bootstraps (10k), Δ = paired per-clip difference vs zero-velocity (negative = better). HM n=60 -> wide CIs.", "", | |
| "## HM-subset MPJPE (px) at h = 4 and h = 5, per part", "", | |
| C.md_table(["group", "seeds", "h", "all joints", "body", "face", "lhand", "rhand"], rows_h), "", | |
| "## Paired Δ vs zero-velocity on the HM subset (px)", "", | |
| C.md_table(["group", "h", "all joints", "body", "face", "lhand", "rhand"], rows_p), "", | |
| "Paper Driver-WM HM h=5 (all joints): 155.82 px (Table 1 text); paper ZV HM h=5 is not reported per part.", ""] | |
| (C.TABLES / "latent_aide_hm_late.md").write_text("\n".join(L) + "\n") | |
| print(f"done {time.time() - t0:.0f}s -> {C.TABLES / 'latent_aide_hm_late.md'}") | |
| if __name__ == "__main__": | |
| main() | |
Xet Storage Details
- Size:
- 5.23 kB
- Xet hash:
- deb351e4844658269bf23e1b9373a637df4c012a634ad1bda526bb2f0be70d1d
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.