Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

TurboOCR engine for Python

The native engine bindings for TurboOCR — the fast C++/CUDA document parser. This package (import name turboocr_engine) is a thin nanobind wrapper over the C++ engine: detection, recognition, CTC decoding, warping, and layout all run in native code (CUDA / TensorRT / Metal / AVX2), driven from Python. It does not reimplement the pipeline in NumPy — you get the engine's real speed.

Most people install it through the pure-Python turboocr umbrella package, whose [cpu]/[apple]/[cuda]/[openvino]/[rocm] extras pin the right engine wheel and re-export the same API — import turboocr and import turboocr_engine then both work.

  • Fast setup by default. The default backend runs the ONNX graph on your GPU with no TensorRT engine build (CUDA on NVIDIA, CoreML/CPU on Apple, OpenVINO on Intel, DirectML on Windows, MLAS on CPU). TensorRT (peak throughput, slow first build) is one opt-in flag away: backend="turbo".
  • One install panel. turboocr doctor inspects your machine and tells you exactly which wheel to install for your GPU.
  • Layout, tables, PDF. Detected layout regions, PDFium-rendered PDFs, and Markdown/JSON/TSV/hOCR exports.

Install

One engine wheel per hardware target — install exactly one, they are mutually exclusive (each bakes a different ONNX Runtime execution provider into the same native extension). The umbrella extra on the left is the normal way in; the engine name on the right is what it pins:

Hardware Install Engine wheel
CPU — any x86-64 / ARM64 (the default) pip install "turboocr[cpu]" turboocr-engine-cpu
Apple Silicon — Metal + Neural Engine pip install "turboocr[apple]" turboocr-engine-cpu (its macOS arm64 build carries the full Apple backend)
NVIDIA GPU, driver R525+ pip install "turboocr[cuda12]" turboocr-engine-cuda12
NVIDIA GPU, driver R580+ pip install "turboocr[cuda13]" turboocr-engine-cuda13
Intel CPU / iGPU / Arc / NPU pip install "turboocr[openvino]" turboocr-engine-openvino
AMD GPU (ROCm) pip install "turboocr[rocm]" turboocr-engine-rocm

There is no separate Apple package: the macOS arm64 turboocr-engine-cpu wheel is built with the Apple backend and bundles the Metal shader library.

Feature extras work on any engine wheel (and combine with the umbrella's backend extras):

pip install "turboocr[cpu,pdf]"         # pypdfium2 + reportlab — read PDFs, write searchable PDFs
pip install "turboocr[cuda,pdf]"        # extras combine with any backend
pip install "turboocr-engine-cpu[all]"  # engine-only: pdf + rich + pandas

[pdf] reads PDFs and writes searchable ones, [rich] prettifies the turboocr doctor panel, [pandas] enables PageResult.to_pandas(), [all] is all three. turboocr doctor inspects the machine and prints the right install line for it.

Where to get them today

On PyPI: cpu and openvino. turboocr-engine-cpu (Linux, macOS with the Apple backend, Windows), turboocr-engine-openvino and the turboocr umbrella are published; because 4.0.0a5 is a pre-release, pip needs --pre or an exact pin to select it:

pip install --pre "turboocr[cpu]"       # or [apple] | [openvino]
pip install "turboocr[cpu]==4.0.0a5"    # equivalent, explicit

Not on PyPI yet: the NVIDIA wheels (-cuda12 / -cuda13) — built and verified, awaiting PyPI's file-size approval — and -rocm (deliberately unpublished until hardware-validated). For those, build from source (always current, matches this host exactly). Use the helper script — it builds and repairs the wheel:

# <variant> is one of: cpu | cuda12 | cuda13 | openvino | rocm
# (cpu builds turboocr-engine-cpu — also the Apple wheel on macOS arm64)
scripts/python/build_backend_wheel.sh cpu
pip install build-wheels/cpu/fixed/*.whl

A bare pip wheel python/ is not installable anywhere but the machine that built it — see Building from source for why, and for the manual delocate / auditwheel repair if you'd rather drive it by hand.

After installing, turboocr doctor reports the version and the provider it actually selected.

Usage

import turboocr_engine as turboocr   # or just `import turboocr` with the umbrella installed

ocr = turboocr.OCR()                       # tiny model, backend="auto" (fast-setup)
page = ocr.read("document.png")
print(page.text)                           # reading-order text
for line in page:                          # per-line detail
    print(line.confidence, line.text, line.box)

page.to_json(indent=2)                     # structured output
page.save_overlay("boxes.png")             # draw detected boxes
page.to_tsv(); page.to_hocr()              # exports
page.filter(min_confidence=0.9)            # keep confident lines

Language and accuracy tier:

turboocr.OCR(lang="en", tier="medium")     # Latin/CJK, most accurate tier
turboocr.OCR(lang="ko")                    # Korean script recognizer
turboocr.OCR(tier="small")                 # tiny | small | medium
turboocr.OCR("arabic")                     # explicit model always wins

Backend selection:

turboocr.OCR(backend="cuda")               # NVIDIA, ONNX on GPU (no build)
turboocr.OCR(backend="turbo")              # NVIDIA TensorRT (opt-in, cached)
turboocr.OCR(backend="cpu")                # force CPU
turboocr.OCR(backend="openvino", device="NPU")

NVIDIA (turboocr-engine-cuda12 / -cuda13) — what the first run costs. The wheel needs an NVIDIA driver at runtime. The CUDA, cuDNN and TensorRT runtimes are not bundled — the repair step excludes those sonames — so they come from the host toolkit, or from the matching pip packages, which the wheel finds automatically (pip install tensorrt-cu12-libs==10.15.1.29 nvidia-cuda-runtime-cu12 nvidia-nvjpeg-cu12, or the -cu13 equivalents; no LD_LIBRARY_PATH needed). They are not declared as dependencies of the engine wheel. It carries two NVIDIA paths:

  • backend="cuda" runs the ONNX graph on the CUDA execution provider. Nothing is compiled — start-up is instant, and steady-state speed is good. Pick it when you can't pay a one-time engine build.
  • backend="turbo" (aliases "tensorrt", "trt") — what backend="auto", the default, resolves to on these wheels — uses TensorRT for peak throughput. The first run builds an engine specialised to your GPU, driver and model — roughly ~90 s on an RTX 5090, up to an hour on older cards (TRT_OPT_LEVEL=3 cuts it 3–5x). That cost is paid once: the engine is written to TRT_ENGINE_CACHE (default ~/.cache/turbo-ocr) and later runs load it in a fraction of a second. Keep that directory persistent — mount it as a volume in containers. Changing GPU, driver, TensorRT or model correctly invalidates the cache and triggers one more build.

Both the server's native NVIDIA arm and these Python wheels default to TensorRT: the nvidia backend is compiled in, so backend="auto" resolves to "turbo" and the first run pays the engine build. Pass backend="cuda" for an instant first start on the CUDA execution provider.

Layout regions:

ocr = turboocr.OCR(layout=True)            # loads PP-DocLayoutV3
page = ocr.read("paper.png", layout=True)
for region in page.layout:
    print(region.label, region.score, region.box)   # text / table / figure / ...

PDF (needs the pdf extra — e.g. pip install "turboocr[cpu,pdf]"):

doc = ocr.read_pdf("paper.pdf", dpi=150)
print(doc.to_markdown())
for page in doc:
    print(page.page, len(page.lines))

Inputs: paths, raw bytes, NumPy arrays (BGR), and PIL images.

CLI

turboocr doctor                          # install panel for your hardware
turboocr models                          # list models
turboocr ocr image.png --lang en --tier medium
turboocr ocr *.png -f tsv -o out.tsv     # globs, formats, output file
turboocr ocr scan.png --overlay boxes.png --layout
turboocr pdf doc.pdf -f markdown -o doc.md

Formats: text (default), json, markdown, tsv, hocr.

Models

name tier / script
tiny (default) / small / medium PP-OCRv6 — Latin + Chinese + Japanese
arabic eslav korean thai greek retained PP-OCRv5 script recognizers

Weights resolve from an explicit models_dir=, TURBO_OCR_MODELS_DIR, a ./models folder, or an on-demand SHA256-verified download of just that tier from the pinned TurboOCR GitHub release (cached under ~/.cache/turboocr).

Backends

auto (default, best no-build EP) · turbo (TensorRT, NVIDIA) · cpu · cuda · openvino · directml · rocm/migraphx · coreml.

On Apple Silicon, auto uses CPU on purpose — for these SVTR/DBNet models the CoreML EP is typically slower than MLAS (and stumbles on dynamic shapes). Pass backend="coreml" to force it.

Building from source

For a development install — builds in place, only ever used on this machine:

cmake -S . -B build -DBUILD_PYTHON=ON -DUSE_CPU_ONLY=ON \
      -Dnanobind_DIR=$(python -m nanobind --cmake_dir)
cmake --build build --target _turboocr
pip install ./python

For a distributable wheel, use the helper — it builds and then repairs:

scripts/python/build_backend_wheel.sh <cpu|cuda|openvino|rocm>
pip install build-wheels/<variant>/fixed/*.whl

Why the repair step is mandatory

pip wheel python/ alone produces a wheel that works only on the machine that built it: it bundles zero shared libraries, and its RPATH points into your dev checkout, so it breaks the moment you move it elsewhere or delete build/. Making it self-contained is a separate repair pass that vendors the ~114 dylibs/shared objects it links (OpenCV, ONNX Runtime, PDFium, …). Never hand someone an unrepaired wheel.

The helper script does this for you. By hand it is:

# macOS
pip wheel python/ --no-deps -w dist/
pip install delocate && delocate-wheel -w dist/fixed -v dist/turboocr_engine_*.whl
pip install dist/fixed/turboocr_engine_*.whl

# Linux
pip wheel python/ --no-deps -w dist/
pip install auditwheel && auditwheel repair -w dist/fixed dist/turboocr_engine_*.whl
pip install dist/fixed/turboocr_engine_*.whl

The cuda and rocm variants need more than the plain command above: the driver/toolkit sonames (libcuda.so.1, libcudart, libcudnn, libnvinfer, libamdhip64, libmigraphx, …) must be excluded so they resolve from the host, as onnxruntime-gpu does; and CUDA needs a second pass, because ORT dlopens its provider libraries and auditwheel — which only follows DT_NEEDED — drops them silently. Both are already encoded in scripts/python/build_backend_wheel.sh; prefer it over reproducing them.

License

MIT (same as TurboOCR). The wheel bundles ONNX Runtime, OpenCV and PDFium under their respective licenses.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

turboocr_engine_cpu-4.0.0a5-cp312-abi3-win_amd64.whl (9.3 MB view details)

Uploaded CPython 3.12+Windows x86-64

turboocr_engine_cpu-4.0.0a5-cp312-abi3-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (20.2 MB view details)

Uploaded CPython 3.12+manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

turboocr_engine_cpu-4.0.0a5-cp312-abi3-macosx_14_0_arm64.whl (29.6 MB view details)

Uploaded CPython 3.12+macOS 14.0+ ARM64

File details

Details for the file turboocr_engine_cpu-4.0.0a5-cp312-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for turboocr_engine_cpu-4.0.0a5-cp312-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 3f0bb3d2699330e67f340a28de6b1ebbf689a2a6abd1a4f720377d578b5ba861
MD5 83a2f187e3d5b4b42cda3843d205b047
BLAKE2b-256 31431028bf30f46f0b2a73616e0cb78ad87e0781520ef254fe53c0afc77db6d3

See more details on using hashes here.

Provenance

The following attestation bundles were made for turboocr_engine_cpu-4.0.0a5-cp312-abi3-win_amd64.whl:

Publisher: wheels.yml on aiptimizer/TurboOCR

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file turboocr_engine_cpu-4.0.0a5-cp312-abi3-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for turboocr_engine_cpu-4.0.0a5-cp312-abi3-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 f69f6d94877f769c682bffabe94f53d77bf140fecdb51d7f80a019c0473d0a3a
MD5 89621f28905ca763d781b6229ef11d31
BLAKE2b-256 e22c4437ed6343dd88d2089b8e7d39009685aa3ba22e56ea0c8394c8ab0fb836

See more details on using hashes here.

Provenance

The following attestation bundles were made for turboocr_engine_cpu-4.0.0a5-cp312-abi3-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: wheels.yml on aiptimizer/TurboOCR

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file turboocr_engine_cpu-4.0.0a5-cp312-abi3-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for turboocr_engine_cpu-4.0.0a5-cp312-abi3-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 349737fb75b22cd76ded023a9cd2e3e7f1a981d52bef6b970dc05726d25589dd
MD5 fb91c5b9c2f2637a8f29ec3029e08b9d
BLAKE2b-256 e6249b30d9b52f95cc4e6d80435d535560f8315fc4bd26897fe7eda7345cad76

See more details on using hashes here.

Provenance

The following attestation bundles were made for turboocr_engine_cpu-4.0.0a5-cp312-abi3-macosx_14_0_arm64.whl:

Publisher: wheels.yml on aiptimizer/TurboOCR

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.
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