skillfed

python-doctr

Document Text Recognition (docTR): deep Learning for high-performance OCR on documents.

python-doctr v1.0.1 340.7K downloads/30d#7,410 on PyPI6,258
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

python-doctr is a PyTorch-based OCR library that combines text detection and recognition models to extract structured text from documents. It reads PDFs and images, localizes each word, recognizes its characters, and returns a nested document structure (Page, Block, Line, Word) that can be exported as JSON or visualized. The library offers multiple architectures for both detection (DBNet, LinkNet, FAST) and recognition (CRNN, SAR, MASTER, ViTSTR, PARSeq, VIPTR), letting you choose speed versus accuracy trade-offs.

The package handles rotated pages and multi-orientation text through configurable options, supports a KIE (Key Information Extraction) predictor for multi-class detection, and includes utilities for document synthesis and interactive result visualization. It integrates with Hugging Face Hub for model distribution and includes a Streamlit demo app for local testing.

Use it for:

  • Extract text and bounding boxes from scanned invoices, receipts, or forms for downstream processing.
  • Build a document search index by OCR-ing a large PDF archive and exporting structured text.
  • Detect and extract specific fields (dates, addresses) from documents using the KIE predictor with a custom multi-class detector.
  • Automate data entry workflows by recognizing and localizing text in handwritten or printed documents.
  • Validate or correct OCR output by visualizing detected text regions and character predictions interactively.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

python-doctr extracts and localizes text from documents and images using a two-stage deep learning pipeline: text detection (finding word locations) followed by text recognition (identifying characters), with support for PDFs, images, and rotated pages.

Yes, if you need production-grade OCR with flexible model selection and don't mind the weight of torch and torchvision. The library is actively maintained, permissively licensed, and well-documented. Install only if you have a genuine OCR task; the dependency footprint is substantial but justified for deep learning work.

Install

python-doctr on PyPI

pip

pip install python-doctr

uv

uv add python-doctr

poetry

poetry add python-doctr

Installing python-doctr

Before you install

Low install friction with a pure-Python wheel. Requires 18 runtime dependencies including torch, torchvision, and opencv-python, which are substantial but standard for deep learning work. Repository is active with recent commits and 6258 stars, indicating ongoing maintenance.

License in practice

Apache License 2.0 is permissive: you can use, modify, and distribute python-doctr freely in commercial and private projects, provided you include a copy of the license and note any changes you make.

Quickstart

pip install python-doctr

from doctr.models import ocr_predictor
from doctr.io import DocumentFile

model = ocr_predictor(pretrained=True)
doc = DocumentFile.from_pdf("path/to/doc.pdf")
result = model(doc)
json_output = result.export()

Requires Python 3.10 or higher. torch and torchvision are heavy dependencies; GPU support is optional but recommended for performance.

Verify before relying

  • Inference speed and accuracy benchmarks on common document types and languages.
  • Memory footprint and whether models can run on resource-constrained environments.
  • How well the KIE predictor generalizes to custom document classes beyond the examples shown.

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 18 — torch, torchvision, onnx, numpy, scipy, h5py, opencv-python, pypdfium2, pyclipper, shapely, langdetect, rapidfuzz, huggingface-hub, Pillow, defusedxml, anyascii, validators, tqdm
Maintenance actively maintained — 191 days since the last release
Last repo commit
First released
Downloads 340,733/month — #7,410 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: python_doctr-1.0.1-py3-none-any.whl

Keywords: OCR, deep learning, computer vision, pytorch, text detection, text recognition

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 text extractiondocument text recognitiontext detection and recognitionPDF text extractiondeep learning OCRPyTorch OCRdocument image analysis
ocrdocument-processingcomputer-vision

More Artificial Intelligence packages