ncnn-ocr
Production-ready Python OCR built on PaddleOCR PP-OCR Mobile models running on Tencent NCNN.
Standalone, publishable to PyPI, and independent of Qefro.
Features
- Fast CPU inference — NCNN-backed det + cls + rec pipeline (same engine as PaddleOCR-ncnn-CPP)
- PP-OCRv5 multilingual — Tamil, Arabic, Devanagari, Latin, Korean, Cyrillic, and more
- PP-OCRv6 profiles —
v6_tiny,v6_small,v6_medium - Simple API —
recognize(),recognize_text(),batch() - Auto model download — pulls weights from developerabu/pp-OCRv5-6-ncnn on first use
- Arabic post-processing — optional visual-order → logical-order fix
Install
From source (requires native deps)
# macOS (Homebrew)
brew install cmake opencv ncnn
# Debian/Ubuntu
sudo apt install cmake libopencv-dev libomp-dev
# Build ncnn if not packaged (see https://github.com/Tencent/ncnn)
export NCNN_DIR=$HOME/.local/ncnn # optional, CMake searches common paths
pip install .
Python dependencies only (no extension)
Pure-Python modules import without the _ncnn_ocr extension; OCR() raises a clear error until the native module is built.
Quick start
from ncnn_ocr import OCR
ocr = OCR(lang="ta")
text = ocr.recognize_text("page.png")
print(text)
lines = ocr.recognize("page.png")
for line in lines:
print(line.text, line.confidence, line.box)
One-shot helpers:
from ncnn_ocr import recognize_text
print(recognize_text("scan.jpg", lang="en"))
Supported languages (PP-OCRv5)
| Code | Script / language |
|---|---|
en |
English |
ta, te |
Tamil, Telugu |
hi, mr, ne |
Devanagari |
ar, fa, ur |
Arabic |
ko, th, el |
Korean, Thai, Greek |
ru, uk, bg |
Cyrillic / Slavic |
de, fr, es, latin |
Latin |
ch, zh |
Chinese (generic v5 rec) |
from ncnn_ocr import supported_langs
print(supported_langs())
PP-OCRv6
ocr = OCR(lang="en", profile="v6_tiny")
text = ocr.recognize_text("page.png")
Profiles: v6_tiny, v6_small, v6_medium.
Environment variables
| Variable | Default | Description |
|---|---|---|
NCNN_OCR_MODEL_DIR |
~/.cache/ncnn-ocr/models |
Local model cache |
NCNN_OCR_HF_REPO |
developerabu/pp-OCRv5-6-ncnn |
HuggingFace model repo |
Build layout
py-ocr-ncnn/
├── src/ncnn_ocr/ # Python package
├── native/
│ ├── bindings.cpp # pybind11 wrapper
│ └── paddleocr/ # vendored NCNN OCR engine (Apache-2.0)
├── CMakeLists.txt
└── pyproject.toml
Models
On first run, recognition models and keys are downloaded from HuggingFace. Shared PP-OCRv5 detection and angle-classifier weights are fetched from HuggingFace when available, otherwise from the PaddleOCR-ncnn-CPP v0.3.0 archive.
Development
python -m venv .venv && source .venv/bin/activate
pip install -e ".[dev]"
PYTHONPATH=src pytest -q
License
Apache-2.0 — see LICENSE. The vendored PaddleOCR-ncnn-CPP sources retain their original license.
Credits
- Avafly/PaddleOCR-ncnn-CPP — NCNN OCR engine
- PaddleOCR — PP-OCR models
- Tencent NCNN — inference framework
Metadata
Release files for ncnn-ocr 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| ncnn_ocr-0.1.1.tar.gz | 252.4 kB | Without provenance | Details for ncnn_ocr-0.1.1.tar.gz |
Built distributions (wheels)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ncnn_ocr-0.1.1-cp312-cp312-manylinux_2_39_x86_64.whl | CPython 3.12 | CPython 3.12 | Linux glibc 2.39+ x86-64 | Details for ncnn_ocr-0.1.1-cp312-cp312-manylinux_2_39_x86_64.whl |
| ncnn_ocr-0.1.1-cp312-cp312-macosx_14_0_arm64.whl | CPython 3.12 | CPython 3.12 | macOS 14.0+ ARM64 | Details for ncnn_ocr-0.1.1-cp312-cp312-macosx_14_0_arm64.whl |
Total release size: 68.8 MB
Release files / ncnn_ocr-0.1.1.tar.gz
| Download URL | ncnn_ocr-0.1.1.tar.gz |
|---|---|
| Size | 252.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
515ffde7cebacb35a027eb5335328df55b4203bca6e19e5b3173d836bcec3ac3
|
|
BLAKE2b-256 checksum How to use checksums |
2d5f6d855cab51689081b408f02973eba5c7d2a01231517cbd2b1a7902eb9a05
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.14
|
Release files / ncnn_ocr-0.1.1-cp312-cp312-manylinux_2_39_x86_64.whl
| Download URL | ncnn_ocr-0.1.1-cp312-cp312-manylinux_2_39_x86_64.whl |
|---|---|
| Size | 68.4 MB |
| Tags | CPython 3.12 Linux glibc 2.39+ x86-64 |
|
SHA-256 checksum How to use checksums |
b821301023e69c8e00f2f299df9b5e7bff50877a568e5ae6f4981d99c669fd33
|
|
BLAKE2b-256 checksum How to use checksums |
8df8223456db0e46df2edd69b11da97e3b605590acb26fc12034cf719d35e382
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.14
|
Release files / ncnn_ocr-0.1.1-cp312-cp312-macosx_14_0_arm64.whl
| Download URL | ncnn_ocr-0.1.1-cp312-cp312-macosx_14_0_arm64.whl |
|---|---|
| Size | 174.9 kB |
| Tags | CPython 3.12 macOS 14.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
3e8b14825d786db143c99000abb84047b3a20d098a78953a0bbe1d62ac14b36f
|
|
BLAKE2b-256 checksum How to use checksums |
4e7b0a88ec9ef69c5586c47ced0a8d2b986347f604abc388c8c84443d5739763
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.14
|
Security for ncnn-ocr 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.