Skip to main content

OnnxOCR

Multilingual OCR that runs on ONNX Runtime alone

The upstream project is jingsongliujing/OnnxOCR.

This package is built from KumaTea/OnnxOCR.

Release lines

Each major version is one model generation:

Version Models Built from
4.x PP-OCRv6 small (default) and tiny, plus PP-OCRv5 upstream ppocrv6 branch
3.x PP-OCRv5 upstream main
2.x PP-OCRv5 (default) and PP-OCRv4, 2025 code upstream, June 2025 (was 2025.5)
1.x PP-OCRv4 upstream, May 2025

To stay on one generation, pin the major version, e.g. pip install "onnxocr<4".

Install

pip install onnxocr

Requires Python 3.11+. The wheel (~75 MB) bundles the PP-OCRv6 small and tiny detection and recognition models, the PP-OCRv5 models and the angle classifier.

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)

Model size

PP-OCRv6 comes in three sizes. This package defaults to small; upstream defaults to medium.

ocr_model_size Bundled CPU speed vs PP-OCRv5
"tiny" yes ~2× faster, weaker on Japanese and Latin text
"small" (default) yes similar
"medium" no: ~140 MB, over PyPI's file size limit ~4× slower
model = ONNXPaddleOcr(ocr_model_size="tiny")

To use medium, download and extract PP-OCRv6_medium_det and PP-OCRv6_medium_rec from PaddleX, then pass their paths:

model = ONNXPaddleOcr(
    ocr_model_size="medium",
    det_model_dir="PP-OCRv6_medium_det_onnx_infer/inference.onnx",
    rec_model_dir="PP-OCRv6_medium_rec_onnx_infer/inference.onnx",
)

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.

Metadata

Release files for onnxocr 4.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for onnxocr 4.0.0
File Size Uploaded
onnxocr-4.0.0.tar.gz 75.4 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for onnxocr 4.0.0
File Interpreter ABI Platform
onnxocr-4.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 150.6 MB

Release files / onnxocr-4.0.0.tar.gz

Download URL onnxocr-4.0.0.tar.gz
Size 75.4 MB
Tags Source
SHA-256 checksum
How to use checksums
f371bd015422839c2b34b7185194b3996fbe8557db4cd5d38b0ff3464d65a06b
BLAKE2b-256 checksum
How to use checksums
4b027b6d2aa98beed21a9199b678da0d9cd8b78009af9fce36d277d45994dc66
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.7

Release files / onnxocr-4.0.0-py3-none-any.whl

Download URL onnxocr-4.0.0-py3-none-any.whl
Size 75.2 MB
Tags Python 3
SHA-256 checksum
How to use checksums
71c570a347ec688cd47dbc400c77e9abcbd3f48e497519234e0f5ce575c5845b
BLAKE2b-256 checksum
How to use checksums
92fdbe4ce649c5fb4a59c028e4f5365bcb679e16abbc4da41baa4588e70a0ccd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.7

Release history Release notifications | RSS feed

This release

4.0.0 This release

2 release files

3.1.1

2 release files

3.1.0

2 release files

2.0.0

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page