Add adaptive preprocessing escalation and single-receipt test scripts
build / build (push) Successful in 2m57s
build / build (push) Successful in 2m57s
Preprocessing now tries progressively heavier variants per receipt (plain -> high-pass -> edge-enhance -> both), stopping as soon as a cheap LLM-free arithmetic check on the OCR text looks plausible, so the extra processing only applies to receipts that need it. A flat version of the same heavier processing regressed the full batch by helping hard receipts but hurting easy ones; the adaptive version improves date-matching 37/52 -> 40/52 with no regression (see testing/2026_10_04_gimp_highpass_nlfilter_experiment.md). Also adds test_ocr.sh and test_single.sh for checking a single receipt's OCR text or full pipeline result without a batch run.
This commit is contained in:
Executable
+37
@@ -0,0 +1,37 @@
|
||||
#!/usr/bin/env bash
|
||||
# Test-only tool: runs preprocessing + OCR (1_preprocess_image.sh,
|
||||
# 2_ocr_image.sh - variant 0/baseline only, deliberately not
|
||||
# 12_adaptive_preprocess_ocr.sh) on a single receipt photo and prints the
|
||||
# raw OCR text to stdout - no LLM extraction step, no ground-truth
|
||||
# comparison, and no files left behind (unlike test_single.sh/
|
||||
# test_batch.sh, which persist scratch/result directories and go through
|
||||
# the real adaptive pipeline). Useful for quickly checking what Tesseract
|
||||
# actually reads off one specific preprocessing variant in isolation -
|
||||
# e.g. while iterating on tooling-container/src/preprocess.py - without
|
||||
# the adaptive step's variant selection in the way, waiting on the LLM
|
||||
# call, or needing ground truth.
|
||||
#
|
||||
# Usage: ./test_ocr.sh -in <photo.jpg>
|
||||
set -euo pipefail
|
||||
|
||||
cd "$(dirname "${BASH_SOURCE[0]}")"
|
||||
|
||||
fail() { echo "FAIL: $*" >&2; exit 1; }
|
||||
|
||||
IN_PATH=""
|
||||
while [ $# -gt 0 ]; do
|
||||
case "$1" in
|
||||
-in) IN_PATH="${2:-}"; shift 2 ;;
|
||||
*) fail "unknown argument: $1" ;;
|
||||
esac
|
||||
done
|
||||
[ -n "$IN_PATH" ] || fail "usage: $0 -in <photo.jpg>"
|
||||
[ -f "$IN_PATH" ] || fail "input file not found: $IN_PATH"
|
||||
|
||||
SCRATCH_DIR="$(mktemp -d)"
|
||||
trap 'rm -rf "$SCRATCH_DIR"' EXIT
|
||||
|
||||
./1_preprocess_image.sh -in "$IN_PATH" -out "$SCRATCH_DIR" >/dev/null
|
||||
./2_ocr_image.sh -in "$SCRATCH_DIR/03_final.png" -out "$SCRATCH_DIR" >/dev/null
|
||||
|
||||
cat "$SCRATCH_DIR/ocr.txt"
|
||||
Reference in New Issue
Block a user