skillfed

cnocr

Python3 package for Chinese/English OCR, with small pretrained models

cnocr v2.3.3 136.8K downloads/30d#11,387 on PyPI3,766
Permissive license Apache 2.0 Active released

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 cnocr

uv

uv add cnocr

poetry

poetry add cnocr

Installing 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

Development Status :: 4 - BetaIntended Audience :: DevelopersLicense :: OSI Approved :: Apache Software LicenseOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Programming Language :: Python :: ImplementationTopic :: Scientific/Engineering :: Artificial Intelligence

Tags

chinese ocr text recognitionoptical character recognition pythonscene text detection and recognitiondocument image ocrchinese character recognitionmultilingual ocr enginetext extraction from images
ocr-text-recognitionchinese-nlpdocument-processing

More Artificial Intelligence packages