OAR-OCR
An Optical Character Recognition (OCR) and Document Layout Analysis library written in Rust.
Quick Start
Installation
With GPU support:
With auto-download of model files from ModelScope:
Bare file names passed to the builders are then fetched from ModelScope into $OAR_HOME (default ~/.oar) and verified against their expected SHA-256. See docs/models.md for the exact path resolution rules.
Basic Usage
use *;
use Path;
PP-OCRv6
PP-OCRv6 ships in three sizes. Pass the bare file names below and enable the auto-download feature to fetch them automatically or point to local paths:
| Size | Detection | Recognition | Dictionary |
|---|---|---|---|
| tiny | pp-ocrv6_tiny_det.onnx |
pp-ocrv6_tiny_rec.onnx |
ppocrv6_tiny_dict.txt |
| small | pp-ocrv6_small_det.onnx |
pp-ocrv6_small_rec.onnx |
ppocrv6_dict.txt |
| medium | pp-ocrv6_medium_det.onnx |
pp-ocrv6_medium_rec.onnx |
ppocrv6_dict.txt |
use *;
use TextDetectionConfig;
use Path;
Document Structure Analysis
use *;
use Path;
Vision-Language Models (VLM)
For advanced document understanding using Vision-Language Models (like PaddleOCR-VL, PaddleOCR-VL-1.5, PaddleOCR-VL-1.6, GLM-OCR, HunyuanOCR, and MinerU2.5), check out the oar-ocr-vl crate.
Documentation
- Usage Guide - Detailed API usage, builder patterns, GPU configuration
- Pre-trained Models - Model download links and recommended configurations
- Environment Variables - Runtime configuration via
OAR_*variables
Examples
The examples/ directory contains complete examples for various tasks:
# General OCR
# Document Structure Analysis
# Layout Detection
# Table Structure Recognition
Acknowledgments
This project builds upon the excellent work of several open-source projects:
-
ort: Rust bindings for ONNX Runtime by pykeio. This crate provides the Rust interface to ONNX Runtime that powers the efficient inference engine in this OCR library.
-
PaddleOCR: Baidu's awesome multilingual OCR toolkits based on PaddlePaddle. This project utilizes PaddleOCR's pre-trained models, which provide excellent accuracy and performance for text detection and recognition across multiple languages.
-
Candle: A minimalist ML framework for Rust by Hugging Face. We use Candle to implement Vision-Language model inference.