Skip to content
Python

fix: bound-aware export/eval, focal-aware inference, adapter MPJPE + [email protected]; drop the rejected --detach-2d-head

mohamdev83fecb793ab5
diff --git a/benchmark/eval_3dpw_ckpt.py b/benchmark/eval_3dpw_ckpt.py
index 97ea8e6..125fc79 100644
--- a/benchmark/eval_3dpw_ckpt.py
+++ b/benchmark/eval_3dpw_ckpt.py
@@ -159,7 +159,8 @@ def main():
report = {}
hdr = (f"\n {'run':<24s} {'ckpt':<6s} {'ep':>4s} {'GT':<15s} {'J12 PA':>8s} "
f"{'J12 MPJPE':>10s} {'J14 PA':>8s} {'J14 MPJPE':>10s}"
- + (f" {'J14+ad PA':>10s}" if W_adapt is not None else ""))
+ + (f" {'J14+ad PA':>10s} {'J14+ad MPJPE':>13s}"
+ if W_adapt is not None else ""))
print(hdr)
for ck_path in args.ckpt:
@@ -191,9 +192,15 @@ def main():
f"{rows['J12']['PA_MPJPE_mm']:8.2f} {rows['J12']['MPJPE_mm']:10.2f} "
f"{rows['J14']['PA_MPJPE_mm']:8.2f} {rows['J14']['MPJPE_mm']:10.2f}")
if W_adapt is not None:
+ # Both metrics adapter-applied. The raw J14 columns read ~35 mm
+ # higher on MPJPE because they compare the MHR rig's own joint
+ # positions against the H36M convention; the adapter is what
+ # removes that fixed convention offset, so it belongs on MPJPE
+ # every bit as much as on PA-MPJPE.
line += (f" {rows['J14+adapter']['PA_MPJPE_mm']:10.2f}"
+ f" {rows['J14+adapter']['MPJPE_mm']:13.2f}"
if "J14+adapter" in rows
- else f" {'n/a':>10s}")
+ else f" {'n/a':>10s} {'n/a':>13s}")
print(line + (f" ({n_dropped} dropped)" if n_dropped else ""), flush=True)
if args.fit_adapter:
diff --git a/benchmark/eval_coco.py b/benchmark/eval_coco.py
index 1111763..5eac978 100644
--- a/benchmark/eval_coco.py
+++ b/benchmark/eval_coco.py
@@ -135,6 +135,11 @@ def main():
summary = {
"num_samples": len(kept),
"mean_OKS": float(np.nanmean(sample_oks)),
+ # 0.05 is the threshold most 2D-pose papers quote; 0.1/0.2 are kept so
+ # older reports in benchmark/results/ stay comparable. All three are
+ # normalised by the BBOX DIAGONAL -- a paper normalising by head
+ # segment (PCKh) or torso is not comparable at the same threshold.
+ "[email protected]_bboxdiag": M.pck2d(pred_kp, gt_xy, valid, diag, 0.05),
"[email protected]_bboxdiag": M.pck2d(pred_kp, gt_xy, valid, diag, 0.1),
"[email protected]_bboxdiag": M.pck2d(pred_kp, gt_xy, valid, diag, 0.2),
"NME_bboxdiag": M.nme2d(pred_kp, gt_xy, valid, diag),
@@ -142,11 +147,12 @@ def main():
per_kp = {}
for i, name in enumerate(J.COCO17_NAMES):
v = valid[:, i]
+ d_i = (np.linalg.norm(pred_kp[v, i] - gt_xy[v, i], axis=-1) / diag[v]
+ if v.any() else None)
per_kp[name] = {
"n": int(v.sum()),
- "[email protected]": float("nan") if not v.any() else
- float((np.linalg.norm(pred_kp[v, i] - gt_xy[v, i], axis=-1)
- / diag[v] < 0.1).mean()),
+ "[email protected]": float("nan") if d_i is None else float((d_i < 0.05).mean()),
+ "[email protected]": float("nan") if d_i is None else float((d_i < 0.1).mean()),
}
# --- OKS AP through the official evaluator ---------------------------
@@ -180,7 +186,8 @@ def main():
f"AP50 {summary['oks_ap']['AP50']*100:6.2f} "
f"AP75 {summary['oks_ap']['AP75']*100:6.2f}")
print(f" mean OKS {summary['mean_OKS']:6.4f}")
- print(f" [email protected] {summary['[email protected]_bboxdiag']*100:6.2f} % "
+ print(f" [email protected] {summary['[email protected]_bboxdiag']*100:6.2f} % "
+ f"[email protected] {summary['[email protected]_bboxdiag']*100:6.2f} % "
f"[email protected] {summary['[email protected]_bboxdiag']*100:6.2f} %")
print(f" NME {summary['NME_bboxdiag']:6.4f} (bbox-diagonal units)")
print("=" * 68)
diff --git a/benchmark/results/3dpw_test_gen5.json b/benchmark/results/3dpw_test_gen5.json
new file mode 100644
index 0000000..089baf0
--- /dev/null
+++ b/benchmark/results/3dpw_test_gen5.json
@@ -0,0 +1,290 @@
+{
+ "instanthmr_distill_train/runs/bno_s0/bno_s0/best_student_model_v3.pth|h36m": {
+ "ckpt": "instanthmr_distill_train/runs/bno_s0/bno_s0/best_student_model_v3.pth",
+ "gt": "h36m",
+ "split": "test",
+ "stride": 1,
+ "epoch": 85,
+ "source": "ema",
+ "n": 35463,
+ "n_dropped": 0,
+ "results": [
+ {
+ "joint_set": "J14",
+ "num_joints": 14,
+ "num_samples": 35463,
+ "MPJPE_mm": 105.59075208981304,
+ "PA_MPJPE_mm": 68.65276639038719,
+ "PCK3D_50mm": 0.38712380307846006,
+ "PCK3D_100mm": 0.8200015307705012,
+ "AUC_0_150mm": 0.5514413607692109,
+ "per_joint_PA_MPJPE_mm": {
+ "right_ankle": 68.6002112208962,
+ "right_knee": 47.796202194113405,
+ "right_hip": 98.89813178363754,
+ "left_hip": 86.54804326749168,
+ "left_knee": 47.93220834357654,
+ "left_ankle": 70.43573883389739,
+ "right_wrist": 70.9671299706096,
+ "right_elbow": 59.931862055983714,
+ "right_shoulder": 48.88554359499399,
+ "left_shoulder": 50.86661346152063,
+ "left_elbow": 70.13890219496395,
+ "left_wrist": 74.72033982944755,
+ "neck": 34.32004777862704,
+ "head": 131.09775493566124
+ }
+ },
+ {
+ "joint_set": "J12",
+ "num_joints": 12,
+ "num_samples": 35463,
+ "MPJPE_mm": 103.55279371039903,
+ "PA_MPJPE_mm": 63.212442975844404,
+ "PCK3D_50mm": 0.42238389307165214,
+ "PCK3D_100mm": 0.8809745368412147,
+ "AUC_0_150mm": 0.5840778621607435,
+ "per_joint_PA_MPJPE_mm": {
+ "right_ankle": 64.31700202915948,
+ "right_knee": 49.58846684843106,
+ "right_hip": 97.74150472679717,
+ "left_hip": 85.53733176084349,
+ "left_knee": 48.44964497448344,
+ "left_ankle": 64.69117986025115,
+ "right_wrist": 67.87638478520945,
+ "right_elbow": 50.475248931588496,
+ "right_shoulder": 51.10462090980213,
+ "left_shoulder": 51.255945550101416,
+ "left_elbow": 56.66098902303212,
+ "left_wrist": 70.8509963104334
+ }
+ },
+ {
+ "joint_set": "J14+adapter",
+ "num_joints": 14,
+ "num_samples": 35463,
+ "MPJPE_mm": 70.63804778208632,
+ "PA_MPJPE_mm": 43.80571997315016,
+ "PCK3D_50mm": 0.6998984857457068,
+ "PCK3D_100mm": 0.9421328467094476,
+ "AUC_0_150mm": 0.7086226431104736
+ }
+ ]
+ },
+ "instanthmr_distill_train/runs/bno_s1/bno_s1/best_student_model_v3.pth|h36m": {
+ "ckpt": "instanthmr_distill_train/runs/bno_s1/bno_s1/best_student_model_v3.pth",
+ "gt": "h36m",
+ "split": "test",
+ "stride": 1,
+ "epoch": 83,
+ "source": "ema",
+ "n": 35463,
+ "n_dropped": 0,
+ "results": [
+ {
+ "joint_set": "J14",
+ "num_joints": 14,
+ "num_samples": 35463,
+ "MPJPE_mm": 106.30543762749703,
+ "PA_MPJPE_mm": 69.44755093221157,
+ "PCK3D_50mm": 0.38019908073203057,
+ "PCK3D_100mm": 0.8145914655516212,
+ "AUC_0_150mm": 0.5472726100845551,
+ "per_joint_PA_MPJPE_mm": {
+ "right_ankle": 67.74238502662348,
+ "right_knee": 50.229744214062734,
+ "right_hip": 99.11057157887134,
+ "left_hip": 87.11689008905907,
+ "left_knee": 48.94307517094425,
+ "left_ankle": 71.62276277304298,
+ "right_wrist": 72.18656746368522,
+ "right_elbow": 60.28634507967081,
+ "right_shoulder": 49.20902541330741,
+ "left_shoulder": 51.6274906772661,
+ "left_elbow": 69.61796047904427,
+ "left_wrist": 78.3774062085848,
+ "neck": 35.00746248300054,
+ "head": 131.1880263937989
+ }
+ },
+ {
+ "joint_set": "J12",
+ "num_joints": 12,
+ "num_samples": 35463,
+ "MPJPE_mm": 104.2722236813728,
+ "PA_MPJPE_mm": 64.21451119174024,
+ "PCK3D_50mm": 0.4131536155053624,
+ "PCK3D_100mm": 0.8724656684431661,
+ "AUC_0_150mm": 0.5785831150989112,
+ "per_joint_PA_MPJPE_mm": {
+ "right_ankle": 64.47348616999159,
+ "right_knee": 51.722590577312005,
+ "right_hip": 98.26981164392382,
+ "left_hip": 86.4184403211381,
+ "left_knee": 49.3418828076764,
+ "left_ankle": 66.84643443124799,
+ "right_wrist": 68.57455496187201,
+ "right_elbow": 51.34128655762564,
+ "right_shoulder": 50.95717427196927,
+ "left_shoulder": 51.53147956682218,
+ "left_elbow": 56.7424678225824,
+ "left_wrist": 74.35452516872154
+ }
+ },
+ {
+ "joint_set": "J14+adapter",
+ "num_joints": 14,
+ "num_samples": 35463,
+ "MPJPE_mm": 72.11047276121764,
+ "PA_MPJPE_mm": 45.08471664866667,
+ "PCK3D_50mm": 0.6821717605069267,
+ "PCK3D_100mm": 0.9376895839124078,
+ "AUC_0_150mm": 0.7012210168812281
+ }
+ ]
+ },
+ "instanthmr_distill_train/runs/dt_s0/dt_s0/best_student_model_v3.pth|h36m": {
+ "ckpt": "instanthmr_distill_train/runs/dt_s0/dt_s0/best_student_model_v3.pth",
+ "gt": "h36m",
+ "split": "test",
+ "stride": 1,
+ "epoch": 85,
+ "source": "ema",
+ "n": 35463,
+ "n_dropped": 0,
+ "results": [
+ {
+ "joint_set": "J14",
+ "num_joints": 14,
+ "num_samples": 35463,
+ "MPJPE_mm": 113.34418144842128,
+ "PA_MPJPE_mm": 69.84164513504265,
+ "PCK3D_50mm": 0.38238244286801937,
+ "PCK3D_100mm": 0.8120697225679884,
+ "AUC_0_150mm": 0.545767439056037,
+ "per_joint_PA_MPJPE_mm": {
+ "right_ankle": 69.41474637936595,
+ "right_knee": 47.67699784860789,
+ "right_hip": 97.78243974951047,
+ "left_hip": 86.92655040131828,
+ "left_knee": 47.27021771033743,
+ "left_ankle": 71.70788367819415,
+ "right_wrist": 76.16593910378955,
+ "right_elbow": 62.16631485447152,
+ "right_shoulder": 48.92740512341149,
+ "left_shoulder": 51.04701763616356,
+ "left_elbow": 71.05377174626769,
+ "left_wrist": 78.67982288070175,
+ "neck": 34.30443174226576,
+ "head": 134.65949303619172
+ }
+ },
+ {
+ "joint_set": "J12",
+ "num_joints": 12,
+ "num_samples": 35463,
+ "MPJPE_mm": 111.1924824935285,
+ "PA_MPJPE_mm": 64.17582989732823,
+ "PCK3D_50mm": 0.4218763218001861,
+ "PCK3D_100mm": 0.8720520918516012,
+ "AUC_0_150mm": 0.5794967585479823,
+ "per_joint_PA_MPJPE_mm": {
+ "right_ankle": 65.0988301138224,
+ "right_knee": 49.43896704040137,
+ "right_hip": 97.50509750422344,
+ "left_hip": 86.45899166106351,
+ "left_knee": 47.99247268585938,
+ "left_ankle": 65.93102969455582,
+ "right_wrist": 73.0855595216394,
+ "right_elbow": 52.04128443883315,
+ "right_shoulder": 50.16486648188655,
+ "left_shoulder": 50.43834591421628,
+ "left_elbow": 57.25801910095047,
+ "left_wrist": 74.69649461048695
+ }
+ },
+ {
+ "joint_set": "J14+adapter",
+ "num_joints": 14,
+ "num_samples": 35463,
+ "MPJPE_mm": 82.33977956088862,
+ "PA_MPJPE_mm": 45.745626042711464,
+ "PCK3D_50mm": 0.6781514737694417,
+ "PCK3D_100mm": 0.9323359155014683,
+ "AUC_0_150mm": 0.6976277345467224
+ }
+ ]
+ },
+ "instanthmr_distill_train/runs/dt_s1/dt_s1/best_student_model_v3.pth|h36m": {
+ "ckpt": "instanthmr_distill_train/runs/dt_s1/dt_s1/best_student_model_v3.pth",
+ "gt": "h36m",
+ "split": "test",
+ "stride": 1,
+ "epoch": 87,
+ "source": "ema",
+ "n": 35463,
+ "n_dropped": 0,
+ "results": [
+ {
+ "joint_set": "J14",
+ "num_joints": 14,
+ "num_samples": 35463,
+ "MPJPE_mm": 108.93126868900502,
+ "PA_MPJPE_mm": 69.53100413938488,
+ "PCK3D_50mm": 0.37985465736925006,
+ "PCK3D_100mm": 0.8164586027287999,
+ "AUC_0_150mm": 0.5471804779720436,
+ "per_joint_PA_MPJPE_mm": {
+ "right_ankle": 69.55625612825625,
+ "right_knee": 47.71172195018994,
+ "right_hip": 96.54945478544958,
+ "left_hip": 86.4034397102533,
+ "left_knee": 47.583384395413084,
+ "left_ankle": 72.05032976730145,
+ "right_wrist": 75.2052788934457,
+ "right_elbow": 62.21923341843739,
+ "right_shoulder": 49.43185737953577,
+ "left_shoulder": 51.118420086942656,
+ "left_elbow": 71.58790258368994,
+ "left_wrist": 76.93281864570858,
+ "neck": 34.66586332776017,
+ "head": 132.41809687900442
+ }
+ },
+ {
+ "joint_set": "J12",
+ "num_joints": 12,
+ "num_samples": 35463,
+ "MPJPE_mm": 106.99366688568519,
+ "PA_MPJPE_mm": 64.08310421047089,
+ "PCK3D_50mm": 0.4158794612224948,
+ "PCK3D_100mm": 0.8770032616153925,
+ "AUC_0_150mm": 0.5797055935021175,
+ "per_joint_PA_MPJPE_mm": {
+ "right_ankle": 65.29752536225554,
+ "right_knee": 49.64317526219177,
+ "right_hip": 95.86754622285763,
+ "left_hip": 86.00415756921923,
+ "left_knee": 48.316752199732825,
+ "left_ankle": 65.89142714634777,
+ "right_wrist": 72.50887822047521,
+ "right_elbow": 52.09341400163957,
+ "right_shoulder": 51.17750531428965,
+ "left_shoulder": 51.22386739723045,
+ "left_elbow": 57.616979263684016,
+ "left_wrist": 73.35602256572712
+ }
+ },
+ {
+ "joint_set": "J14+adapter",
+ "num_joints": 14,
+ "num_samples": 35463,
+ "MPJPE_mm": 76.87984598188521,
+ "PA_MPJPE_mm": 45.3190899609874,
+ "PCK3D_50mm": 0.6844477745416753,
+ "PCK3D_100mm": 0.9339452386994896,
+ "AUC_0_150mm": 0.7000717694862341
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/benchmark/results/coco_gen5_bno_s0.json b/benchmark/results/coco_gen5_bno_s0.json
new file mode 100644
index 0000000..1a659f9
--- /dev/null
+++ b/benchmark/results/coco_gen5_bno_s0.json
@@ -0,0 +1,112 @@
+{
+ "model": "models/gen5/bno_s0.onnx",
+ "dataset": "COCO val2017",
+ "protocol": "top-down, ground-truth boxes, score=1.0",
+ "summary": {
+ "num_samples": 6352,
+ "mean_OKS": 0.6670050119307734,
+ "[email protected]_bboxdiag": 0.7338855090522612,
+ "[email protected]_bboxdiag": 0.8519240636223705,
+ "[email protected]_bboxdiag": 0.9132448874880892,
+ "NME_bboxdiag": 0.06468322584629825,
+ "oks_ap": {
+ "AP": 0.39577907358699205,
+ "AP50": 0.6323345348337878,
+ "AP75": 0.43885406127788734,
+ "AP_medium": 0.370084407129405,
+ "AP_large": 0.4431423548172553,
+ "AR": 0.5558721662468514,
+ "AR50": 0.7618073047858942,
+ "AR75": 0.621536523929471,
+ "AR_medium": 0.5005462988254575,
+ "AR_large": 0.6334448160535117
+ }
+ },
+ "per_keypoint": {
+ "nose": {
+ "n": 4268,
+ "[email protected]": 0.813730084348641,
+ "[email protected]": 0.8638706654170571
+ },
+ "left_eye": {
+ "n": 3703,
+ "[email protected]": 0.8036726978125844,
+ "[email protected]": 0.8552524979746152
+ },
+ "right_eye": {
+ "n": 3685,
+ "[email protected]": 0.8108548168249661,
+ "[email protected]": 0.8583446404341927
+ },
+ "left_ear": {
+ "n": 3185,
+ "[email protected]": 0.8047095761381475,
+ "[email protected]": 0.8631083202511773
+ },
+ "right_ear": {
+ "n": 3256,
+ "[email protected]": 0.8101965601965602,
+ "[email protected]": 0.8645577395577395
+ },
+ "left_shoulder": {
+ "n": 5501,
+ "[email protected]": 0.742592255953463,
+ "[email protected]": 0.8427558625704418
+ },
+ "right_shoulder": {
+ "n": 5495,
+ "[email protected]": 0.7481346678798908,
+ "[email protected]": 0.8504094631483167
+ },
+ "left_elbow": {
+ "n": 4336,
+ "[email protected]": 0.7656826568265682,
+ "[email protected]": 0.8646217712177122
+ },
+ "right_elbow": {
+ "n": 4378,
+ "[email protected]": 0.7578803106441298,
+ "[email protected]": 0.8524440383736867
+ },
+ "left_wrist": {
+ "n": 3945,
+ "[email protected]": 0.7683143219264892,
+ "[email protected]": 0.8585551330798479
+ },
+ "right_wrist": {
+ "n": 4012,
+ "[email protected]": 0.7774177467597209,
+ "[email protected]": 0.861914257228315
+ },
+ "left_hip": {
+ "n": 4755,
+ "[email protected]": 0.5186119873817034,
+ "[email protected]": 0.8088328075709779
+ },
+ "right_hip": {
+ "n": 4784,
+ "[email protected]": 0.5104515050167224,
+ "[email protected]": 0.8068561872909699
+ },
+ "left_knee": {
+ "n": 3513,
+ "[email protected]": 0.7492171932820951,
+ "[email protected]": 0.8682038144036436
+ },
+ "right_knee": {
+ "n": 3500,
+ "[email protected]": 0.7365714285714285,
+ "[email protected]": 0.8682857142857143
+ },
+ "left_ankle": {
+ "n": 2957,
+ "[email protected]": 0.7314846127832263,
+ "[email protected]": 0.8674332093337842
+ },
+ "right_ankle": {
+ "n": 2942,
+ "[email protected]": 0.7338545207341944,
+ "[email protected]": 0.8626784500339905
+ }
+ }
+}
\ No newline at end of file
diff --git a/benchmark/results/coco_gen5_bno_s1.json b/benchmark/results/coco_gen5_bno_s1.json
new file mode 100644
index 0000000..e58547e
--- /dev/null
+++ b/benchmark/results/coco_gen5_bno_s1.json
@@ -0,0 +1,112 @@
+{
+ "model": "models/gen5/bno_s1.onnx",
+ "dataset": "COCO val2017",
+ "protocol": "top-down, ground-truth boxes, score=1.0",
+ "summary": {
+ "num_samples": 6352,
+ "mean_OKS": 0.6682343657306236,
+ "[email protected]_bboxdiag": 0.7370666275745804,
+ "[email protected]_bboxdiag": 0.8534046763908232,
+ "[email protected]_bboxdiag": 0.9128783991790662,
+ "NME_bboxdiag": 0.06547462989899253,
+ "oks_ap": {
+ "AP": 0.39293350706049857,
+ "AP50": 0.6344218780922184,
+ "AP75": 0.425842275446914,
+ "AP_medium": 0.3713137366196817,
+ "AP_large": 0.4360823819559765,
+ "AR": 0.552912468513854,
+ "AR50": 0.7662153652392947,
+ "AR75": 0.6199622166246851,
+ "AR_medium": 0.49964490576345266,
+ "AR_large": 0.6277220364176885
+ }
+ },
+ "per_keypoint": {
+ "nose": {
+ "n": 4268,
+ "[email protected]": 0.8310684161199625,
+ "[email protected]": 0.873008434864105
+ },
+ "left_eye": {
+ "n": 3703,
+ "[email protected]": 0.820955981636511,
+ "[email protected]": 0.8606535241695922
+ },
+ "right_eye": {
+ "n": 3685,
+ "[email protected]": 0.8260515603799186,
+ "[email protected]": 0.8635006784260516
+ },
+ "left_ear": {
+ "n": 3185,
+ "[email protected]": 0.8150706436420723,
+ "[email protected]": 0.8690737833594977
+ },
+ "right_ear": {
+ "n": 3256,
+ "[email protected]": 0.8215601965601965,
+ "[email protected]": 0.870085995085995
+ },
+ "left_shoulder": {
+ "n": 5501,
+ "[email protected]": 0.7453190329031085,
+ "[email protected]": 0.8480276313397564
+ },
+ "right_shoulder": {
+ "n": 5495,
+ "[email protected]": 0.7534121929026387,
+ "[email protected]": 0.8549590536851683
+ },
+ "left_elbow": {
+ "n": 4336,
+ "[email protected]": 0.7615313653136532,
+ "[email protected]": 0.8609317343173432
+ },
+ "right_elbow": {
+ "n": 4378,
+ "[email protected]": 0.7615349474645957,
+ "[email protected]": 0.8547281863864779
+ },
+ "left_wrist": {
+ "n": 3945,
+ "[email protected]": 0.7723700887198987,
+ "[email protected]": 0.8577946768060837
+ },
+ "right_wrist": {
+ "n": 4012,
+ "[email protected]": 0.7851445663010967,
+ "[email protected]": 0.8576769690927218
+ },
+ "left_hip": {
+ "n": 4755,
+ "[email protected]": 0.5091482649842272,
+ "[email protected]": 0.8069400630914827
+ },
+ "right_hip": {
+ "n": 4784,
+ "[email protected]": 0.509824414715719,
+ "[email protected]": 0.8043478260869565
+ },
+ "left_knee": {
+ "n": 3513,
+ "[email protected]": 0.7338457159123256,
+ "[email protected]": 0.8642186165670367
+ },
+ "right_knee": {
+ "n": 3500,
+ "[email protected]": 0.7397142857142858,
+ "[email protected]": 0.8631428571428571
+ },
+ "left_ankle": {
+ "n": 2957,
+ "[email protected]": 0.7267500845451471,
+ "[email protected]": 0.8660804869800474
+ },
+ "right_ankle": {
+ "n": 2942,
+ "[email protected]": 0.7233174711080897,
+ "[email protected]": 0.8677770224337186
+ }
+ }
+}
\ No newline at end of file
diff --git a/benchmark/results/coco_gen5_dt_s0.json b/benchmark/results/coco_gen5_dt_s0.json
new file mode 100644
index 0000000..558e3ff
--- /dev/null
+++ b/benchmark/results/coco_gen5_dt_s0.json
@@ -0,0 +1,112 @@
+{
+ "model": "models/gen5/dt_s0.onnx",
+ "dataset": "COCO val2017",
+ "protocol": "top-down, ground-truth boxes, score=1.0",
+ "summary": {
+ "num_samples": 6352,
+ "mean_OKS": 0.08904053315167523,
+ "[email protected]_bboxdiag": 0.031092868137506415,
+ "[email protected]_bboxdiag": 0.11507732903320383,
+ "[email protected]_bboxdiag": 0.35413032324268856,
+ "NME_bboxdiag": 0.26528959799858415,
+ "oks_ap": {
+ "AP": 5.461410363272982e-06,
+ "AP50": 9.687857239735715e-06,
+ "AP75": 3.890369390573635e-06,
+ "AP_medium": 0.000760422094841063,
+ "AP_large": 0.0029702970297029695,
+ "AR": 0.0002676322418136021,
+ "AR50": 0.0006297229219143577,
+ "AR75": 0.00015743073047858942,
+ "AR_medium": 0.00038240917782026763,
+ "AR_large": 0.00011148272017837236
+ }
+ },
+ "per_keypoint": {
+ "nose": {
+ "n": 4268,
+ "[email protected]": 0.012652296157450796,
+ "[email protected]": 0.039831302717900655
+ },
+ "left_eye": {
+ "n": 3703,
+ "[email protected]": 0.00594112881447475,
+ "[email protected]": 0.027275182284634082
+ },
+ "right_eye": {
+ "n": 3685,
+ "[email protected]": 0.007598371777476255,
+ "[email protected]": 0.03717774762550882
+ },
+ "left_ear": {
+ "n": 3185,
+ "[email protected]": 0.009733124018838305,
+ "[email protected]": 0.024803767660910518
+ },
+ "right_ear": {
+ "n": 3256,
+ "[email protected]": 0.004914004914004914,
+ "[email protected]": 0.032862407862407864
+ },
+ "left_shoulder": {
+ "n": 5501,
+ "[email protected]": 0.010179967278676604,
+ "[email protected]": 0.047991274313761136
+ },
+ "right_shoulder": {
+ "n": 5495,
+ "[email protected]": 0.012556869881710645,
+ "[email protected]": 0.057870791628753415
+ },
+ "left_elbow": {
+ "n": 4336,
+ "[email protected]": 0.03505535055350553,
+ "[email protected]": 0.14391143911439114
+ },
+ "right_elbow": {
+ "n": 4378,
+ "[email protected]": 0.028780264961169484,
+ "[email protected]": 0.13453631795340337
+ },
+ "left_wrist": {
+ "n": 3945,
+ "[email protected]": 0.07604562737642585,
+ "[email protected]": 0.2948035487959442
+ },
+ "right_wrist": {
+ "n": 4012,
+ "[email protected]": 0.0992023928215354,
+ "[email protected]": 0.31331006979062814
+ },
+ "left_hip": {
+ "n": 4755,
+ "[email protected]": 0.09127234490010515,
+ "[email protected]": 0.29989484752891693
+ },
+ "right_hip": {
+ "n": 4784,
+ "[email protected]": 0.07901337792642141,
+ "[email protected]": 0.27738294314381273
+ },
+ "left_knee": {
+ "n": 3513,
+ "[email protected]": 0.006831767719897523,
+ "[email protected]": 0.0389980074010817
+ },
+ "right_knee": {
+ "n": 3500,
+ "[email protected]": 0.008,
+ "[email protected]": 0.037142857142857144
+ },
+ "left_ankle": {
+ "n": 2957,
+ "[email protected]": 0.0010145417653026716,
+ "[email protected]": 0.004058167061210686
+ },
+ "right_ankle": {
+ "n": 2942,
+ "[email protected]": 0.0006798096532970768,
+ "[email protected]": 0.0030591434398368456
+ }
+ }
+}
\ No newline at end of file
diff --git a/benchmark/results/coco_gen5_dt_s1.json b/benchmark/results/coco_gen5_dt_s1.json
new file mode 100644
index 0000000..f48e3c7
--- /dev/null
+++ b/benchmark/results/coco_gen5_dt_s1.json
@@ -0,0 +1,112 @@
+{
+ "model": "models/gen5/dt_s1.onnx",
+ "dataset": "COCO val2017",
+ "protocol": "top-down, ground-truth boxes, score=1.0",
+ "summary": {
+ "num_samples": 6352,
+ "mean_OKS": 0.09038467977205145,
+ "[email protected]_bboxdiag": 0.031400718317085685,
+ "[email protected]_bboxdiag": 0.117364216081507,
+ "[email protected]_bboxdiag": 0.35738473942681226,
+ "NME_bboxdiag": 0.2647629929200928,
+ "oks_ap": {
+ "AP": 9.943598533839752e-06,
+ "AP50": 1.776493438817566e-05,
+ "AP75": 1.3218945392536584e-05,
+ "AP_medium": 0.006930693069306931,
+ "AP_large": 0.00792079207920792,
+ "AR": 0.0004722921914357682,
+ "AR50": 0.0012594458438287153,
+ "AR75": 0.00047229219143576825,
+ "AR_medium": 0.00040972411909314386,
+ "AR_large": 0.0005574136008918618
+ }
+ },
+ "per_keypoint": {
+ "nose": {
+ "n": 4268,
+ "[email protected]": 0.01007497656982193,
+ "[email protected]": 0.041002811621368325
+ },
+ "left_eye": {
+ "n": 3703,
+ "[email protected]": 0.003780718336483932,
+ "[email protected]": 0.018633540372670808
+ },
+ "right_eye": {
+ "n": 3685,
+ "[email protected]": 0.0067842605156037995,
+ "[email protected]": 0.032021709633649934
+ },
+ "left_ear": {
+ "n": 3185,
+ "[email protected]": 0.005965463108320251,
+ "[email protected]": 0.029827315541601257
+ },
+ "right_ear": {
+ "n": 3256,
+ "[email protected]": 0.009520884520884522,
+ "[email protected]": 0.03163390663390663
+ },
+ "left_shoulder": {
+ "n": 5501,
+ "[email protected]": 0.011997818578440284,
+ "[email protected]": 0.05199054717324123
+ },
+ "right_shoulder": {
+ "n": 5495,
+ "[email protected]": 0.01019108280254777,
+ "[email protected]": 0.050773430391264786
+ },
+ "left_elbow": {
+ "n": 4336,
+ "[email protected]": 0.027675276752767528,
+ "[email protected]": 0.1113929889298893
+ },
+ "right_elbow": {
+ "n": 4378,
+ "[email protected]": 0.03060758337140247,
+ "[email protected]": 0.13613522156235724
+ },
+ "left_wrist": {
+ "n": 3945,
+ "[email protected]": 0.0788339670468948,
+ "[email protected]": 0.30164765525982257
+ },
+ "right_wrist": {
+ "n": 4012,
+ "[email protected]": 0.09621136590229312,
+ "[email protected]": 0.3200398803589232
+ },
+ "left_hip": {
+ "n": 4755,
+ "[email protected]": 0.09695057833859096,
+ "[email protected]": 0.32723449001051524
+ },
+ "right_hip": {
+ "n": 4784,
+ "[email protected]": 0.08486622073578595,
+ "[email protected]": 0.29891304347826086
+ },
+ "left_knee": {
+ "n": 3513,
+ "[email protected]": 0.010816965556504412,
+ "[email protected]": 0.051522914887560486
+ },
+ "right_knee": {
+ "n": 3500,
+ "[email protected]": 0.0074285714285714285,
+ "[email protected]": 0.039142857142857146
+ },
+ "left_ankle": {
+ "n": 2957,
+ "[email protected]": 0.0010145417653026716,
+ "[email protected]": 0.0037199864727764627
+ },
+ "right_ankle": {
+ "n": 2942,
+ "[email protected]": 0.0010197144799456153,
+ "[email protected]": 0.004418762746430999
+ }
+ }
+}
\ No newline at end of file
diff --git a/docs/todo.md b/docs/todo.md
index 80cba39..32a3832 100644
--- a/docs/todo.md
+++ b/docs/todo.md
@@ -136,11 +136,16 @@ score dropped frames at a fixed penalty so the population is constant.
The graph emits 2D keypoints two ways, and only one is measured today:
1. `joints_2d` — the SimCC head. This is what `benchmark/eval_coco.py` scores
- (`p.joints_2d[COCO17_FROM_MHR70]`) and what `--detach-2d-head` degrades.
+ (`p.joints_2d[COCO17_FROM_MHR70]`).
2. `mhr_params` + `cam_trans` -> forward kinematics -> project with the focal.
- Governed by `loss_reproj`, which the `dt` runs leave **unchanged** to within
- seed noise, so the trunk has not lost image-plane localisation — only the
- SimCC readout of it has.
+ Governed by `loss_reproj`.
+
+The detach experiment is what makes this worth measuring: it showed the two
+routes are genuinely independent. `loss_reproj` was unchanged between the arms
+to within seed noise while the SimCC head collapsed to a point, so the trunk
+kept its image-plane localisation and only the readout lost it. Route 2 may
+therefore be usable when route 1 is not — see
+`instanthmr_distill_train/README.md` §"Tried and rejected".
The logged columns cannot settle which is better: `loss_reproj` is an L1 with
fingers down-weighted to 0.2 and `w_reproj = 0.5` folded in, while
@@ -159,8 +164,7 @@ make.** The head is 0.025 of ~10.8 GFLOPs — 0.23%, nothing. The cost is in the
different architecture that no run has tested, and the standing hypothesis is
that they *help* the global token via self-attention. Sequence: finish the
runs, score both routes, then a separate ablation with the 70 queries removed.
-Dropping `loss_2d_simcc` / `loss_2d_native` under `--detach-2d-head` is the one
-free part — they already contribute exactly zero trunk gradient there.
+(`--detach-2d-head` is gone; it was tried and rejected, see the trainer README.)
### 6. `n_repair` overstates successful updates
diff --git a/instanthmr_distill_train/README.md b/instanthmr_distill_train/README.md
index e24c2a7..5a349df 100644
--- a/instanthmr_distill_train/README.md
+++ b/instanthmr_distill_train/README.md
@@ -291,113 +291,79 @@ Confirmed directly: pushing `scale_spine_length` to 20.3 along a null direction
moves the skeleton by 1.2e-7 m. The bound now keeps that wandering finite;
collapsing the redundancy properly would be a separate change.
-## `--detach-2d-head` (added 2026-09-06, experimental)
-
-Stops the 2D SimCC head from training the **shared trunk** — the backbone plus
-the decoder, i.e. everything that builds the representation. The head keeps its
-full loss, keeps its weights trainable, and stays a deployed ONNX output; the
-only thing that changes is that its gradient no longer flows back into the
-decoder. One line in `InstantHMRStudent.forward`: `feat_2d = feat_2d.detach()`.
-
-### Why
-
-The trunk is being trained mostly for an output the benchmark does not measure.
-Back-propagating each loss term separately through the converged `b3_s1`
-checkpoint, over real augmented batches, gives the share of the gradient that
-reaches backbone + decoder:
-
-| term | share of the trunk's gradient |
-|---|---|
-| `loss_2d_simcc` | **47.6%** |
-| `loss_2d_native` | 8.6% |
-| `loss_cam` | 22.3% |
-| all seven 3D body-pose terms together | **20.7%** |
-
-The dominant term is also the most exhausted and the noisiest. `loss_2d_simcc`
-sits at **2.227 nats against an irreducible floor of 2.112** — that floor is the
-entropy of its own Gaussian soft label at `sigma = 2 * bin_w`, which no model can
-go below.
-
-> **Correction (2026-09-06).** An earlier version of this section read "only
-> 5.2% of the term is reducible, i.e. a task already 95% converged". That does
-> not follow. `CE = H(target) + KL(target || prediction)`, and `H` is a
-> constant with **zero gradient**, so the ratio `2.112 / 2.227` says nothing
-> about how much of the *learnable* part is left: the learnable part is the
-> whole of `KL = 0.115` nats, and this number cannot say whether that is close
-> to optimal. Use it only as a scale for reading the `simcc` column — subtract
-> 2.112 to get the part the model is actually being graded on. The gradient
-> measurements below (47.6% share, SNR 0.28, cosine +0.21) are independent of
-> this and stand.
-
-Its trunk gradient has the
-worst signal-to-noise of any term (`|mean g| / mean |g|` = 0.28, against 0.39 for
-the pose group) and only a +0.21 per-batch cosine with the pose gradient. Most of
-what it sends into the backbone is batch noise from a task that is already 95%
-converged.
-
-The same imbalance is in the compute. At 224, batch 1: backbone 9.040 GFLOPs
-(83.8%), the 71-query decoder 1.694 GFLOPs (15.7%), the 2D head 0.025 GFLOPs, and
-the **parameter head 0.0003 GFLOPs — 0.003%**. Seventy of the 71 decoder queries
-serve the 2D output; all 204 MHR parameters are read from the one remaining
-token.
-
-This is a **trade-off, not a free win**: `joints_2d` is a real deployed output
-(`instanthmr/inference.py` consumes `outs[3]`), despite this file's module
-docstring calling the head training-only. Watch `2d` and `simcc` in the epoch log
-— if they regress materially, the flag has cost you the 2D product to buy 3D
-accuracy.
-
-### What it does not do
-
-It does not kill the 70 keypoint queries. They still receive gradient through the
-decoder's self-attention with the global token, so they stay alive and become
-free capacity for the token the parameters are read from — they simply stop being
-*forced* to encode 2D image-plane positions.
-
-### Verified
-
-Flag off is **bit-identical** to the pre-flag code: all five forward tensors
-match to `0.000e+00` over 32 augmented `--preset v2` samples. Flag on leaves
-every forward value unchanged (so the ONNX graph and the deployed output are
-untouched) and takes the 2D losses' gradient into the trunk from `1.9778` to
-exactly `0.000000`, while the 2D head's own gradient is unchanged at `0.8389`.
-Neither mode leaves any parameter without a gradient, so DDP does not need
-`find_unused_parameters`.
-
-### Evidence, and its limits
-
-In a 1500-step fine-tune from `b3_s1` on COCO+AIC, scored on held-out 3DPW crops
-against the teacher (body-30 PA-MPJPE, mm):
-
-| arm | start | 1500 | delta |
-|---|---|---|---|
-| control | 42.34 | 42.13 | −0.21 |
-| **`--detach-2d-head`** | 42.34 | **41.57** | **−0.77** |
-| 2D losses x0.1 | 42.34 | 41.91 | −0.43 |
-| control at LR/4 (step-size control) | 42.34 | 42.47 | +0.13 |
-
-The ordering is monotone in how much 2D gradient reaches the trunk, and the LR
-arm rules out "it just took smaller steps". But 0.5-0.9 mm on one seed from an
-already-converged checkpoint is well inside the 34-49 mm seed spread this repo
-sees, so treat it as a direction to test, not a result. The real test is a
-from-scratch pair of seeds against a matched control.
-
-### The underlying finding
-
-The teacher's own labels in `data/sam3d_gt_3dpw` are **14.5 mm** J14+adapter
-PA-MPJPE from real 3DPW MoCap (sequence-holdout adapter; 12.5 with the shipped
-one), and `b3_s1` disagrees with those labels by **28.5-31.1 mm on COCO / AIC /
-MPII, which it trained on** (39.8 mm on held-out 3DPW). That is underfitting, not
-label noise: there is no variance shrinkage (per-joint student/teacher variance
-ratio 0.94-1.06), the per-frame noise floor is only 10.9 mm (teacher 3.9, real
-motion 7.3 between adjacent 30 fps frames), and averaging over the mirror and
-rotation symmetries makes the error *worse* (46.3 vs 39.9 mm). A frozen-trunk
-probe study says it is not the readout either: a plain `Linear` on the global
-token scores 41.8 mm against 49.9 for an MLP reading all 71 tokens.
-
-Caveat on the ceiling: those teacher labels were fit with ground-truth access, so
-14.5 mm is not a reachable monocular target. Published monocular SOTA (~36-38 mm)
-is the practical floor.
+## Tried and rejected: detaching the 2D head (2026-09-06 / 09-07)
+
+**Do not retry this without reading the failure mode.** The flag is gone from
+the code; this section is the record of why.
+
+The idea was to stop the 2D SimCC head from training the **shared trunk** —
+backbone plus decoder — with one line in `InstantHMRStudent.forward`,
+`feat_2d = feat_2d.detach()`. The head kept its full loss and stayed a deployed
+output; only its gradient into the trunk was cut. The motivation was a real
+measurement: on the converged `b3_s1` checkpoint, of the gradient reaching
+backbone + decoder, `loss_2d_simcc` owned 47.6% and `loss_2d_native` 8.6%
+against 20.7% for all seven 3D body-pose terms together, and the 2D gradient had
+the worst signal-to-noise of any term (`|mean g| / mean |g|` 0.28 against the
+pose group's 0.39) at only +0.21 per-batch cosine with it.
+
+**It failed on both axes.** Two matched seeds each (`dt` = detached, `bno` =
+control), identical mixture, LR and flags, scored at epoch 83-87 of 300 on 3DPW
+test (35,463 person-frames, published-protocol GT, adapter applied) and COCO
+val2017 (6,352 persons, GT boxes):
+
+| arm | 3DPW PA-MPJPE | 3DPW MPJPE | COCO OKS AP | COCO [email protected] |
+|---|---|---|---|---|
+| `bno` (control) | **44.45 ± 0.90** | **71.37 ± 1.04** | **39.4** | **73.5%** |
+| `dt` (detached) | 45.53 ± 0.30 | 79.61 ± 3.86 | **0.00** | 3.1% |
+
+**The 2D head does not degrade — it collapses.** Measured over 48 COCO crops,
+the spread of the 70 predicted keypoints *within* one crop:
+
+| arm | within-crop spread (x, y) | across-crop centroid spread (x, y) |
+|---|---|---|
+| `bno_s0` / `bno_s1` | 0.226 / 0.311, 0.251 / 0.310 | 0.123 / 0.271, 0.129 / 0.287 |
+| `dt_s0` / `dt_s1` | **0.013 / 0.011**, **0.020 / 0.023** | 0.140 / 0.231, 0.155 / 0.232 |
+
+A 15-25x collapse within the crop, on both seeds, while the across-crop spread
+is unchanged — the head still tracks *where the person is*, but predicts all 70
+keypoints at the same point. Hence OKS AP of exactly 0.00: no prediction ever
+clears the lowest threshold.
+
+**Why, and this is the part worth remembering.** `head_2d_feat` and
+`head_2d_logits` are **shared across all 70 queries**, applied per token. For
+the output to differ per keypoint, query *k*'s feature must encode keypoint *k*
+— and the only thing that ever forced that was the 2D loss. Detach it and the
+70 query features are shaped solely by what helps the *global* token through
+self-attention, where per-keypoint identity is worth nothing. They converge on
+each other and the shared head has nothing left to distinguish. Nothing in the
+objective pushes it back, so more epochs do not recover it.
+
+An earlier note in this file claimed the queries "stay alive and become free
+capacity for the token the parameters are read from". Alive, yes. Still
+keypoint-specific, no.
+
+**Two secondary lessons.**
+
+*Early epochs lied.* At epoch 9 `dt` led by 5.6 mm J14 PA. By epoch 84 it
+trailed. `OneCycleLR(pct_start=0.1)` peaks at epoch 30 of 300, and an arm
+spending less on the fast-converging 2D task looks good before the LR anneals.
+Do not read a 300-epoch A/B before the peak.
+
+*The entropy argument behind it was wrong.* `loss_2d_simcc` sits at 2.227 nats
+against an irreducible floor of 2.112 — the entropy of its own Gaussian soft
+label at `sigma = 2 * bin_w`, computed directly. That was read as "only 5.2% of
+the term is reducible, so the task is 95% converged". It does not follow:
+`CE = H(target) + KL(target || prediction)` and `H` is a constant with **zero
+gradient**, so the ratio says nothing about how much of the *learnable* part is
+left. The learnable part is the whole of `KL = 0.115` nats. Use the floor only
+as a scale for reading the `simcc` column — subtract 2.112 to get what the model
+is actually graded on. The gradient measurements above are independent of this
+and still stand.
+
+**If you want the trunk's capacity back, the cost is not the head.** It is
+0.025 of ~10.8 GFLOPs, 0.23%. The 15.7% is the **70 decoder queries** that feed
+it, and removing those is a different architecture that no run has tested. See
+`docs/todo.md`.
## The reported number
diff --git a/instanthmr_distill_train/train_distill_jz.py b/instanthmr_distill_train/train_distill_jz.py
index 3d7e19a..82af302 100755
--- a/instanthmr_distill_train/train_distill_jz.py
+++ b/instanthmr_distill_train/train_distill_jz.py
@@ -648,12 +648,6 @@ def train(args, cfg, rank, local_rank, world):
"bound_scales": cfg.bound_scales,
"scale_bound_margin": cfg.scale_bound_margin,
"anomaly_safe_fallback": cfg.anomaly_safe_fallback,
- # getattr, not attribute access: the two files are rsynced
- # separately, so a job can start with this driver already updated
- # and train_distill_mhr_only.py still on the old revision. Reading
- # the field directly would raise and, because the self-chain only
- # resubmits on rc == 0, kill the run outright.
- "detach_2d_head": getattr(cfg, "detach_2d_head", False),
"started": time.strftime("%Y-%m-%d %H:%M")})
ema_rollbacks = 0
@@ -965,15 +959,6 @@ def parse_args():
action="store_true",
help="on an anomalous batch, step on the non-FK terms "
"instead of discarding the batch")
- p.add_argument("--detach-2d-head", dest="detach_2d_head", action="store_true",
- help="stop the 2D SimCC head from shaping the shared trunk "
- "(backbone + decoder). It keeps full supervision and "
- "stays a deployed output; only its gradient into the "
- "trunk is cut. On the converged b3_s1 checkpoint the 2D "
- "terms own 56.2%% of the trunk's gradient against 20.7%% "
- "for all seven 3D body-pose terms, while loss_2d_simcc "
- "is 95%% irreducible label entropy. Off by default so "
- "existing runs stay bit-identical.")
p.add_argument("--mhr_model_path", default=None)
p.add_argument("--kp_regressor_path", default=None)
@@ -1089,7 +1074,6 @@ def build_cfg(args):
if args.output_dir: cfg.log_dir = args.output_dir
if args.bound_scales: cfg.bound_scales = True
if args.anomaly_safe_fallback: cfg.anomaly_safe_fallback = True
- if args.detach_2d_head: cfg.detach_2d_head = True
if args.scale_bound_margin is not None:
cfg.scale_bound_margin = args.scale_bound_margin
if args.mhr_model_path: cfg.mhr_model_path = args.mhr_model_path
@@ -1210,9 +1194,6 @@ def main():
+ (f" (margin {cfg.scale_bound_margin})" if cfg.bound_scales else "")
+ f" | safe_fallback={cfg.anomaly_safe_fallback}"
+ f" | rollback@{cfg.anomaly_skip_patience} x{cfg.max_ema_rollbacks}")
- log(f"trunk detach_2d_head={getattr(cfg, 'detach_2d_head', False)}"
- + (" (2D head keeps its loss but no longer trains backbone/decoder)"
- if getattr(cfg, "detach_2d_head", False) else ""))
log(f"seed {args.seed} | mix {args.mix} | "
f"samples/epoch {args.samples_per_epoch:,}")
log("=" * 66)
diff --git a/instanthmr_distill_train/train_distill_mhr_only.py b/instanthmr_distill_train/train_distill_mhr_only.py
index fbcf150..f91ac95 100644
--- a/instanthmr_distill_train/train_distill_mhr_only.py
+++ b/instanthmr_distill_train/train_distill_mhr_only.py
@@ -294,28 +294,6 @@ class DistillConfig:
bound_scales: bool = False
scale_bound_margin: float = 0.5
scale_bounds_path: str = str(PROJECT_ROOT / "assets/mhr_size_bounds.npz")
- # Stop the 2D SimCC head from shaping the shared trunk (backbone + decoder).
- # It keeps its full supervision and stays a deployed output -- only the
- # gradient path back into the decoder is cut, so the trunk is trained by the
- # 3D pathway alone.
- #
- # Measured on the converged b3_s1 checkpoint over real augmented batches:
- # of the gradient reaching backbone+decoder, loss_2d_simcc owns 47.6% and
- # loss_2d_native 8.6%, loss_cam 22.3%, and all seven 3D body-pose terms
- # together 20.7%. The dominant term is also the most exhausted and the
- # noisiest: loss_2d_simcc sits at 2.227 nats against an irreducible floor of
- # 2.112 (the entropy of its own Gaussian soft label at sigma = 2 bins), so
- # only 5.2% of it is reducible, and its trunk gradient has the worst
- # signal-to-noise of any term (|mean g| / mean |g| = 0.28 against the pose
- # group's 0.39) at a +0.21 per-batch cosine with it.
- #
- # The 70 SimCC queries keep receiving gradient through the decoder's
- # self-attention with the global token, so they do not go dead -- they stop
- # being *forced* to encode 2D image-plane positions and become free capacity
- # for the token the parameters are read from.
- #
- # Default off: --preset baseline and --losses legacy must stay bit-identical.
- detach_2d_head: bool = False
use_amp: bool = True
ema_decay: float = 0.9998
early_stop_patience: int = 150
@@ -903,7 +881,6 @@ class InstantHMRStudent(nn.Module):
self.kp2d_bins = getattr(cfg, 'kp2d_bins', 96)
self.kp2d_range = getattr(cfg, 'kp2d_range', 1.5)
- self.detach_2d_head = bool(getattr(cfg, "detach_2d_head", False))
self.head_2d_feat = nn.Sequential(
nn.Linear(cfg.d_model, 256),
nn.GELU()
@@ -992,12 +969,6 @@ class InstantHMRStudent(nn.Module):
parts.append(pred_mhr_params[:, prev:])
pred_mhr_params = torch.cat(parts, dim=1)
- # Cut the 2D head's gradient into the shared trunk. Forward values are
- # untouched, so the deployed joints_2d output and the ONNX graph are
- # unchanged; only what the backbone and decoder are trained FOR changes.
- if self.detach_2d_head:
- feat_2d = feat_2d.detach()
-
feat_2d_processed = self.head_2d_feat(feat_2d)
logits_2d = self.head_2d_logits(feat_2d_processed)
logits_2d = logits_2d.unflatten(-1, (2, self.kp2d_bins))
@@ -2385,10 +2356,6 @@ def parse_args():
action="store_true",
help="On an anomalous batch, step on the non-FK terms "
"instead of discarding the batch.")
- p.add_argument("--detach-2d-head", dest="detach_2d_head", action="store_true",
- help="Stop the 2D SimCC head from shaping the backbone and "
- "decoder. It keeps full supervision and stays a deployed "
- "output; only its gradient into the shared trunk is cut.")
p.add_argument("--kp3d-warmup-steps", dest="kp3d_warmup_steps", type=int, default=None,
help="Optimiser steps over which the FK-path losses ramp from 0 to full weight.")
p.add_argument("--w_keypoints3d", type=float, default=None,
@@ -2444,7 +2411,6 @@ def main():
if args.no_resume: cfg.resume = False
if args.bound_scales: cfg.bound_scales = True
if args.anomaly_safe_fallback: cfg.anomaly_safe_fallback = True
- if args.detach_2d_head: cfg.detach_2d_head = True
if args.scale_bound_margin is not None: cfg.scale_bound_margin = args.scale_bound_margin
if args.kp3d_warmup_steps is not None: cfg.kp3d_warmup_steps = args.kp3d_warmup_steps
if args.losses == "rebalanced": apply_rebalanced_losses(cfg)