cnocr
Python3 package for Chinese/English OCR, with small pretrained models
What it is and what it does
CnOCR is a Python OCR toolkit that detects and recognizes text in images, supporting Chinese (simplified and traditional), English, and digits. It ships with 20+ pre-trained models tuned for different scenarios—scene photos, document scans, single-line text, and pure numbers—so you can use it immediately after installation without training. The package automatically calls its companion text-detection engine (CnSTD) to locate text regions before recognition, making it suitable for both simple layouts (like screenshots) and complex real-world scenes.
The library exposes a simple Python API (CnOcr class) and a command-line interface, plus an optional HTTP server for remote inference. It depends on PyTorch, torchvision, and related ML infrastructure (pytorch-lightning, wandb, torchmetrics), so installation pulls in a substantial ML stack. Model selection is configurable—you can swap detection and recognition models, specify language type for multilingual models, or use a lightweight rule-based detector for fast processing of simple documents.
Use it for:
- Extract text from screenshots, scanned documents, or book pages without training a custom model.
- Build a document digitization pipeline that handles mixed Chinese and English text with automatic language detection.
- Recognize pure-digit sequences (bank card numbers, ID codes) using specialized number-only models for higher accuracy.
- Process vertical or rotated text in images using multilingual PP-OCRv6 models.
- Deploy OCR as a microservice via the built-in HTTP endpoint for batch or real-time inference.
- Train custom OCR models on domain-specific data using the provided training CLI.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
CnOCR recognizes text in images—Chinese (simplified and traditional), English, and digits—using pre-trained deep learning models, with built-in text detection and support for both scene photos and document scans.
Yes, if you need Chinese OCR or multilingual text recognition. CnOCR is actively maintained, permissively licensed, and offers a low-friction installation with no compiled dependencies beyond standard ML libraries. The 20+ pre-trained models cover common scenarios (documents, scenes, numbers, vertical text), so most users can apply it without training. Trade-off: PyTorch and its ecosystem are large downloads; if you need only English OCR or have strict size constraints, lighter alternatives may be preferable.
Install
cnocr on PyPI
pip
pip install cnocruv
uv add cnocrpoetry
poetry add cnocrInstalling cnocr
Before you install
Low friction: pure Python wheel with no compiled dependencies beyond its runtime stack. Active maintenance—last commit 2026-07-05, 40 days since release. Requires PyTorch, torchvision, and related ML libraries, which are substantial downloads but standard for deep-learning packages.
License in practice
Apache 2.0 permissive license allows commercial and private use without restriction, modification, or redistribution obligations beyond attribution.
Quickstart
pip install cnocr[ort-cpu]
from cnocr import CnOcr
ocr = CnOcr()
result = ocr.ocr('./image.jpg')
print(result)
Requires Python 3.8 or higher. First-time PyTorch installation may encounter platform-specific issues (OpenCV, CUDA, etc.) that are common but require manual resolution.
Verify before relying
- Exact accuracy metrics or benchmarks against competing OCR systems are not provided in the fact sheet.
- Whether the package supports GPU acceleration via CUDA beyond the install-time choice (ort-cpu vs ort-gpu) is unclear.
- Performance characteristics (latency per image, throughput) are not documented in the excerpt.
Package facts
| License | Apache 2.0 (permissive) |
| Python support | supports the current Python release (>=3.8) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 12 — click, tqdm, torch, torchvision, numpy, pytorch-lightning, wandb, torchmetrics, pillow, onnx, cnstd, rapidocr |
| Maintenance | actively maintained — 40 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 136,800/month — #11,387 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: cnocr-2.3.3-py3-none-any.whl
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
cnstdDetects text and mathematical formulas in…
permissive · top 15,000 on PyPI
rapidocr-onnxruntimePerforms optical character recognition (OCR) on…
permissive · top 5,000 on PyPI
rapidocrRapidOCR extracts text from images using…
permissive · top 5,000 on PyPI
easyocrEasyOCR performs optical character recognition…
permissive · top 5,000 on PyPI
paddleocrPaddleOCR extracts text, tables, and structured…
permissive · top 5,000 on PyPI
paddlexPaddleX is a low-code framework for training,…
permissive · top 5,000 on PyPI
python-doctrpython-doctr extracts and localizes text from…
permissive · top 15,000 on PyPI
opencc-python-reimplementedConverts text between Simplified Chinese,…
permissive · top 5,000 on PyPI
ddddocrRecognizes text and detects objects in captcha…
permissive · top 15,000 on PyPI
zhconvConverts text between Simplified and…
copyleft · top 15,000 on PyPI