runic-reader-2 / code /cutpreds.py
kesha-humonen's picture
Add files using upload-large-folder tool
ed46c5d verified
Raw History Blame Contribute Delete
491 Bytes
"""cutpreds.py <in.jsonl> <out.jsonl>: apply loopcut.cut_loops to recognizer outputs, keeping the raw output
in pred_raw (the same transformation that produced preds/ocr_*_ocr4b_mixcut.jsonl)."""
import json
import sys
from loopcut import cut_loops
with open(sys.argv[2], "w") as f:
for l in open(sys.argv[1]):
r = json.loads(l)
raw = r.get("pred_raw", r["pred"])
f.write(json.dumps(dict(r, pred=cut_loops(raw or ""), pred_raw=raw), ensure_ascii=False) + "\n")