skillfed

onnxtr

Onnx Text Recognition (OnnxTR): docTR Onnx-Wrapper for high-performance OCR on documents.

onnxtr v0.8.1 102.3K downloads/30d#12,878 on PyPI193
Permissive 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) Active released

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 onnxtr

uv

uv add onnxtr

poetry

poetry add onnxtr

Installing 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

Development Status :: 4 - BetaIntended Audience :: DevelopersIntended Audience :: EducationIntended Audience :: Science/ResearchLicense :: OSI Approved :: Apache Software LicenseNatural Language :: EnglishOperating System :: OS IndependentProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Topic :: Scientific/Engineering :: Artificial Intelligence

Tags

OCR document text extractiononnx text recognitionpdf text detection and recognitionlightweight document analysiscpu-friendly ocr modelsdoctr onnx wrapperdocument ai processing
ocrdocument-processingonnx-inference

More Artificial Intelligence packages