We padded every batch to 320px for no reason¶
Recognition is 76% of arboOCR's CPU engine time and Session::Run alone is 95%
of recognition, so if you want the engine faster there is exactly one place to
look. v0.4.0 cuts −26% engine latency on the small tier, and most of it came
from deleting a constant.
The floor that looked like a requirement¶
The recognizer batches up to 6 crops into one inference call, so a batch has to
share one width. arboOCR sized that width by starting from the model's
reference width — rec_image_shape's 320 — and growing to fit the widest crop
in the batch.
Both halves of that sentence matter. The 320 was never a requirement: it is the aspect ratio PaddleOCR's own inference script uses to seed a ratio, and the crops' real widths are what the model actually sees. But because it was the floor, a batch of six small crops — a receipt's line items, a form's fields — was padded out to 320px and ran a conv stack over 320px of mostly zeros.
The fix is to size the strip to the batch's own widest crop, with a much smaller floor (32px) so a batch of tiny crops cannot collapse to a degenerate strip:
| Batch contents | Old strip width | New strip width |
|---|---|---|
| Six ~90px line items | 320 | ~90 |
| One 240px crop + five ~110px | 320 | 240 |
| Six crops wider than 320 | widest crop | widest crop (unchanged) |
The third row is why this is a pure win on padding rather than a behaviour change for wide text: anything already at or above 320 was never padded, and still is not.
Six more things, and the one that is not free¶
Five smaller changes came in the same pass, all measured together:
| Change | Effect |
|---|---|
EnableMemPattern + ORT_SEQUENTIAL on all three sessions |
Reuses tensor buffers across runs; avoids per-op thread-pool overhead on the single-image path |
| Batch width sized to the batch | The −26% above |
| Single-pass argmax + score in the CTC decode | Removes a second walk of every timestep's class vector |
| CTC decode cut at each crop's own share of the strip | The trailing timesteps cover only zero padding; no reason to argmax them |
minDetBoxArea (default 20, detector-input pixels) |
Drops dust-sized detection boxes before recognition instead of paying a crop + inference to read nothing |
This release is a measured improvement, not a byte-identical one
The padding changes alter what the recognizer sees, so output can differ. On the 40-image SROIE2019 sample: average similarity 86.31% → 86.40%, but only 8 of 40 stems are character-identical — 20 improved, 12 got slightly worse, worst case −0.46pp.
The cause is the strip width, not the decode cut. A narrower strip feeds the conv stack different right-edge context, so the logits for the last few characters of a crop move marginally. Net effect here is flat-to-slightly-up, and you should re-measure on your own corpus before treating either number as yours.
Measurement¶
Same 40 SROIE2019 stems, identical PP-OCRv6 small weights and dicts, CPU cold-spawn in both arms — and, importantly, four arms run in one session so a drift in machine state cannot be mistaken for a code change:
| Engine | Avg engine ms | Avg wall ms | Avg sim |
|---|---|---|---|
| oar-ocr small | 529 | 703 | 84.72% |
| arboOCR small | 363 | 559 | 86.40% |
| ppu-paddle-ocr | 489 | 956 | 83.51% |
oar-ocr and ppu-paddle-ocr were re-run from byte-identical binaries as controls. Both reproduced their previous numbers to the digit (oar 529ms/84.72% twice; ppu 485→489ms, 83.51% twice, 0/40 stems changed similarity), which is what lets the −26% be attributed to the code rather than to a warm machine.
Two things are worth reading off that table. arboOCR is now the fastest engine in it on engine time — 363ms against oar-ocr's 529 and ppu's 489 — while scoring 1.7 points above oar and 2.9 above ppu. And the gap between engine and wall time (spawn plus model load, paid per image in a cold-spawn harness) is comparable between arboOCR and oar-ocr — 196ms vs 174ms — against ppu's 467ms.
One caveat this table cannot settle
The three engines bundle different onnxruntime versions (arbo 1.23.2 from
vcpkg, oar 1.28.0, ppu 1.29.0 via onnxruntime-node) and that was not
equalised. Some of arboOCR's remaining distance from ppu is plausibly the
runtime rather than either engine's code; arboOCR can opt into 1.28.0 with
-DARBOOCR_ORT_VERSION=1.28.0 if you want to test that yourself.
Two new flags¶
Both are in EngineConfig and on the CLI:
# Drop detection boxes under 20 detector-input pixels (default; 0 disables).
--min-det-box-area 20
# Opt-in: emit a space where the space logit is a strong CTC runner-up.
# Off by default — it can insert spurious spaces in dense symbol runs.
--space-recovery
--min-det-box-area is on by default and measured identical output on 40/40
images at its default versus disabled, so it is not a behaviour change for
normal documents — it just stops pathological detection noise from paying for a
crop and an inference.
Upgrading¶
Nothing in the API or CLI changed shape. If you diff OCR output against a stored baseline, regenerate it — see the warning above. If you are on the wrappers, the pinned release moved and you get it on the next install.
The full cross-engine write-up, including what arboOCR took from ppu-paddle-ocr
and what it deliberately did not, lives in
compare/ARBOOCR_VS_OAR.md.