Skip to content

feat(onscreen): ONNX local engine, pinned model fetch, provider in QA - #20

Open
anthony-hermes[bot] wants to merge 5 commits into
wt/onscreen-corefrom
wt/onscreen-onnx
Open

anthony-hermes[bot] wants to merge 5 commits into
wt/onscreen-corefrom
wt/onscreen-onnx

Conversation

@anthony-hermes

@anthony-hermes anthony-hermes Bot commented Dec 4, 2026

Copy link
Copy Markdown
Contributor

Lane 10, the local engine: ONNX PP-OCR with the Korean recognizer, plus the model fetch script.

  • OnnxOcrEngine behind the protocol: PP-OCRv5 mobile detection plus korean_PP-OCRv5_mobile_rec, numpy-only preprocessing, CTC decode against the pinned dictionary.
  • Provider reporting: CUDA when it loads, CPU otherwise, recorded in QA (OS10.6).
  • scripts/fetch_models.sh installs three sha256-pinned files into the app data directory, refuses a mismatch, and serves verified files from cache. No model file is committed (OS10.7).
  • One slow test reads a committed fixture frame and is skipped without the models, so CI stays green without a download.

Card: t_90680d5b. On forge at b5a97e4 the committed Korean fixture reads as 구독과 좋아요 at 0.9941 on the CPU provider; pytest -q tests/onscreen/test_onnx_engine.py -m "not slow" && make check exits 0 (35 passed, 2 deselected, then 234 passed).

Stacked on #19; merge that first and retarget this to master.

Lane 10's local engine reads Korean from one frame and says which provider ran.

- OnnxOcrEngine runs PP-OCRv5 mobile detection plus
  korean_PP-OCRv5_mobile_rec behind the OcrEngine protocol; CUDA is used
  when the runtime lists it and a session loads, CPU otherwise, and the
  provider is reported for qa.json (OS10.6). A CPU run adds one QA note.
- scripts/fetch_models.sh installs the three pinned files into the app
  data directory, verifies sha256 and size before an atomic move, refuses
  a mismatch, and serves a verified file from cache on the next run. The
  manifest pins Hugging Face revisions, not branches, and no model file is
  in the repository (OS10.7).
- Detection and recognition pixels are numpy only: BGR NCHW input at a
  multiple of 32 with the long side capped at 960, DB threshold and unclip
  constants from the pinned config, line merging, 48-pixel recognition
  crops capped at 320 wide, and greedy CTC decode against the config's own
  character order. A frame with no text returns no fragments.
- One committed PPM fixture labelled with its text, read by a slow test
  only when the models are installed; without them the test skips with the
  fetch command in the reason.
- pyproject declares numpy and onnxruntime; mypy ignores the untyped
  onnxruntime import.
@anthony-hermes
anthony-hermes Bot requested a review from anthonyma94 as a code owner December 4, 2026 18:59
@anthony-hermes
anthony-hermes Bot added this pull request to stack #22 December 5, 2026 00:17
@anthony-hermes

anthony-hermes Bot commented Dec 5, 2026

Copy link
Copy Markdown
Contributor Author

Trimmed the ONNX engine tests, on top of #19's merge.

  • Removed helper-math tests (bilinear solid colour, unclip expansion, crop clamping), the malformed-manifest guard, the class-count guard, and the committed-fixture self-check.
  • Kept everything that decides what a user sees: model manifest and fetch-script verification, missing-model error naming the fetch command, detection and recognition input contracts, boxes from the probability map, NMS on one line, scaling back to source pixels, CTC decode, provider selection and its QA note, and the two slow fixture tests.
  • platformdirs was missing from the local venv; installed for verification only, no repo change.

246 tests, make check exit 0, CI green.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants