Download scripts/r5_testpass2/tp2_amend2.py from treoa/turkic-ocr-code: direct link, hf CLI and curl.
- Browser
- Download file 5.71 kB
-
https://huggingface.co/treoa/turkic-ocr-code/resolve/main/scripts/r5_testpass2/tp2_amend2.py
- Command line
-
hf download hf://treoa/turkic-ocr-code/scripts/r5_testpass2/tp2_amend2.py
-
curl -L -o tp2_amend2.py https://huggingface.co/treoa/turkic-ocr-code/resolve/main/scripts/r5_testpass2/tp2_amend2.py
5.71 kB
| """Appends amendment 2 (Kazakh real-document benchmark, owner-approved 25 Nov 2026) to records/R5/TESTPASS2/plan.json, before the model | |
| reads any of its pages. | |
| usage: tp2_amend2.py TESTPASS2_DIR | |
| """ | |
| import hashlib | |
| import json | |
| import os | |
| import sys | |
| import time | |
| TP = sys.argv[1] | |
| p = os.path.join(TP, "plan.json") | |
| plan = json.load(open(p, encoding="utf-8")) | |
| prev = hashlib.sha256(open(p, "rb").read()).hexdigest() | |
| L = json.load(open(os.path.join(TP, "dl_kzb", "listing.json"), encoding="utf-8")) | |
| code = {} | |
| for f in ("tp2_kzb_fetch.py", "tp2_kzb_prep.py", "tp2_kzb_score.py", "tp2_kzb_card.sbatch", "tp2_kzb_fetch.sbatch", "tp2_kzb_run.sbatch", | |
| "tp2_tob_detect.py", "tp2_tob_read.py", "tp2_tob_img.py"): | |
| code[f] = hashlib.sha256(open(os.path.join(TP, "code", f), "rb").read()).hexdigest() | |
| amend = { | |
| "n": 2, "utc": time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime()), "previous_plan_sha256": prev, | |
| "before_any_prediction_on_this_set": True, | |
| "why": ("the owner approved downloading the Kazakh real-document benchmark on 25 Nov 2026; it replaces the " | |
| "entry in sets_not_run"), | |
| "set": {"name": "kzb_hand", "source": "Hugging Face dataset Omar-2002/kz_benchmark_data, config 'handwritten' (split test), revision " | |
| + L["revision"] + " (last modified " + L["last_modified"] + ")", | |
| "pages": 150, "folder": "DATA/data/raw/kz_benchmark_hw (new, empty before the download), README.md sha256 " + L["readme_sha256"], | |
| "files": "README.md, real_handwritten_data/data.csv (columns image_path, text), real_handwritten_data/images/0001-0150.jpg; sha256 in " | |
| "DATA/checksums/kz_benchmark_hw.sha256 and DATA/outputs/r5/testpass2/kzb/fetch.json (checked against the LFS sha256 of the listing)", | |
| "licence": ("card: annotations CC BY 4.0; images collected from the public web, copyright of the original publishers or authors, shared " | |
| "only for non-commercial research evaluation (this project is research only, non-commercial)"), | |
| "status": "DESCRIPTIVE ONLY", | |
| "label_provenance": ("card section 'Source data': pages 0001-0030 'drafted by a vision-language model, then corrected by hand'; pages " | |
| "0031-0150 first-pass VLM transcriptions 're-read against the image by Gemini' and 'then checked by a human. Because " | |
| "of time constraints, some pages may still contain small errors'; page 0042 'still has its first-pass " | |
| "transcription'; section 'Known limitations': 'The references were produced with the help of vision-language " | |
| "models and have not all been verified by a human'. The human check is the card's own claim, not shown, and the " | |
| "card itself qualifies it, so under the project rule the set is descriptive only (findings CL-30: model-drafted " | |
| "references). Slice 0001-0030 (hand-corrected per the card) is reported separately, also descriptive."), | |
| "split": "test only ('A test-only benchmark'); pages 'collected by the author from public web image search' (card)", | |
| "caveat": "card: 'Possible overlap with web data': base-model pretraining exposure unknown; no page or path of it is in our training data"}, | |
| "pipeline": ("identical to the TurkishOCR-Bench pages (plan pages.pipeline): tp2_kzb_prep.py makes the page list and 1280 px copies with " | |
| "tp2_tob_img.load_page and the det_prep resize rule; tp2_tob_detect.py (YOLO11s stage 2, CPU, imgsz 1280, conf 0.25, iou 0.6, " | |
| "max_det 300); tp2_tob_read.py (M1, unchanged)"), | |
| "reference": ("tp2_kzb_score.kz_ref_lines: the data.csv text, NFC, split at line breaks, whitespace runs to one space, empty lines dropped; " | |
| "no markup stripping (the card's scan found no Markdown or HTML in the handwritten references)"), | |
| "metric": ("linedet.det_eval.page_cers: M28 reading order (primary) and M29 order free, micro over pages, case-sensitive; secondary: both " | |
| "lower-cased (str.lower); as the card suggests, the per-page mean of M28 capped at 1.0 and the number of pages above 1.0; output-" | |
| "to-reference character ratio; pages with hit-cap lines. M29 caveat as for the other page sets; page 0042's reference is one line."), | |
| "interval": "95% percentile bootstrap over pages (no document or writer id exists), B 10000, seed 20261121", | |
| "running": ("tp2_kzb_fetch.sbatch (download + page list, no model) then tp2_kzb_run.sbatch (detector, M1, scorer), each one ZEN4 job; to " | |
| "keep at most 6 tasks at once the tp2_test array throttle was lowered from 6 to 5 at 07:33Z"), | |
| "code_sha256": code, | |
| "interim_scoring_log": ("job 55227 (07:21-07:23Z) scored the five complete crop sets of M1 (az_localdoc_test, chd_test, hkr_test1, " | |
| "hkr_test2, synth_typed_test), the TurkishOCR-Bench handwritten pages and the 125 printed pages done by then, to " | |
| "check the scoring chain; the aggregates were seen; nothing was changed because of them. Final scoring reruns " | |
| "the same code after every task is complete."), | |
| } | |
| plan["amendments"].append(amend) | |
| plan["sets_not_run"]["kz_benchmark (Omar-2002/kz_benchmark_data, 150 handwritten pages)"] = "superseded by amendment 2 (owner approved the download)" | |
| plan["version"] = "1.2" | |
| json.dump(plan, open(p, "w", encoding="utf-8"), indent=1, ensure_ascii=False) | |
| print("amended", p, hashlib.sha256(open(p, "rb").read()).hexdigest()) | |