Download scripts/r5_vlma/linedet_ckpt_task.sh from treoa/turkic-ocr-code: direct link, hf CLI and curl.
- Browser
- Download file 3.61 kB
-
https://huggingface.co/treoa/turkic-ocr-code/resolve/main/scripts/r5_vlma/linedet_ckpt_task.sh
- Command line
-
hf download hf://treoa/turkic-ocr-code/scripts/r5_vlma/linedet_ckpt_task.sh
-
curl -L -o linedet_ckpt_task.sh https://huggingface.co/treoa/turkic-ocr-code/resolve/main/scripts/r5_vlma/linedet_ckpt_task.sh
3.61 kB
| # R5 test pass (clarifications J2/J9): ONE line-arm checkpoint on the named locked sets, with LINEDET's own commands as the | |
| # run() function of CODE/scripts/r5_linedet/test_pass_commands.sh (sha256 a3f37d8e...) writes them: linedet.predict | |
| # --test_pass, then linedet.lm_decode --test_pass when a validation-tuned LM exists (its H9 gate hook runs inside it). | |
| # The only addition is linedet.predict's own option --only (comma-separated set names), so the shared task list keeps | |
| # J2's order per checkpoint and per set. LINEDET's script and modules are not changed. | |
| # Gate: LINEDET's predict.py and lm_decode.py refuse the test pass without DATA/outputs/r5/linedet/test_pass_started.txt; | |
| # this wrapper checks it first. Exit codes: 0 done, 1 gate missing, 2 predict failed, 3 lm_decode failed, 4 a requested set | |
| # has no TSV written by this call (predict.py records a skipped set only in its summary and exits 0), 10 no checkpoint. | |
| # Known effect of per-call sets (LINEDET's code, unchanged): predict.py rewrites <label>/<ckpt>/meta_test_pass.json with the | |
| # sets of THIS call only, and lm_decode decodes exactly those sets; the TSVs of earlier calls stay. A copy of both meta files | |
| # of every call is kept in $TESTPASS_DIR/linedet_meta/ (provenance only; nothing reads it). | |
| # LD_GATE, LD_EVALSETS, LD_PRED_DIR, LD_LOGIT_DIR: smoke tests on scratch paths only (unset in the real pass). | |
| # usage: linedet_ckpt_task.sh LABEL ARM CKPT_DIR CHECKPOINT SETS | |
| set -u | |
| unset HF_TOKEN HUGGING_FACE_HUB_TOKEN | |
| C=/path/to/TURKIC_OCR_CODE | |
| D=/path/to/TURKIC_OCR_DATA | |
| PY=$C/.venv_kraken/bin/python | |
| GATE=${LD_GATE:-$D/outputs/r5/linedet/test_pass_started.txt} | |
| PD=${LD_PRED_DIR:-$D/outputs/r5/preds} | |
| X=() # empty in the real pass: the commands are run()'s own plus --only | |
| [ -n "${LD_GATE:-}" ] && X+=(--gate_file $LD_GATE) | |
| [ -n "${LD_EVALSETS:-}" ] && X+=(--evalsets $LD_EVALSETS) | |
| [ -n "${LD_PRED_DIR:-}" ] && X+=(--pred_dir $LD_PRED_DIR) | |
| [ -n "${LD_LOGIT_DIR:-}" ] && X+=(--logit_dir $LD_LOGIT_DIR) | |
| LAB=$1; ARM=$2; CD=$3; CKPT=$4; SETS=$5 | |
| if [ ! -f $GATE ]; then echo "REFUSED: $GATE does not exist (the scoring pass has not started)"; exit 1; fi | |
| if [ ! -f $CD/$ARM/$CKPT.pt ]; then echo "skip $LAB $CKPT (no checkpoint)"; exit 10; fi | |
| echo "=== $LAB $CKPT sets $SETS $(date -u +%FT%TZ)" | |
| MC=${TESTPASS_DIR:-/tmp}/linedet_meta; mkdir -p $MC; STAMP=$(date -u +%Y%m%dT%H%M%SZ) | |
| T0=$MC/.start_${LAB}_${CKPT}_$$; touch $T0; sleep 1 | |
| missing() { # folder: every requested set must have a TSV written by this call (predict.py skips a set silently) | |
| local M="" s | |
| for s in ${SETS//,/ }; do [ "$1/$s.tsv" -nt $T0 ] || M="$M $s"; done | |
| echo $M | |
| } | |
| $PY -I -m linedet.predict --arm $ARM --arm_label $LAB --ckpt $CKPT --ckpt_dir $CD --test_pass --device ${LINEDET_DEVICE:-cuda} --workers 8 --only $SETS "${X[@]}" || { rm -f $T0; exit 2; } | |
| cp $PD/$LAB/$CKPT/meta_test_pass.json $MC/${LAB}_${CKPT}_greedy_$STAMP.json 2>/dev/null | |
| MS=$(missing $PD/$LAB/$CKPT) | |
| if [ -n "$MS" ]; then echo "INCOMPLETE: predict wrote no TSV for:$MS"; rm -f $T0; exit 4; fi | |
| if [ -f $PD/$LAB/${CKPT}_lm/meta.json ]; then | |
| $PY -I -m linedet.lm_decode --arm $LAB --ckpt $CKPT --test_pass --workers 16 "${X[@]}" || { rm -f $T0; exit 3; } # no --max_lines: every crop | |
| cp $PD/$LAB/${CKPT}_lm/meta_test_pass.json $MC/${LAB}_${CKPT}_lm_$STAMP.json 2>/dev/null | |
| MS=$(missing $PD/$LAB/${CKPT}_lm) | |
| if [ -n "$MS" ]; then echo "INCOMPLETE: lm_decode wrote no TSV for:$MS"; rm -f $T0; exit 4; fi | |
| else | |
| echo "no validation-tuned LM for $LAB $CKPT: LM decoding skipped" | |
| fi | |
| rm -f $T0 | |
| echo "=== done $LAB $CKPT $(date -u +%FT%TZ)" | |