File size: 2,075 Bytes
24aaa76 | 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 | """R5 VLMA: one table of the smoke tests (20 steps + save-and-resume on KOHTD train, export, reload, 16 train crops
read back). Columns: ok, resume fingerprint match, median step seconds (KOHTD words, batch 32), max train memory,
answer-end tokens, reload CER on 16 TRAIN crops (a pipeline check, not a result), hit_cap share, curve-test CER.
usage: smoke_table.py OUT_TSV
"""
import glob
import json
import os
import sys
V = "/path/to/TURKIC_OCR_DATA/outputs/r5/vlma"
summ = json.load(open(os.path.join(V, "smoke_summary.json")))
rows = []
for short, s in summ.items():
d = os.path.join(V, "runs", "smoke_" + short, "smoke")
g = {}
if os.path.exists(os.path.join(d, "smoke_generation.json")):
g = json.load(open(os.path.join(d, "smoke_generation.json")))
ex = g.get("examples", [])
metas = sorted(glob.glob(os.path.join(d, "run_meta_*.json")))
rm = json.load(open(metas[-1])) if metas else {}
cv = {}
if os.path.exists(os.path.join(d, "curve_test", "meta.json")):
cv = json.load(open(os.path.join(d, "curve_test", "meta.json")))
rows.append([short, s.get("ok"), s.get("resume_fingerprint_match"), s.get("median_step_seconds_kohtd_words"),
s.get("max_mem_GiB_train"), json.dumps(rm.get("answer_suffix_tokens", []), ensure_ascii=False),
(g.get("score_train_rows_not_a_result") or {}).get("plain", {}).get("cer"),
(sum(1 for e in ex if e.get("hit_cap")) / len(ex)) if ex else None,
int(any(e.get("conf") is not None for e in ex)), cv.get("plain_cer"), s.get("utc")])
hdr = ["short", "ok", "resume_fp_match", "median_step_s_words_b32", "max_mem_GiB_train", "answer_end_tokens",
"reload_cer_16_train_crops", "reload_hit_cap_share", "conf_present", "curve_test_cer_32_train_crops", "smoke_utc"]
with open(sys.argv[1], "w", encoding="utf-8") as f:
f.write("\t".join(hdr) + "\n")
for r in rows:
f.write("\t".join("" if x is None else str(x) for x in r) + "\n")
for r in rows:
print("\t".join("" if x is None else str(x) for x in r))
|