OnnxOCR
Multilingual OCR that runs on ONNX Runtime alone
The upstream project is jingsongliujing/OnnxOCR.
This package is built from KumaTea/OnnxOCR.
Install
pip install onnxocr
Requires Python 3.11+. The PP-OCRv5 detection, angle-classification and recognition models are bundled in the wheel (~41 MB).
Optional extras:
| Extra | Enables |
|---|---|
onnxocr[pdf] |
PDF input (pymupdf, pdf2image) |
onnxocr[qwen] |
Qwen3.5-2B ONNX information extraction |
onnxocr[doc] |
RapidDoc document → Markdown pipeline |
onnxocr[office] |
DOCX/PPTX/XLSX/HTML/LaTeX conversion for the doc pipeline |
onnxocr[all] |
everything above |
Usage
import cv2
from onnxocr.onnx_paddleocr import ONNXPaddleOcr
model = ONNXPaddleOcr(use_angle_cls=True, use_gpu=False)
img = cv2.imread("test.jpg")
result = model.ocr(img)
for box, (text, score) in result[0]:
print(f"{score:.3f} {text}")
Save an annotated image:
from onnxocr.onnx_paddleocr import sav2Img
sav2Img(img, result, name="result.jpg")
Non-ASCII paths on Windows need cv2.imdecode rather than cv2.imread:
import numpy as np
img = cv2.imdecode(np.fromfile(path, dtype=np.uint8), cv2.IMREAD_COLOR)
Other modes
ONNXPaddleOcr also exposes license-plate, table and layout recognition via
use_plate_recognition=True, use_table_recognition=True and
use_layout_analysis=True.
Those models are not bundled — download them first:
python scripts/download_models.py --source huggingface
See the upstream README for those modes, the HTTP API service, the WebUI and Docker images.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file onnxocr-3.1.0.tar.gz.
File metadata
- Download URL: onnxocr-3.1.0.tar.gz
- Upload date:
- Size: 43.5 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.14.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b399e0aad42a104292533d6dc8ca5d284fd97375351be5d203c7d6769b7c03d6
|
|
| MD5 |
35343c777862f9f2b3260b2c478fe2ba
|
|
| BLAKE2b-256 |
d2a38621f4423100bd1114e7bd85ce15570c2088d8f77a896cc4f5eea21f77a6
|
File details
Details for the file onnxocr-3.1.0-py3-none-any.whl.
File metadata
- Download URL: onnxocr-3.1.0-py3-none-any.whl
- Upload date:
- Size: 43.3 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.14.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
186b3e141f0d0f7fc760f31bcc4551bda0c613e6c4d14f01a5603d9c6e823def
|
|
| MD5 |
247944d46efe7966573d93e639dca4e6
|
|
| BLAKE2b-256 |
1a8e5f3a2c1954d573259d77b4074ce02a991b4d20866f4637918166a9567420
|