File size: 3,099 Bytes
24aaa76
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
"""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)