Download scripts/r5_loopguard/lg_prep.sbatch from treoa/turkic-ocr-code: direct link, hf CLI and curl.
- Browser
- Download file 4.19 kB
-
https://huggingface.co/treoa/turkic-ocr-code/resolve/main/scripts/r5_loopguard/lg_prep.sbatch
- Command line
-
hf download hf://treoa/turkic-ocr-code/scripts/r5_loopguard/lg_prep.sbatch
-
curl -L -o lg_prep.sbatch https://huggingface.co/treoa/turkic-ocr-code/resolve/main/scripts/r5_loopguard/lg_prep.sbatch
4.19 kB
| #!/bin/bash | |
| #SBATCH --job-name=lg_prep | |
| #SBATCH --partition=ZEN4 | |
| #SBATCH --cpus-per-task=16 | |
| #SBATCH --mem=32G | |
| #SBATCH --time=02:00:00 | |
| # (site-specific node exclusion removed: one ZEN4 node of the original cluster lacked libGL) | |
| #SBATCH --output=/path/to/TURKIC_OCR_DATA/logs/%x_%j.out | |
| # LOOPGUARD-1 prep (design protocol step 2; no reading model, no score). one node was excluded: its libGL was missing for cv2 | |
| # (om_score.py note of 25 Nov 2026). Prints counts only, never text. | |
| # 1 det_prep reproduction: the validation page files rebuilt with the same code path equal the stored ones (except the | |
| # image column) | |
| # 2 held-out page files (1280-px copies, reference boxes and lines): School test (annotations_test.json) and generated test | |
| # 3 CPU detector (lg_detect.py = tp2_tob_detect.py + csv field limit; det_eval settings) on the first 20 validation pages | |
| # per set; lg_box_check against the | |
| # stored det_eval boxes (same count, every box matched at IoU >= 0.9) | |
| # 4 only if 3 passed: CPU detector boxes for the 300 + 150 held-out pages | |
| # 5 held-out page records (om_build_pages.py --heldout: resized page images, references, leak check) | |
| # 6 prep.done.json, then the held-out data pins lg_pins_heldout.sha256 (hashes only) | |
| set -u | |
| C=/path/to/TURKIC_OCR_CODE | |
| D=/path/to/TURKIC_OCR_DATA | |
| S=$C/scripts/r5_loopguard | |
| PY=$C/.venv_vlm/bin/python | |
| PK=$C/.venv_kraken/bin/python | |
| P=$D/data/processed/r6_loopguard | |
| O=$D/outputs/r6_loopguard | |
| W=$D/checkpoints/r5/linedet/detectors/yolo_s2/weights/best.pt | |
| DET=$D/data/processed/r5_linedet_det | |
| TMPV=$D/tmp/lg_detprep_valcheck | |
| unset HF_TOKEN HUGGING_FACE_HUB_TOKEN | |
| export HF_HOME=$D/hf_cache/r5_vlmb_home HF_HUB_OFFLINE=1 TRANSFORMERS_OFFLINE=1 TOKENIZERS_PARALLELISM=false PYTHONDONTWRITEBYTECODE=1 | |
| export OMP_NUM_THREADS=16 | |
| mkdir -p $O/prep $O/det $P/det | |
| hostname; date -u | |
| echo "=== 1 det_prep validation reproduction $(date -u +%T)" | |
| rm -rf $TMPV | |
| $PK -I $S/lg_det_prep.py valcheck --out $TMPV --report $O/prep/det_prep_valcheck.json --workers 16 > $O/prep/det_prep_valcheck.stdout 2>&1 | |
| echo "valcheck rc $?" | |
| rm -rf $TMPV | |
| echo "=== 2 held-out page files $(date -u +%T)" | |
| $PK -I $S/lg_det_prep.py school --split test --out $P/det/school2 --workers 16 > $O/prep/det_prep_school_test.stdout 2>&1 | |
| echo "school test rc $?" | |
| $PK -I $S/lg_det_prep.py gen --split test --out $P/det/gen --workers 16 > $O/prep/det_prep_gen_test.stdout 2>&1 | |
| echo "gen test rc $?" | |
| echo "=== 3 box check on validation $(date -u +%T)" | |
| rm -f $O/prep/boxcheck_gen_val.jsonl $O/prep/boxcheck_school_val.jsonl | |
| $PK -I $S/lg_detect.py --pages $DET/gen/pages_gen_val.tsv --image-col image --weights $W \ | |
| --out $O/prep/boxcheck_gen_val.jsonl --max-pages 20 --threads 16 | |
| $PK -I $S/lg_detect.py --pages $DET/school2/pages_school_val.tsv --image-col image --weights $W \ | |
| --out $O/prep/boxcheck_school_val.jsonl --max-pages 20 --threads 16 | |
| $PK -I $S/lg_box_check.py --cpu gen_val=$O/prep/boxcheck_gen_val.jsonl,school_val=$O/prep/boxcheck_school_val.jsonl \ | |
| --stored gen_val=$D/outputs/r5/linedet/det_eval/e2e_yolo_s2_gen_val_A1_long_pages.jsonl,school_val=$D/outputs/r5/linedet/det_eval/e2e_yolo_s2_school_val_A1_long_pages.jsonl \ | |
| --n 20 --out $O/prep/box_check.json | |
| BC=$? | |
| echo "box check rc $BC" | |
| if [ $BC -eq 0 ]; then | |
| echo "=== 4 held-out detector boxes $(date -u +%T)" | |
| $PK -I $S/lg_detect.py --pages $P/det/gen/pages_gen_test.tsv --image-col image --weights $W \ | |
| --out $O/det/gen_test.jsonl --threads 16 > $O/prep/detect_gen_test.stdout 2>&1 | |
| echo "detect gen_test rc $?" | |
| $PK -I $S/lg_detect.py --pages $P/det/school2/pages_school_test.tsv --image-col image --weights $W \ | |
| --out $O/det/school_test.jsonl --threads 16 > $O/prep/detect_school_test.stdout 2>&1 | |
| echo "detect school_test rc $?" | |
| else | |
| echo "box check failed: held-out detector boxes NOT made" | |
| fi | |
| echo "=== 5 held-out records $(date -u +%T)" | |
| $PY -I $S/om_build_pages.py --heldout --workers 16 > $O/prep/build_heldout.stdout 2>&1 | |
| echo "build rc $?" | |
| echo "=== 6 verdict and pins $(date -u +%T)" | |
| $PK -I $S/lg_prep_done.py --out $O/prep.done.json | |
| RC=$? | |
| if [ $RC -eq 0 ]; then | |
| $PK -I $S/lg_make_pins.py heldout --out $S/lg_pins_heldout.sha256 | |
| echo "pins rc $?" | |
| fi | |
| echo "=== exit $RC $(date -u)" | |