File size: 2,391 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 | """R5 REF: appends kohtd_rand_test to DATA/data/processed/r5/evalsets.json as a LOCKED test set (clarification H1), in the registry's existing format.
Only this one entry is added; a backup of the old file is kept; the write is atomic. Reads build_report.json (counts, sha256), never the manifest images.
Usage: python ref_register_rand_test.py
"""
import json
import os
import sys
HERE = os.path.dirname(os.path.abspath(__file__))
sys.path.insert(0, HERE)
import ref_common as rc # noqa: E402
rep = json.load(open(rc.REFDATA + "/build_report.json"))
rt = rep["rand_test"]
d = json.load(open(rc.EVALSETS, encoding="utf-8"))
if any(s["name"] == "kohtd_rand_test" for s in d["sets"]):
print("already registered")
sys.exit(0)
bak = rc.EVALSETS + ".bak_before_ref_" + rc.utc().replace(":", "")
with open(bak, "w", encoding="utf-8") as f:
json.dump(d, f, ensure_ascii=False, indent=1)
entry = {"name": "kohtd_rand_test", "manifest": rt["path"], "split": "test",
"purpose": "replication only; overlaps our training forms; never compared with our arms. Test part of the crop-level random 70/15/15 split (seed 20261121) of the pool of all crops of the KOHTD train and validation forms of the project split (clarification H1 of amendment 3.3). Scored with each published paper's own metric, to check the re-run of HTR-Flor (R1) and the PP-OCRv3 recogniser of Bimurat 2024 (R2) against the published numbers.",
"locked": True, "status": "ready", "n_rows": rt["rows"], "n_groups": rt["forms"], "manifest_sha256": rt["sha256"], "langs": {"kk": rt["rows"]}, "unit": "word",
"group_unit": "KOHTD form", "endpoint": "none (replication check only)",
"split_rule": "numpy default_rng(20261121).permutation over the id-sorted pool; first 70% train, next 15% validation, last 15% test; scripts/r5_ref/ref_build_data.py",
"caution": "crop-level split: the same forms and writers occur in rand_train. The pool holds 121,607 crops, fewer than the 140k crops of the papers' split. About 70% of the crops of V1 and kohtd_val are in rand_train, so any figure of a 'rand' checkpoint on V1 or kohtd_val is a training-set figure."}
d["sets"].append(entry)
tmp = rc.EVALSETS + ".tmp_ref"
with open(tmp, "w", encoding="utf-8") as f:
json.dump(d, f, ensure_ascii=False, indent=1)
os.replace(tmp, rc.EVALSETS)
print("registered kohtd_rand_test, backup", bak)
|