Metadata-Version: 2.4
Name: onnxocr
Version: 3.1.0
Summary: A lightweight OCR system based on PaddleOCR, running on ONNX Runtime without PaddlePaddle
Author-email: jingsongliujing <45508593+jingsongliujing@users.noreply.github.com>
Maintainer-email: KumaTea <KumaTea@outlook.com>
License-Expression: Apache-2.0
Project-URL: Homepage, https://github.com/jingsongliujing/OnnxOCR
Project-URL: Repository, https://github.com/jingsongliujing/OnnxOCR
Project-URL: Issues, https://github.com/jingsongliujing/OnnxOCR/issues
Project-URL: Packaging, https://github.com/KumaTea/OnnxOCR
Keywords: ocr,onnx,onnxruntime,paddleocr,ppocr,ppocrv5,text-detection,text-recognition
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Scientific/Engineering :: Image Recognition
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy
Requires-Dist: opencv-python-headless
Requires-Dist: pillow
Requires-Dist: onnxruntime
Requires-Dist: shapely
Requires-Dist: pyclipper
Requires-Dist: loguru
Requires-Dist: colorlog
Requires-Dist: omegaconf
Requires-Dist: requests
Requires-Dist: tqdm
Provides-Extra: pdf
Requires-Dist: pymupdf; extra == "pdf"
Requires-Dist: pdf2image; extra == "pdf"
Provides-Extra: qwen
Requires-Dist: onnxruntime>=1.26.0; extra == "qwen"
Requires-Dist: tokenizers; extra == "qwen"
Requires-Dist: json-repair; extra == "qwen"
Requires-Dist: modelscope; extra == "qwen"
Requires-Dist: huggingface-hub; extra == "qwen"
Provides-Extra: doc
Requires-Dist: magika; extra == "doc"
Requires-Dist: tokenizers; extra == "doc"
Requires-Dist: fast-langdetect; extra == "doc"
Requires-Dist: beautifulsoup4; extra == "doc"
Requires-Dist: pypdfium2; extra == "doc"
Requires-Dist: pypdf; extra == "doc"
Requires-Dist: pdfminer.six; extra == "doc"
Requires-Dist: pdftext; extra == "doc"
Requires-Dist: reportlab; extra == "doc"
Requires-Dist: pydantic; extra == "doc"
Requires-Dist: boto3; extra == "doc"
Requires-Dist: matplotlib; extra == "doc"
Provides-Extra: office
Requires-Dist: python-docx; extra == "office"
Requires-Dist: python-pptx; extra == "office"
Requires-Dist: openpyxl; extra == "office"
Requires-Dist: lxml; extra == "office"
Requires-Dist: mammoth; extra == "office"
Requires-Dist: markdown-it-py; extra == "office"
Requires-Dist: mdit-py-plugins; extra == "office"
Requires-Dist: pygments; extra == "office"
Requires-Dist: pylatexenc; extra == "office"
Requires-Dist: ftfy; extra == "office"
Requires-Dist: img2table; extra == "office"
Requires-Dist: polars; extra == "office"
Requires-Dist: scipy; extra == "office"
Requires-Dist: scikit-image; extra == "office"
Provides-Extra: all
Requires-Dist: onnxocr[doc,office,pdf,qwen]; extra == "all"
Dynamic: license-file

# OnnxOCR

Multilingual OCR that runs on ONNX Runtime alone

The upstream project is [jingsongliujing/OnnxOCR](https://github.com/jingsongliujing/OnnxOCR).

This package is built from
[KumaTea/OnnxOCR](https://github.com/KumaTea/OnnxOCR).

## Install

```shell
pip install onnxocr
```

Requires Python 3.11+. The PP-OCRv5 detection, angle-classification and recognition
models are bundled in the wheel (~41 MB).

Optional extras:

| Extra | Enables |
|---|---|
| `onnxocr[pdf]` | PDF input (`pymupdf`, `pdf2image`) |
| `onnxocr[qwen]` | Qwen3.5-2B ONNX information extraction |
| `onnxocr[doc]` | RapidDoc document → Markdown pipeline |
| `onnxocr[office]` | DOCX/PPTX/XLSX/HTML/LaTeX conversion for the doc pipeline |
| `onnxocr[all]` | everything above |

## Usage

```python
import cv2
from onnxocr.onnx_paddleocr import ONNXPaddleOcr

model = ONNXPaddleOcr(use_angle_cls=True, use_gpu=False)

img = cv2.imread("test.jpg")
result = model.ocr(img)

for box, (text, score) in result[0]:
    print(f"{score:.3f}  {text}")
```

Save an annotated image:

```python
from onnxocr.onnx_paddleocr import sav2Img

sav2Img(img, result, name="result.jpg")
```

Non-ASCII paths on Windows need `cv2.imdecode` rather than `cv2.imread`:

```python
import numpy as np
img = cv2.imdecode(np.fromfile(path, dtype=np.uint8), cv2.IMREAD_COLOR)
```

### Other modes

`ONNXPaddleOcr` also exposes license-plate, table and layout recognition via
`use_plate_recognition=True`, `use_table_recognition=True` and
`use_layout_analysis=True`.
Those models are not bundled — download them first:

```shell
python scripts/download_models.py --source huggingface
```

See the [upstream README](https://github.com/jingsongliujing/OnnxOCR#readme) for those
modes, the HTTP API service, the WebUI and Docker images.
