rlx-ocr
OCR engine for RLX — native compiled text detection + recognition graphs. Loads HuggingFace robertknight/ocrs weights as .safetensors and runs detection + recognition on every standard RLX backend. No Python and (on the default rlx feature) no RTen engine — host-side pad/resize plus RLX graphs.
Quick start
# Detection + recognition on a single image (models auto-resolved from --model-dir).
# or directly:
CLI flags: --model-dir DIR (expects ocr-*-full.safetensors) or both --detection-model PATH and --recognition-model PATH; --image PATH; --device cpu|metal|mlx|cuda|rocm|gpu|vulkan; --dry (skip inference). The rlx-ocr-convert bin (feature convert-rten) exports legacy .rten checkpoints to .safetensors.
Public API
use ;
use Device;
let runner = builder
.model_dir
.device
.build?;
let out: OcrOutput = runner.predict_path?;
println!;
// Or straight from decoded RGB bytes:
let text: String = runner.predict_text?;
# Ok
Lower-level entry points: OcrEngine / OcrEngineParams (detection + recognition pipeline), ocr_rgb_bytes, and prepare_image. Text geometry is returned as TextLine / TextWord / TextChar with RotatedRect boxes; CTC decoding lives in ctc.
Backends & features
| Feature | Enables |
|---|---|
rlx (default) |
Native RLX detection + recognition graphs + host pad/resize |
metal, mlx, cuda, rocm, gpu, vulkan |
Forwarded to rlx-runtime; all-backends builds one binary accepting all --device values |
blas-accelerate |
Apple Accelerate (AMX) CPU matmul/conv |
convert-rten |
rlx-ocr-convert — export .rten → .safetensors |
rten-inference / parity-ocrs |
Legacy RTen graph inference / upstream ocrs parity oracle (baseline + tests only) |
Tests & benches