gigapdf-lib
OCR engine. PaddleOCR is printed-text only, so this model adds handwriting for the Latin /
Cyrillic / Greek alphabets. It runs on RTen (pure-Rust
ONNX, no C++, no Tesseract) and is invoked opt-in (a handwriting model is overconfident on printed
input, so it is kept out of the engine's automatic printed-script selection).nn.LSTM (256 hidden) → CTC. The standard LSTM exports to a dynamic-width ONNX
LSTM op, so the engine feeds each line at its natural width — no fixed-width padding.= 1 − gray (dark text → 1) on a 0 background,
tight-cropped to the ink, tensor [1, 1, 32, W] (dynamic width).[1, T, K+1] CTC logits. Charlist: classes 0..K-1 = the dict.txt alphabet
(Latin-extended + Cyrillic + Greek, one char per line), class K = CTC blank (last).crates/ocr-rten/tools/train_handwriting.py. The lineage traces to gigapdf's first handwriting model,
which beat Tesseract on IAM (CER 0.309); this is the clean, dynamic-width RTen re-train.| File | Use |
|---|---|
model.onnx | ONNX graph (dynamic batch/width), opset 17 |
model.rten | Converted for the RTen runtime (rten-convert) |
dict.txt | alphabet, one char per line (blank is the implicit last class) |
1use gigapdf_ocr_rten::OcrEngine;
2// Drop model.rten + dict.txt into <models_dir>/latin_hw/, then call it EXPLICITLY:
3let eng = OcrEngine::load_models_dir("models")?;
4let lines = eng.recognize_page_handwriting(&rgb_image)?; // opt-in
5// or: eng.recognize_page_with(&rgb_image, gigapdf_ocr_rten::HANDWRITING_MODEL)?;