Download scripts/r5/r5_val_subsets.py from treoa/turkic-ocr-code: direct link, hf CLI and curl.
- Browser
- Download file 1.04 kB
-
https://huggingface.co/treoa/turkic-ocr-code/resolve/main/scripts/r5/r5_val_subsets.py
- Command line
-
hf download hf://treoa/turkic-ocr-code/scripts/r5/r5_val_subsets.py
-
curl -L -o r5_val_subsets.py https://huggingface.co/treoa/turkic-ocr-code/resolve/main/scripts/r5/r5_val_subsets.py
1.04 kB
| """R5 DATA (optional helper): fixed 2,000-row random subsets of the three large Russian validation manifests (hkr_val, chd_val, school_val), | |
| so that a validation pass over many checkpoints stays cheap. The full validation manifests stay as they are. | |
| Draw: numpy.random.default_rng(20261121).choice(n, 2000, replace=False), rows kept in manifest order. Opens no image. | |
| Usage: python -I r5_val_subsets.py | |
| """ | |
| import numpy as np | |
| from pathlib import Path | |
| MAN = Path("/path/to/TURKIC_OCR_DATA/data/processed/r5/manifests") | |
| for name in ("hkr_val", "chd_val", "school_val"): | |
| lines = open(MAN / f"{name}.tsv", encoding="utf-8", newline="").read().split("\n") | |
| header, rows = lines[0], [l for l in lines[1:] if l] | |
| rng = np.random.default_rng(20261121) | |
| pick = np.sort(rng.choice(len(rows), size=2000, replace=False)) | |
| with open(MAN / f"{name}_s2000.tsv", "w", encoding="utf-8", newline="") as f: | |
| f.write(header + "\n") | |
| for i in pick: | |
| f.write(rows[i] + "\n") | |
| print(name, len(rows), "->", len(pick)) | |