Metadata-Version: 2.4
Name: sumoocr
Version: 1.0.0
Summary: SumoOCR tiny: a 1M-parameter CPU OCR pipeline for business documents in Latin-script languages
Author: Docsumo
License-Expression: Apache-2.0
Project-URL: Homepage, https://huggingface.co/docsumo/sumoOCR-tiny
Project-URL: Benchmark report, https://huggingface.co/docsumo/sumoOCR-tiny/blob/main/REPORT.md
Keywords: ocr,text-recognition,documents,invoices,receipts,onnx,cpu
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.10
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: Operating System :: OS Independent
Classifier: Intended Audience :: Developers
Classifier: Topic :: Scientific/Engineering :: Image Recognition
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
License-File: NOTICE
Requires-Dist: numpy>=1.23
Requires-Dist: opencv-python-headless>=4.8
Requires-Dist: onnxruntime>=1.18
Provides-Extra: openvino
Requires-Dist: openvino>=2024.0; extra == "openvino"
Provides-Extra: pil
Requires-Dist: pillow; extra == "pil"
Provides-Extra: test
Requires-Dist: pytest; extra == "test"
Dynamic: description
Dynamic: description-content-type
Dynamic: license-file

# SumoOCR tiny

**A 1M-parameter, 1.8 MB OCR pipeline for business documents in Latin-script languages, running on one CPU core.**

![SumoOCR tiny: accuracy against speed on CPU](https://huggingface.co/docsumo/sumoOCR-tiny/resolve/main/charts/accuracy_vs_speed.svg)

[Benchmark report](https://huggingface.co/docsumo/sumoOCR-tiny/blob/main/REPORT.md) · [SumoOCR](https://www.docsumo.com/blog/introducing-sumoocr) · [PP-OCRv6 tiny (base)](https://huggingface.co/PaddlePaddle/PP-OCRv6_tiny_rec) · [Citation](#citation)

```bash
pip install sumoocr
```

SumoOCR tiny is a text-line recognizer from Docsumo: Paddle's PP-OCRv6 tiny recognizer fine-tuned on public and business documents. Together with the PP-OCRv6 tiny text detector included in the package, it makes a complete OCR pipeline, and it is the first reader in SumoOCR, Docsumo's OCR engine.

| | SumoOCR tiny |
|---|---|
| **Size** | 1.04M parameters, 1.8 MB (0.43M detector + 0.61M recognizer) |
| **Speed** | 0.28 s a page (3.55 pages per second) on one CPU core (Mac mini M4), whole pipeline |
| **Accuracy** (word F1) | FUNSD 83.8 · SROIE 91.3 · XFUND 95.2 · OmniDocBench (English) 91.9 |
| **Languages** | English and European Latin-script languages (German, French, Spanish, Italian, Portuguese, Dutch, Polish, Czech, Hungarian, Turkish, Romanian, Nordic) |
| **Runtime** | ONNX Runtime (default) or OpenVINO, CPU only; no PyTorch or PaddlePaddle needed |
| **License** | Apache-2.0, the same as PP-OCRv6 |

Compared with the other engines tested, on the same pages and one CPU thread:

- **More accurate** than the same-size PP-OCRv6 tiny recognizer, PaddleOCR's own tiny setting, OCRia-nano-1 and Tesseract on all four benchmarks, and than Indra on SROIE, XFUND and OmniDocBench (FUNSD is a statistical tie).
- **Faster** than every engine tested: 1.65x faster than OCRia-nano-1, 1.72x than Indra 1.2.0, 3.3x than Tesseract and 8.7x than PaddleOCR's tiny setting.

Full numbers are in [Benchmarks](#benchmarks) and the [benchmark report](https://huggingface.co/docsumo/sumoOCR-tiny/blob/main/REPORT.md).

> SumoOCR tiny reads **text lines**. For whole pages it runs after a text detector (see [How it works](#how-it-works)); it does not produce layout blocks, tables or reading order.

Need checkbox and signature detection, more complex documents, or higher accuracy? Try [Docsumo](https://www.docsumo.com).

![SumoOCR tiny: word F1 by benchmark](https://huggingface.co/docsumo/sumoOCR-tiny/resolve/main/charts/word_f1_by_benchmark.svg)

## Quickstart

```bash
pip install sumoocr              # models included (1.8 MB); `pip install "sumoocr[openvino]"` for OpenVINO
sumoocr invoice.png                # text, one line per line
sumoocr invoice.png --format json  # lines with boxes and confidences
```

### Python

```python
from sumoocr import SumoOCR

ocr = SumoOCR()                              # backend="openvino" for OpenVINO; threads=1 for one core
for line in ocr("invoice.png"):             # a path, a BGR numpy array (cv2.imread) or a PIL image
    print(line.text, round(line.conf, 3), line.box)

print(ocr.read_text("invoice.png"))          # the page as text, in reading order
text, conf = ocr.read_line("line.png")       # one text-line crop, no detection
```

### ONNX only

The two models are plain ONNX files in [`sumoocr/models/`](https://huggingface.co/docsumo/sumoOCR-tiny/tree/main/sumoocr/models): read a line crop without the package:

```python
import json

import cv2
import numpy as np
import onnxruntime as ort

sess = ort.InferenceSession("sumoocr/models/rec.onnx")
chars = json.load(open("sumoocr/models/rec.classes.json"))   # index 0 = CTC blank

def read_line(bgr):
    h, w = bgr.shape[:2]
    x = cv2.resize(bgr, (max(4, round(w * 40 / h)), 40)).astype(np.float32)
    x = ((x / 255.0 - 0.5) / 0.5).transpose(2, 0, 1)[None]   # 1 x 3 x 40 x W, BGR
    probs = sess.run(None, {"x": x})[0][0]                     # W/4 x 758
    ids = probs.argmax(1)
    keep = (ids != 0) & np.r_[True, ids[1:] != ids[:-1]]  # greedy CTC
    return "".join(chars[i] for i in ids[keep])

print(read_line(cv2.imread("line.png")))
```

### Input

- A page image (PNG, JPEG, TIFF, BMP, WebP; any size): the detector caps its long side at 1,280 px and automatically steps up to 2,400 px on dense small print such as newspapers (`adaptive=True`).
- Printed text in Latin script; pages turned by 90°, 180° or 270° are detected and turned back.
- Or one text-line crop (`read_line`).

### Output

| Field | What it is |
|---|---|
| `text` | the line's text |
| `conf` | mean character confidence, 0-1 (lines below 0.85 are dropped: `SumoOCR(text_score=...)`) |
| `box` | 4 [x, y] points, clockwise from the top-left, in pixels of the input image |

Lines come in reading order: top to bottom, left to right within a row.

## How it works

| Model | File | Role | Parameters |
|---|---|---|---|
| Text detector (PP-OCRv6 tiny, INT8 QDQ) | `sumoocr/models/det.onnx` | finds the text lines on the page | 0.43M |
| **SumoOCR tiny** (INT8 QDQ) | `sumoocr/models/rec.onnx` | reads each line: 40 px high, CTC over 758 characters (`rec.classes.json`) | 0.61M |
| **Total** |  |  | **1.04M** |

The page is scaled for the detector, its text boxes are cut out at full resolution and read one by one; a page whose lines read badly is tried upside down, and a page whose boxes stand on end is turned.

## Benchmarks

Word F1 (x 100) on whole pages, every engine on the same page images on CPU with one thread; bold = best in the column. Speed (pages/s) was measured on a Mac mini M4, 1 CPU core. Details, confidence intervals and the method: [benchmark report](https://huggingface.co/docsumo/sumoOCR-tiny/blob/main/REPORT.md).

| System (CPU) | FUNSD | SROIE | XFUND | OmniDocBench (EN) | Business Docs | pages/s | License |
|---|---|---|---|---|---|---|---|
| **SumoOCR tiny** | 83.8 | 91.3 | 95.2 | **91.9** | 98.9 | **3.55** | Apache-2.0 |
| SumoOCR \* | **85.6** | **94.5** | **96.0** | 90.9 | **99.0** | 0.91 | not released |
| Paddle tiny rec (our pipeline) | 79.0 | 89.3 | 94.5 | 90.4 | 97.5 | 1.31 | Apache-2.0 |
| PaddleOCR tiny ¹ | 77.0 | 86.5 | 94.5 | 91.0 | 97.1 | 0.41 | Apache-2.0 |
| OCRia-nano-1 | 80.9 | 87.0 | 92.7 | 82.2 | 98.0 | 2.15 | OCRia-nano-1 licence |
| Indra 1.2.0 | 83.4 | 89.2 | 93.6 | 90.0 | 98.2 | 2.07 | modified OpenRAIL-M |
| Tesseract 5 | 61.9 | 75.0 | 90.7 | 90.2 | 92.3 | 1.07 | Apache-2.0 |

FUNSD: 50 scanned forms. SROIE: 347 receipts. XFUND: 250 forms in German, Spanish, French, Italian and Portuguese. OmniDocBench: 755 English pages (papers, books, slides, magazines, newspapers). Business Docs: 41 public and synthetic business documents (invoices, statements, forms and US federal pages in 16 languages). "Paddle tiny rec (our pipeline)" is the PP-OCRv6 tiny recognizer SumoOCR tiny was fine-tuned from, run in the FP32 OpenVINO pipeline (see [Systems compared](https://huggingface.co/docsumo/sumoOCR-tiny/blob/main/REPORT.md#systems-compared)), not the shipped INT8 ONNX Runtime build with adaptive detection: its gap to SumoOCR tiny is the fine-tune plus those pipeline differences. The [line recognition table](#line-recognition-only) compares the two recognizers on the same crops. ¹ PaddleOCR 3.7 itself (Paddle's own package), its tiny setting: PP-OCRv6 tiny detector and recognizer. Timed natively, outside the container.

\* SumoOCR is Docsumo's full OCR engine (not released). It also supports checkboxes, signatures and more complex documents.

### Line recognition only

The same ground-truth line crops for every recognizer (no detector): character error rate ↓, case and spaces ignored.

| Recognizer | SROIE CER ↓ | XFUND CER ↓ | FUNSD CER ↓ |
|---|---|---|---|
| SumoOCR tiny | 2.93 % | **1.77 %** | **4.26 %** |
| PP-OCRv6 tiny rec | **2.62 %** | 1.96 % | 5.38 % |
| Tesseract 5 (`--psm 7`) | 8.58 % | 9.86 % | 12.92 % |

## Speed

**Hardware: Mac mini M4, 1 CPU core.** One process in a Docker container limited to 1 vCPU and 8 GB (`--cpus=1 --memory=8g`, Linux arm64), every engine on the same 100 pages (20 from each benchmark), taking turns page by page; whole pages, detection included.

| Configuration | mean word F1 (4 benchmarks) | pages/s | ms per page, 1 core (mean / P90) | License |
|---|---|---|---|---|
| **SumoOCR tiny** | 90.6 | 3.55 | 281 / 546 | Apache-2.0 |
| OCRia-nano-1 | 85.7 | 2.15 | 464 / 734 | OCRia-nano-1 licence |
| Indra 1.2.0 | 89.0 | 2.07 | 484 / 857 | modified OpenRAIL-M |
| Paddle tiny rec (our pipeline) | 88.3 | 1.31 | 764 / 1,456 | Apache-2.0 |
| Tesseract 5 | 79.4 | 1.07 | 931 / 2,074 | Apache-2.0 |
| SumoOCR | 91.7 | 0.91 | 1,103 / 1,976 | not released |
| PaddleOCR 3.7, tiny (PP-OCRv6 tiny det + rec) ¹ | 87.3 | 0.41 | 2,444 / 4,527 | Apache-2.0 |

¹ PaddleOCR was not run in the 1-vCPU container: it was timed natively on the same host, one thread (`cpu_threads=1`), 100 pages (8.7x the time of SumoOCR tiny run the same way on the same pages). Paddle's CPU kernels on ARM are much slower than its x86 path.

## Training

Fine-tuned from the PP-OCRv6 tiny recognizer (its output layer mapped to 758 Latin characters) on text-line crops (line heights 32-48 px) from business and public documents across diverse fonts and scan conditions, including:

- **Docsumo's internal benchmark documents** (their training split).
- **Public government documents**: US federal publications (IRS, Federal Register, GovInfo, Census Bureau, CFPB, GSA, Federal Reserve) and EU documents from EUR-Lex.
- **Synthetic rendered text lines**, with sentences from Tatoeba.

Only the model weights are released: no training document, crop or text is part of this repository. None of the four public benchmarks above (FUNSD, SROIE, XFUND, OmniDocBench) was used; 3 of the 41 Business Docs pages are public federal PDF pages that are also in the training set (see the [benchmark report](https://huggingface.co/docsumo/sumoOCR-tiny/blob/main/REPORT.md)).

Attribution. EUR-Lex documents: source EUR-Lex, © European Union, https://eur-lex.europa.eu. Synthetic sentences: Tatoeba (https://tatoeba.org), CC BY 2.0 FR.

## Limitations

- **Latin script only.** The 758 characters cover English and European Latin-script languages; Cyrillic, Greek, Arabic, Hebrew, Chinese, Japanese, Korean and Indic scripts are not recognized.
- **Printed text.** Handwriting was not a training target and was not measured here.
- **Lines, not documents.** It returns text lines with boxes and confidences: no layout blocks, tables, reading order or key-value structure (the benchmarks put every engine's lines in reading order with one shared routine).
- **Receipts and low-resolution scans are its weakest pages.** SROIE 91.3 and FUNSD 83.8 word F1, 3.1 and 1.8 points behind SumoOCR. On receipt line crops the base PP-OCRv6 tiny reads slightly better (2.62 % vs 2.93 % character errors).
- **Post-training INT8 quantization.** Both ONNX models use synthetic-calibrated INT8 QDQ quantization (keeping sensitive layers in FP32) for fast CPU inference at 1.8 MB total size; word F1 is within 0.2 points of FP32 on every benchmark (0.1 on the four-benchmark mean).

## Files

| File | What |
|---|---|
| `sumoocr/models/det.onnx` | text detector (PP-OCRv6 tiny, INT8 QDQ, opset-20 Gelu), 0.7 MB |
| `sumoocr/models/rec.onnx` | SumoOCR tiny recognizer (INT8 QDQ, opset-20 Gelu), 1.1 MB |
| `sumoocr/models/rec.classes.json` | the 758 output classes (0 = CTC blank, last = space) |
| `sumoocr/models/config.json` | input height and pre-processing of both models |
| `sumoocr/` | the Python package (`pip install sumoocr`) |
| `REPORT.md`, `charts/` | benchmark report |
| `LICENSE`, `NOTICE` | Apache-2.0; PaddleOCR attribution |

## License

Apache-2.0, the same licence as its base model, PP-OCRv6 tiny (PaddlePaddle); see `NOTICE`. The text detector is derived from the PP-OCRv6 tiny detector (Apache-2.0). ONNX Runtime (MIT) or OpenVINO (Apache-2.0) run the models.

## Citation

```bibtex
@misc{sumoocrtiny2026,
  title  = {SumoOCR tiny: a 0.6M-parameter text-line recognizer for business documents},
  author = {Docsumo},
  year   = {2026},
  url    = {https://huggingface.co/docsumo/sumoOCR-tiny}
}
```

---

Need checkbox and signature detection, more complex documents, or higher accuracy? Try [Docsumo](https://www.docsumo.com).
