File size: 13,516 Bytes
8e5456b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
#!/usr/bin/env python3
"""Generate ABLATIONS_VNHN.md -- T2M-GPT and NSLP-G trained on processed_vnhn/Cut_video.

Numbers are read from the eval JSONs, never hand-typed (this project has twice been bitten
by a hand-made column). Re-run after adding runs to refresh the file.

Scope note: this is a MODEL COMPARISON with controls, not a hyper-parameter sweep. No
hyper-parameter ablation was run on vnhn, because the controls below show neither model
reads its conditioning text on this corpus -- tuning against a target that carries no
signal would produce a table of noise. The reasoning is recorded in the file itself.
"""
import glob
import json
import os

T2M = "logs_vnhn"
NSL = "../0.NSLP-G/sentence-level/logs_vnhn"
REPORT = "ABLATIONS_VNHN.md"


def jload(p):
    return json.load(open(p)) if os.path.exists(p) else None


def main():
    L = []
    A = L.append
    A("# T2M-GPT and NSLP-G on processed_vnhn / Cut_video")
    A("")
    A("Both models trained from scratch on the vnhn corpus (VTV *Việt Nam hôm nay* broadcast,")
    A("87 sources, 25 fps, 144x180 signer crop). Single-stage text->pose: there is **no gloss")
    A("annotation** in this corpus, so `--text-field sentence` conditions directly on the")
    A("transcript. Conditions named `oracle-*` mean *the clip's own ground-truth text*, paired")
    A("against a *different clip's* text as the control -- not a gloss-prediction stage.")
    A("")
    A("## The data, and the caveat that governs every number below")
    A("")
    A("`Cut_video` is **not sentence-segmented**, despite its README title. Measured:")
    A("")
    A("| | |")
    A("|---|---|")
    A("| transcript span | **~10 s for 83% of clips** (exactly 10.0 s for 55.6%) |")
    A("| words per clip | median **40** (TriVis sentences: ~8.9) |")
    A("| sentence punctuation | 940 periods across 16,401 train clips |")
    A("| consecutive segments abutting | **94.6%** have a 0.00 s gap |")
    A("| tail padding | **+3 s** past the transcript end, ~23% of a median clip |")
    A("")
    A("So each clip pairs ~10 s of continuous signing with a 40-word transcript fragment cut")
    A("mid-phrase at both ends. The windows come from the upstream transcripts, which are")
    A("duration-chunked ASR output rather than sentences. Nothing is broken -- the unit simply")
    A("is not what \"sentence-level\" implies, and that is the single most important fact for")
    A("interpreting the results.")
    A("")
    A("### Packing (`dataset/VNHN`, shared by both models)")
    A("")
    A("| split | clips kept | frames | dropped |")
    A("|---|---|---|---|")
    A("| train | 15,723 / 16,401 | 5,267,148 | 11 short, **667 long (4.07%)** |")
    A("| val | 2,016 / 2,080 | 672,461 | 1 short, 63 long |")
    A("| test | 2,003 / 2,095 | 668,263 | 1 short, 91 long |")
    A("")
    A("Layout `upper` (124 kpt: body14 + face68 + hands42). Three vnhn-specific decisions,")
    A("each of which would have silently corrupted the data if got wrong:")
    A("")
    A("1. **Keypoints are raw COCO-WholeBody 133**, not the project's 128. Full_TriVis came")
    A("   through `easy_dwpose`, which already converts COCO-17 -> OpenPose-18 (synthesising a")
    A("   `neck` from the shoulder midpoint). Done explicitly in `prepare_vnhn_data.py`;")
    A("   verified because hand root 91 sits 0.021 frame-widths from COCO Lwrist 9.")
    A("2. **`scores` are not [0,1] confidences** -- they run 0.4..11.3, median 8.2, i.e. ~10x a")
    A("   confidence. TriVis's `--score-thr 0.3` would mark *everything* valid. Calibrated to")
    A("   **3.0** by matching TriVis per-group validity: face 99.7 / hands 98.1 / body 76.3,")
    A("   and feet correctly killed at 1.0%. (4.0 collapses hands to 78%; 2.0 leaks feet at 22%.)")
    A("3. **Legs are off-frame** (bust shot): knees score ~1.2, ankles ~0.85, both <0.1% valid.")
    A("   Hence `upper`, not `full` -- `full` would hand the decoder four noise dimensions.")
    A("")
    A("Clips over 512 frames (=128 pose tokens) are **dropped, not truncated**: truncation")
    A("inside the loader would break the text<->pose correspondence on exactly the longest clips.")
    A("")

    # ---------------- T2M-GPT
    A("## T2M-GPT")
    A("")
    A("| stage | result |")
    A("|---|---|")
    fn = jload(f"{T2M}/eval_last_oracle.json")
    if fn:
        A(f"| stage 1 VQ-VAE (50k iters) | val hands **0.04021**, "
          f"{fn['stage1']['codes_used']}/512 codes used |")
        A(f"| stage 2 GPT (30k iters) | best gen hands 0.23134 @ iter 8,000; "
          f"val_acc **{fn['stage2']['val_acc']:.2f}%** |")
    A("")
    A("`val_acc 2.99%` is a third of TriVis's ~10% at the same point -- the first hint that")
    A("there is far less text->pose mutual information to exploit here.")
    A("")
    A("### Shoulder widths (comparable to the TriVis tables), gt_anchor, 300 test clips")
    A("")
    for ck in ("best", "last"):
        d = jload(f"{T2M}/sw_{ck}.json")
        if not d:
            continue
        r = d["results"]
        it = 8000 if ck == "best" else 30000
        A(f"**net_{ck} (iter {it})**")
        A("")
        A("| condition | all | body | face | hands | len_ratio |")
        A("|---|---|---|---|---|---|")
        for c in ("ceiling", "oracle-gloss", "shuffled-half", "shuffled-random"):
            if c not in r:
                continue
            g = r[c]["gt_anchor"]
            nm = "**ground-truth text**" if c == "oracle-gloss" else c
            A(f"| {nm} | {g['all']['mean']:.4f} | {g['body']['mean']:.4f} | "
              f"{g['face']['mean']:.4f} | **{g['hands']['mean']:.4f}** | "
              f"{r[c]['len_ratio']:.3f} |")
        o = r["oracle-gloss"]["gt_anchor"]["hands"]["mean"]
        ce = r["ceiling"]["gt_anchor"]["hands"]["mean"]
        A("")
        pen = ", ".join(
            f"{s} **{100*(r[s]['gt_anchor']['hands']['mean']-o)/o:+.1f}%**"
            for s in ("shuffled-half", "shuffled-random") if s in r)
        A(f"shuffle penalty: {pen} &nbsp;|&nbsp; model/ceiling **{o/ce:.2f}x**")
        A("")
    A("### Frame-normalized (same convention as `eval_vsl.py` on TriVis)")
    A("")
    A("| checkpoint / text | all | body | face | hands | len_ratio |")
    A("|---|---|---|---|---|---|")
    for ck in ("best", "last"):
        for c in ("oracle", "shuffled"):
            d = jload(f"{T2M}/eval_{ck}_{c}.json")
            if not d:
                continue
            g = d["gen_dtw"]
            A(f"| {ck} / {c} | {g['all']:.4f} | {g['body']:.4f} | {g['face']:.4f} | "
              f"**{g['hands']:.4f}** | {d['len_ratio_mean']:.3f} |")
    d = jload(f"{T2M}/eval_last_oracle.json")
    if d:
        A(f"| *ceiling* | {d['ceiling']['all']:.4f} | {d['ceiling']['body']:.4f} | "
          f"{d['ceiling']['face']:.4f} | *{d['ceiling']['hands']:.4f}* | -- |")
    A("")

    # ---------------- NSLP-G
    A("## NSLP-G")
    A("")
    A("Stage 1 SpatialVAE 80 epochs; stage 2 GaussianSeeker **early-stopped at epoch 34/120**")
    A("(`valid/pose_loss` did not improve for 30 records; best **0.959**). Not a crash --")
    A("EarlyStopping working as designed. Peak memory only 1.6 GB, so `batch_size: 16` was")
    A("an order of magnitude too conservative.")
    A("")
    n = jload(f"{NSL}/nslpg_vnhn_test.json")
    if n:
        r = n["results"]
        A("300 test clips, 50 joints (8 body + 42 hands), DTW-MJE:")
        A("")
        A("| condition | all | body | hands | len_ratio | shape_unexpl | spread_ratio |")
        A("|---|---|---|---|---|---|---|")
        for k in ("ceiling", "nslpg-oracle", "nslpg-pred", "shuffled-gloss",
                  "random-init", "global-mean"):
            if k not in r:
                continue
            v = r[k]
            dd = v["dtw"]
            h = v.get("handshape") or {}
            nm = "**ground-truth text**" if k == "nslpg-oracle" else k
            A(f"| {nm} | {dd['all']['mean']:.4f} | {dd['body']['mean']:.4f} | "
              f"**{dd['hands']['mean']:.4f}** | {v['len_ratio']:.3f} | "
              f"{h.get('shape_unexplained', float('nan')):.3f} | "
              f"{h.get('spread_ratio', float('nan')):.3f} |")
        o = r["nslpg-oracle"]["dtw"]["hands"]["mean"]
        s = r["shuffled-gloss"]["dtw"]["hands"]["mean"]
        gm = r["global-mean"]["dtw"]["hands"]["mean"]
        ce = r["ceiling"]["dtw"]["hands"]["mean"]
        A("")
        A(f"shuffle penalty **{100*(s-o)/o:+.1f}%** &nbsp;|&nbsp; vs global-mean floor "
          f"**{100*(gm-o)/gm:+.1f}%** &nbsp;|&nbsp; model/ceiling **{o/ce:.1f}x**")
        A("")

    # ---------------- verdict
    A("## Verdict: neither model learned a text->pose mapping")
    A("")
    A("| | T2M-GPT | NSLP-G |")
    A("|---|---|---|")
    A("| hands, ground-truth text (shoulder / 50-joint) | 0.4682 | 0.1867 |")
    A("| **shuffle penalty** | **+5.2%** (net_last) | **−0.0%** |")
    A("| **model / ceiling** | **4.45x** | **30.1x** |")
    A("| vs floor | modest | +2.1% over global-mean |")
    A("| len_ratio | 0.989 | 1.000 (given the reference length) |")
    A("")
    A("**NSLP-G is text-independent to five significant figures**: ground-truth 0.18672 vs")
    A("shuffled 0.18671, with identical `shape_unexplained` and `spread_ratio`. It beats the")
    A("global-mean floor by 2.1% -- the margin of a model that has learned the average pose of")
    A("a news signer. `spread_ratio` 0.677 against the ceiling's 0.995 means its output has a")
    A("third less positional variance than real signing.")
    A("")
    A("**T2M-GPT does read its text, barely** (+5.2%, vs +14.7% for the TriVis sentence model)")
    A("and is 4.45x above its own tokenizer ceiling.")
    A("")
    A("### The qualitative render makes this visible where DTW does not")
    A("")
    A("`0.NSLP-G/sentence-level/qual_vnhn_3way_fixed/` -- 6 clips, GT | NSLP-G | T2M-GPT, drawn")
    A("on identical clips in the same 50-joint space:")
    A("")
    A("* **GT** -- hands move substantially across keyframes (face, side, down, open shapes).")
    A("* **NSLP-G** -- essentially the *same pose in every keyframe* across 328-350 frames.")
    A("  The mean-pose collapse, directly visible.")
    A("* **T2M-GPT** -- genuinely varied motion, blobbier handshapes than GT, ~13% short on")
    A("  length (T=284 vs 328).")
    A("")
    A("DTW separates these two by only ~5% on hands, yet the difference is obvious on sight.")
    A("Another instance of this project's documented finding that DTW ranks generators poorly.")
    A("")
    A("## Why no hyper-parameter ablation was run on vnhn")
    A("")
    A("A sweep needs a signal to optimise. With NSLP-G at **−0.0%** text sensitivity and")
    A("T2M-GPT at **+5.2%**, tuning either against this target would be tuning noise -- and the")
    A("TriVis work in `ABLATIONS.md` already established the harder lesson that between-run")
    A("TRAINING variance here is **0.0144** while sampling-seed spread is only 0.0075, so any")
    A("single-run config comparison of this size is unresolvable anyway.")
    A("")
    A("The binding constraint is the **~10 s arbitrary windowing**, not any hyper-parameter.")
    A("Re-segmenting to real sentence boundaries is the change that would make ablations")
    A("meaningful. That needs punctuation the `text` field does not contain (940 periods in")
    A("16,401 clips) -- check `processed_vnhn/vnhn_transcript/` (190 files) for whether the")
    A("upstream transcripts kept it. If they did, re-cutting is straightforward; if not it")
    A("needs Vietnamese punctuation restoration first.")
    A("")
    A("## Artifacts")
    A("")
    A("```")
    A("T2M-GPT-code/output_vsl/vq_vnhn/            stage 1 (VQ-VAE)")
    A("T2M-GPT-code/output_vsl/gpt_vnhn/           stage 2 (+ net_iter{10,20,30}k snapshots)")
    A("T2M-GPT-code/dataset/VNHN/                  packed memmaps, shared by both models")
    A("T2M-GPT-code/logs_vnhn/                     evals: sw_*.json, eval_*.json")
    A("T2M-GPT-code/qual_vnhn/                     GT | ceiling | T2M-GPT renders")
    A("0.NSLP-G/sentence-level/logs/*_spavae_vnhn/ NSLP-G stage 1")
    A("0.NSLP-G/sentence-level/logs/*_gs_vnhn/     NSLP-G stage 2")
    A("0.NSLP-G/sentence-level/logs_vnhn/          NSLP-G eval json + logs")
    A("0.NSLP-G/sentence-level/qual_vnhn_3way_fixed/  GT | NSLP-G | T2M-GPT  <- use this one")
    A("0.NSLP-G/sentence-level/qual_vnhn_3way/     SUPERSEDED: panel 3 is T2M-GPT's ceiling,")
    A("                                            not its generation (dump_t2mgpt.py writes")
    A("                                            T2M-GPT output under NSLP-G's condition")
    A("                                            names -- nslpg_pred.npz IS the generation)")
    A("```")
    A("")
    A("Reproduce: `prepare_vnhn_data.py` -> `run_vnhn_t2mgpt.sh` / `run_vnhn_nslpg.sh` ->")
    A("`logs_vnhn/eval_sw.sh` / `eval_vnhn_nslpg.sh` -> `qual_vnhn_3way.sh`.")
    A("Regenerate this file with `make_vnhn_report.py`.")
    A("")
    A("**Gotchas worth keeping:** NSLP-G's `main.py --train` is `nargs='?'` with no `const`, so")
    A("passing it bare sets `None` and the process loads the data then exits 0 with no error --")
    A("use `--train true`. And `dump_t2mgpt.py` needs `transformers` (PhoBERT), which is absent")
    A("from NSLP-G's venv; run that one step with the T2M-GPT venv.")
    A("")
    with open(REPORT, "w") as f:
        f.write("\n".join(L))
    print(f"wrote {REPORT} ({len(L)} lines)")


if __name__ == "__main__":
    main()