Download src/r5eval/frozen.py from treoa/turkic-ocr-code: direct link, hf CLI and curl.
- Browser
- Download file 1.63 kB
-
https://huggingface.co/treoa/turkic-ocr-code/resolve/main/src/r5eval/frozen.py
- Command line
-
hf download hf://treoa/turkic-ocr-code/src/r5eval/frozen.py
-
curl -L -o frozen.py https://huggingface.co/treoa/turkic-ocr-code/resolve/main/src/r5eval/frozen.py
1.63 kB
| """Loads the two frozen files by path and refuses to run if their bytes are not the fingerprinted ones. | |
| scorelib_j2.py J2 screen scoring library, amendment 1, sha256 recorded in records/R4/J2_screen/scoring.txt and | |
| eval_spec.json binding_inputs (ae7457a0...) | |
| postproc_vlma.py VLMA fixed post-processing script, fingerprinted 2026-11-20T22:17:56Z (records/R5/VLMA/postproc.sha256) | |
| scorelib_j2.py is byte-identical to the original. postproc_vlma.py differs from the original only by one reworded line | |
| of its docstring (original sha256 77653dee...); FROZEN_SHA256 holds the sha256 of the shipped file. The two fixes found by RESEVAL (other_script for | |
| Uzbek Latin, Turkic case fold) live in textnorm.py, not in the frozen file. | |
| """ | |
| import hashlib | |
| import importlib.util | |
| import os | |
| _DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), "frozen") | |
| FROZEN_SHA256 = { | |
| "scorelib_j2.py": "ae7457a01993a9653457c658fde08db21d21da3e18284a7b0cb3e1c7f8dadacc", | |
| "postproc_vlma.py": "8b85e10fc93171a75a34200bf6df8b1e9a41b7d2dafb5a61c47b223d1ab7aa6f", | |
| } | |
| def _load(fname): | |
| path = os.path.join(_DIR, fname) | |
| with open(path, "rb") as f: | |
| data = f.read() | |
| got = hashlib.sha256(data).hexdigest() | |
| if got != FROZEN_SHA256[fname]: | |
| raise RuntimeError("frozen file %s has sha256 %s, expected %s" % (fname, got, FROZEN_SHA256[fname])) | |
| spec = importlib.util.spec_from_file_location("r5eval_frozen_" + fname[:-3], path) | |
| mod = importlib.util.module_from_spec(spec) | |
| spec.loader.exec_module(mod) | |
| return mod | |
| j2 = _load("scorelib_j2.py") | |
| vlma_pp = _load("postproc_vlma.py") | |