Download src/linedet/make_smoke.py from treoa/turkic-ocr-code: direct link, hf CLI and curl.
- Browser
- Download file 1.75 kB
-
https://huggingface.co/treoa/turkic-ocr-code/resolve/main/src/linedet/make_smoke.py
- Command line
-
hf download hf://treoa/turkic-ocr-code/src/linedet/make_smoke.py
-
curl -L -o make_smoke.py https://huggingface.co/treoa/turkic-ocr-code/resolve/main/src/linedet/make_smoke.py
1.75 kB
| """Smoke-test inputs from the KOHTD split of round R4 (kohtd_split_v1): train and validation crops in the shared manifest | |
| format, a one-component mix yaml and a tiny evalsets.json. Used only until mix_v1 is frozen. | |
| KOHTD sheets and crops stay on the cluster. Writes under DATA/data/processed/r5_linedet_smoke/ (own folder). | |
| """ | |
| import csv | |
| import os | |
| import sys | |
| from .common import DATA, write_tsv, save_json | |
| SPLIT = DATA + "/data/processed/kohtd_split_v1" | |
| IMG = DATA + "/data/processed/kohtd_words_raw/KOHTD_dataset/HK_dataset/img/" | |
| OUT = DATA + "/data/processed/r5_linedet_smoke" | |
| def rows(split_file, split): | |
| out = [] | |
| with open(split_file, newline="", encoding="utf-8") as f: | |
| for r in csv.DictReader(f, delimiter="\t", quoting=csv.QUOTE_NONE): | |
| out.append([r["crop_file"], IMG + r["crop_file"], r["label"], "kk", "Cyrl", "hand_real", "kohtd", split, r["form_id"], "word"]) | |
| return out | |
| def main(n_train=200000, n_val=3000): | |
| hdr = ["id", "image", "text", "lang", "script", "kind", "source", "split", "group", "unit"] | |
| tr = rows(SPLIT + "/train.tsv", "train")[:n_train] | |
| va = rows(SPLIT + "/validation.tsv", "val")[:n_val] | |
| write_tsv(OUT + "/kohtd_train_smoke.tsv", hdr, tr) | |
| write_tsv(OUT + "/kohtd_val_smoke.tsv", hdr, va) | |
| with open(OUT + "/smoke_mix.yaml", "w") as f: | |
| f.write("components:\n - name: kohtd_train_smoke\n manifest: %s/kohtd_train_smoke.tsv\n share: 1.0\n" % OUT) | |
| save_json(OUT + "/evalsets_smoke.json", {"sets": [{"name": "kohtd_val_smoke", "manifest": OUT + "/kohtd_val_smoke.tsv", | |
| "split": "val", "purpose": "smoke", "locked": False}]}) | |
| print(len(tr), len(va)) | |
| if __name__ == "__main__": | |
| main() | |