Download scripts/r5_loopguard/lg_make_pins.py from treoa/turkic-ocr-code: direct link, hf CLI and curl.
- Browser
- Download file 3.1 kB
-
https://huggingface.co/treoa/turkic-ocr-code/resolve/main/scripts/r5_loopguard/lg_make_pins.py
- Command line
-
hf download hf://treoa/turkic-ocr-code/scripts/r5_loopguard/lg_make_pins.py
-
curl -L -o lg_make_pins.py https://huggingface.co/treoa/turkic-ocr-code/resolve/main/scripts/r5_loopguard/lg_make_pins.py
3.1 kB
| """LOOPGUARD-1: sha256 pin lists of the data the GPU job reads (format of sha256sum, absolute paths; checked with | |
| 'sha256sum -c' by lg_run_gpu.sh stage 0, and listed themselves in READY). | |
| val : stored A0 validation predictions, GPU baseline, validation records, build report, page-model weights folder, the | |
| leader folder (pipeline reader), stored crop scores for G2/G3, stored page scores, clutter manifest, the frozen | |
| design files (DATA/outputs/r6_loopguard/design/) | |
| heldout : held-out records, page files, CPU detector boxes, build_report_heldout.json, prep.done.json (hashed only; no | |
| content is printed), and heldout_exclusions.json (the page ids left out of the primary confirmation) | |
| usage: lg_make_pins.py val|heldout --out FILE | |
| """ | |
| import argparse | |
| import glob | |
| import hashlib | |
| import os | |
| D = "/path/to/TURKIC_OCR_DATA" | |
| ap = argparse.ArgumentParser() | |
| ap.add_argument("what", choices=["val", "heldout"]) | |
| ap.add_argument("--out", required=True) | |
| a = ap.parse_args() | |
| def sha(p): | |
| h = hashlib.sha256() | |
| with open(p, "rb") as f: | |
| for blk in iter(lambda: f.read(1 << 22), b""): | |
| h.update(blk) | |
| return h.hexdigest() | |
| if a.what == "val": | |
| files = [] | |
| for s in ("gen_val", "school_val"): | |
| files += [D + "/outputs/r6_onemodel/page_preds/seed1_final/%s.jsonl" % s, D + "/outputs/r6_onemodel/baseline/gpu/%s.jsonl" % s, | |
| D + "/data/processed/r6_onemodel/records/%s.jsonl" % s] | |
| files += [D + "/data/processed/r6_onemodel/build_report.json", | |
| D + "/outputs/r6_onemodel/scores/onemodel/seed1_final/V1.json", | |
| D + "/outputs/r6_onemodel/scores/onemodel/seed1_final/synth_clutter_val.json", | |
| D + "/outputs/r6_onemodel/page_scores/page_scores_seed1_final.json", | |
| D + "/outputs/r6_onemodel/page_scores/per_page_seed1_final.jsonl", | |
| D + "/outputs/r6_onemodel/page_preds/seed1_final/clutter_spot.jsonl", | |
| D + "/data/processed/r5/frozen_eval_v1/synth_clutter_val.tsv"] | |
| files += sorted(glob.glob(D + "/checkpoints/r6_onemodel/seed1/final/*")) | |
| files += sorted(glob.glob(D + "/checkpoints/r5/paddleocr_vl_1_6/leader/*")) | |
| files += sorted(glob.glob(D + "/outputs/r6_loopguard/design/*")) | |
| else: | |
| files = [D + "/data/processed/r6_loopguard/records/gen_test.jsonl", D + "/data/processed/r6_loopguard/records/school_test.jsonl", | |
| D + "/data/processed/r6_loopguard/det/gen/pages_gen_test.tsv", D + "/data/processed/r6_loopguard/det/school2/pages_school_test.tsv", | |
| D + "/outputs/r6_loopguard/det/gen_test.jsonl", D + "/outputs/r6_loopguard/det/school_test.jsonl", | |
| D + "/data/processed/r6_loopguard/build_report_heldout.json", D + "/outputs/r6_loopguard/prep.done.json", | |
| D + "/data/processed/r6_loopguard/heldout_exclusions.json"] | |
| missing = [p for p in files if not os.path.isfile(p)] | |
| if missing: | |
| raise SystemExit("missing: %s" % missing) | |
| with open(a.out, "w") as f: | |
| for p in files: | |
| f.write("%s %s\n" % (sha(p), p)) | |
| print("pinned", len(files), "files ->", a.out) | |