onnxtr
Onnx Text Recognition (OnnxTR): docTR Onnx-Wrapper for high-performance OCR on documents.
What it is and what it does
OnnxTR is an ONNX-based wrapper around the docTR library that performs optical character recognition on documents. It detects and recognizes text by localizing individual words within PDFs, images, and webpages, then returns structured output with nested document hierarchy (pages, blocks, lines, words). Unlike the base docTR library, OnnxTR avoids PyTorch and TensorFlow dependencies, instead using ONNX Runtime for inference, which reduces package size and enables deployment on resource-constrained environments.
The package supports multiple execution backends: CPU, CUDA (NVIDIA GPUs), OpenVINO (Intel CPUs and GPUs), and CoreML (Apple Silicon). It offers 8-bit quantized models for faster CPU inference and lower memory footprint. Output can be exported as nested dictionaries (JSON-compatible), human-readable text, or hOCR XML format. Configuration is granular—you can tune detection and recognition batch sizes, enable orientation and language detection, control page straightening, and adjust document parsing behavior.
Use it for:
- Extract text from scanned PDF documents for downstream NLP or search indexing
- Batch process images on CPU-only servers without GPU infrastructure
- Deploy OCR on edge devices or embedded systems with limited memory and compute
- Detect and recognize text in multi-page documents with automatic line and block grouping
- Export document structure as XML (hOCR) for archival or accessibility compliance
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
OnnxTR extracts and recognizes text from documents (PDFs, images, webpages) using ONNX-based deep learning models, localizing and identifying words without requiring PyTorch or TensorFlow.
Yes, if you need OCR without PyTorch/TensorFlow overhead and can target Python 3.10+. The low install friction, active maintenance, permissive license, and support for multiple hardware backends (CPU, GPU, Intel, Apple Silicon) make it a practical choice for document text extraction. No known security vulnerabilities. Consider it especially for resource-constrained deployments or when ONNX Runtime is already in your stack.
Install
onnxtr on PyPI
pip
pip install onnxtruv
uv add onnxtrpoetry
poetry add onnxtrInstalling onnxtr
Before you install
Low install friction; pure Python wheel with 11 runtime dependencies. Actively maintained with recent commits. Requires Python 3.10 or higher. Optional extras for GPU (CUDA), Intel (OpenVINO), and visualization support are available.
License in practice
Apache License 2.0 (permissive): you can use, modify, and distribute OnnxTR freely in commercial and private projects, provided you include the license and attribute the original work.
Quickstart
pip install "onnxtr[cpu]"
from onnxtr.io import DocumentFile
from onnxtr.models import ocr_predictor
model = ocr_predictor(det_arch='fast_base', reco_arch='vitstr_base')
doc = DocumentFile.from_pdf("path/to/doc.pdf")
result = model(doc)
json_output = result.export()
Requires Python 3.10 or higher. GPU support requires CUDA and cuDNN to be pre-installed separately.
Verify before relying
- Accuracy comparison with PyTorch/TensorFlow-based OCR pipelines on standard benchmarks
- Performance metrics (inference latency, memory usage) for 8-bit quantized models on typical hardware
- Whether weasyprint is required for webpage parsing or optional
Package facts
| License | Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for… (full text in the JSON record) (permissive) |
| Python support | supports the current Python release (<4,>=3.10.0) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 11 — numpy, scipy, pypdfium2, pyclipper, rapidfuzz, langdetect, huggingface-hub, Pillow, defusedxml, anyascii, tqdm |
| Maintenance | actively maintained — 191 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 102,258/month — #12,878 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: onnxtr-0.8.1-py3-none-any.whl
Keywords: OCR, deep learning, computer vision, onnx, text detection, text recognition, docTR, document analysis, document processing, document AI
Tags
More Artificial Intelligence packages
LiteLLM provides a unified Python interface to…
permissive · top 100 on PyPI
huggingface-hubClient library and CLI tool for downloading,…
permissive · top 100 on PyPI
langchainLangChain provides a framework for building…
permissive · top 1,000 on PyPI
hf-xethf-xet provides chunk-based deduplication and…
permissive · top 1,000 on PyPI
tokenizersTokenizers converts raw text into token…
permissive · top 1,000 on PyPI
transformersTransformers provides a unified framework for…
permissive · top 1,000 on PyPI
python-doctrpython-doctr extracts and localizes text from…
permissive · top 15,000 on PyPI
rapidocr-onnxruntimePerforms optical character recognition (OCR) on…
permissive · top 5,000 on PyPI
nudenetDetects nudity in images using lightweight ONNX…
permissive · top 15,000 on PyPI
paddleocrPaddleOCR extracts text, tables, and structured…
permissive · top 5,000 on PyPI
easyocrEasyOCR performs optical character recognition…
permissive · top 5,000 on PyPI
rapidocrRapidOCR extracts text from images using…
permissive · top 5,000 on PyPI
ddddocrRecognizes text and detects objects in captcha…
permissive · top 15,000 on PyPI
surya-ocrSurya is an OCR and document intelligence model…
permissive · top 5,000 on PyPI
keras-ocrkeras-ocr detects and recognizes text in images…
permissive · top 15,000 on PyPI
pyocrPyOCR wraps multiple OCR engines (Tesseract,…
copyleft · top 15,000 on PyPI