sumoocr 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- sumoocr-1.0.0/LICENSE +202 -0
- sumoocr-1.0.0/MANIFEST.in +1 -0
- sumoocr-1.0.0/NOTICE +10 -0
- sumoocr-1.0.0/PKG-INFO +239 -0
- sumoocr-1.0.0/README.md +235 -0
- sumoocr-1.0.0/examples/invoice.png +0 -0
- sumoocr-1.0.0/examples/ocr_page.py +11 -0
- sumoocr-1.0.0/pyproject.toml +51 -0
- sumoocr-1.0.0/setup.cfg +4 -0
- sumoocr-1.0.0/setup.py +25 -0
- sumoocr-1.0.0/sumoocr/__init__.py +11 -0
- sumoocr-1.0.0/sumoocr/backend.py +64 -0
- sumoocr-1.0.0/sumoocr/cli.py +34 -0
- sumoocr-1.0.0/sumoocr/det.py +132 -0
- sumoocr-1.0.0/sumoocr/models/config.json +7 -0
- sumoocr-1.0.0/sumoocr/models/det.onnx +0 -0
- sumoocr-1.0.0/sumoocr/models/rec.classes.json +1 -0
- sumoocr-1.0.0/sumoocr/models/rec.onnx +0 -0
- sumoocr-1.0.0/sumoocr/ocr.py +240 -0
- sumoocr-1.0.0/sumoocr/rec.py +135 -0
- sumoocr-1.0.0/sumoocr.egg-info/PKG-INFO +239 -0
- sumoocr-1.0.0/sumoocr.egg-info/SOURCES.txt +25 -0
- sumoocr-1.0.0/sumoocr.egg-info/dependency_links.txt +1 -0
- sumoocr-1.0.0/sumoocr.egg-info/entry_points.txt +2 -0
- sumoocr-1.0.0/sumoocr.egg-info/requires.txt +12 -0
- sumoocr-1.0.0/sumoocr.egg-info/top_level.txt +1 -0
- sumoocr-1.0.0/tests/test_sumoocr.py +62 -0
sumoocr-1.0.0/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright 2026 Docsumo
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
recursive-include examples *.png *.py
|
sumoocr-1.0.0/NOTICE
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
SumoOCR tiny
|
|
2
|
+
Copyright 2026 Docsumo
|
|
3
|
+
|
|
4
|
+
This product includes models from PaddleOCR (https://github.com/PaddlePaddle/PaddleOCR),
|
|
5
|
+
Copyright PaddlePaddle Authors, licensed under the Apache License, Version 2.0:
|
|
6
|
+
- sumoocr/models/det.onnx: derived from the PP-OCRv6 tiny text detection model (converted to
|
|
7
|
+
ONNX opset 20 with fused Gelu(tanh) and post-training INT8 QDQ quantization).
|
|
8
|
+
- sumoocr/models/rec.onnx: SumoOCR tiny, fine-tuned by Docsumo from the PP-OCRv6 tiny text
|
|
9
|
+
recognition model (its output layer reduced to 758 Latin-script characters, converted to ONNX
|
|
10
|
+
opset 20 with fused Gelu(tanh) and post-training INT8 QDQ quantization).
|
sumoocr-1.0.0/PKG-INFO
ADDED
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: sumoocr
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: SumoOCR tiny: a 1M-parameter CPU OCR pipeline for business documents in Latin-script languages
|
|
5
|
+
Author: Docsumo
|
|
6
|
+
License-Expression: Apache-2.0
|
|
7
|
+
Project-URL: Homepage, https://huggingface.co/docsumo/sumoOCR-tiny
|
|
8
|
+
Project-URL: Benchmark report, https://huggingface.co/docsumo/sumoOCR-tiny/blob/main/REPORT.md
|
|
9
|
+
Keywords: ocr,text-recognition,documents,invoices,receipts,onnx,cpu
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
17
|
+
Classifier: Operating System :: OS Independent
|
|
18
|
+
Classifier: Intended Audience :: Developers
|
|
19
|
+
Classifier: Topic :: Scientific/Engineering :: Image Recognition
|
|
20
|
+
Requires-Python: >=3.10
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
License-File: LICENSE
|
|
23
|
+
License-File: NOTICE
|
|
24
|
+
Requires-Dist: numpy>=1.23
|
|
25
|
+
Requires-Dist: opencv-python-headless>=4.8
|
|
26
|
+
Requires-Dist: onnxruntime>=1.18
|
|
27
|
+
Provides-Extra: openvino
|
|
28
|
+
Requires-Dist: openvino>=2024.0; extra == "openvino"
|
|
29
|
+
Provides-Extra: pil
|
|
30
|
+
Requires-Dist: pillow; extra == "pil"
|
|
31
|
+
Provides-Extra: test
|
|
32
|
+
Requires-Dist: pytest; extra == "test"
|
|
33
|
+
Dynamic: description
|
|
34
|
+
Dynamic: description-content-type
|
|
35
|
+
Dynamic: license-file
|
|
36
|
+
|
|
37
|
+
# SumoOCR tiny
|
|
38
|
+
|
|
39
|
+
**A 1M-parameter, 1.8 MB OCR pipeline for business documents in Latin-script languages, running on one CPU core.**
|
|
40
|
+
|
|
41
|
+

|
|
42
|
+
|
|
43
|
+
[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)
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
pip install sumoocr
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
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.
|
|
50
|
+
|
|
51
|
+
| | SumoOCR tiny |
|
|
52
|
+
|---|---|
|
|
53
|
+
| **Size** | 1.04M parameters, 1.8 MB (0.43M detector + 0.61M recognizer) |
|
|
54
|
+
| **Speed** | 0.28 s a page (3.55 pages per second) on one CPU core (Mac mini M4), whole pipeline |
|
|
55
|
+
| **Accuracy** (word F1) | FUNSD 83.8 · SROIE 91.3 · XFUND 95.2 · OmniDocBench (English) 91.9 |
|
|
56
|
+
| **Languages** | English and European Latin-script languages (German, French, Spanish, Italian, Portuguese, Dutch, Polish, Czech, Hungarian, Turkish, Romanian, Nordic) |
|
|
57
|
+
| **Runtime** | ONNX Runtime (default) or OpenVINO, CPU only; no PyTorch or PaddlePaddle needed |
|
|
58
|
+
| **License** | Apache-2.0, the same as PP-OCRv6 |
|
|
59
|
+
|
|
60
|
+
Compared with the other engines tested, on the same pages and one CPU thread:
|
|
61
|
+
|
|
62
|
+
- **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).
|
|
63
|
+
- **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.
|
|
64
|
+
|
|
65
|
+
Full numbers are in [Benchmarks](#benchmarks) and the [benchmark report](https://huggingface.co/docsumo/sumoOCR-tiny/blob/main/REPORT.md).
|
|
66
|
+
|
|
67
|
+
> 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.
|
|
68
|
+
|
|
69
|
+
Need checkbox and signature detection, more complex documents, or higher accuracy? Try [Docsumo](https://www.docsumo.com).
|
|
70
|
+
|
|
71
|
+

|
|
72
|
+
|
|
73
|
+
## Quickstart
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
pip install sumoocr # models included (1.8 MB); `pip install "sumoocr[openvino]"` for OpenVINO
|
|
77
|
+
sumoocr invoice.png # text, one line per line
|
|
78
|
+
sumoocr invoice.png --format json # lines with boxes and confidences
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### Python
|
|
82
|
+
|
|
83
|
+
```python
|
|
84
|
+
from sumoocr import SumoOCR
|
|
85
|
+
|
|
86
|
+
ocr = SumoOCR() # backend="openvino" for OpenVINO; threads=1 for one core
|
|
87
|
+
for line in ocr("invoice.png"): # a path, a BGR numpy array (cv2.imread) or a PIL image
|
|
88
|
+
print(line.text, round(line.conf, 3), line.box)
|
|
89
|
+
|
|
90
|
+
print(ocr.read_text("invoice.png")) # the page as text, in reading order
|
|
91
|
+
text, conf = ocr.read_line("line.png") # one text-line crop, no detection
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### ONNX only
|
|
95
|
+
|
|
96
|
+
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:
|
|
97
|
+
|
|
98
|
+
```python
|
|
99
|
+
import json
|
|
100
|
+
|
|
101
|
+
import cv2
|
|
102
|
+
import numpy as np
|
|
103
|
+
import onnxruntime as ort
|
|
104
|
+
|
|
105
|
+
sess = ort.InferenceSession("sumoocr/models/rec.onnx")
|
|
106
|
+
chars = json.load(open("sumoocr/models/rec.classes.json")) # index 0 = CTC blank
|
|
107
|
+
|
|
108
|
+
def read_line(bgr):
|
|
109
|
+
h, w = bgr.shape[:2]
|
|
110
|
+
x = cv2.resize(bgr, (max(4, round(w * 40 / h)), 40)).astype(np.float32)
|
|
111
|
+
x = ((x / 255.0 - 0.5) / 0.5).transpose(2, 0, 1)[None] # 1 x 3 x 40 x W, BGR
|
|
112
|
+
probs = sess.run(None, {"x": x})[0][0] # W/4 x 758
|
|
113
|
+
ids = probs.argmax(1)
|
|
114
|
+
keep = (ids != 0) & np.r_[True, ids[1:] != ids[:-1]] # greedy CTC
|
|
115
|
+
return "".join(chars[i] for i in ids[keep])
|
|
116
|
+
|
|
117
|
+
print(read_line(cv2.imread("line.png")))
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### Input
|
|
121
|
+
|
|
122
|
+
- 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`).
|
|
123
|
+
- Printed text in Latin script; pages turned by 90°, 180° or 270° are detected and turned back.
|
|
124
|
+
- Or one text-line crop (`read_line`).
|
|
125
|
+
|
|
126
|
+
### Output
|
|
127
|
+
|
|
128
|
+
| Field | What it is |
|
|
129
|
+
|---|---|
|
|
130
|
+
| `text` | the line's text |
|
|
131
|
+
| `conf` | mean character confidence, 0-1 (lines below 0.85 are dropped: `SumoOCR(text_score=...)`) |
|
|
132
|
+
| `box` | 4 [x, y] points, clockwise from the top-left, in pixels of the input image |
|
|
133
|
+
|
|
134
|
+
Lines come in reading order: top to bottom, left to right within a row.
|
|
135
|
+
|
|
136
|
+
## How it works
|
|
137
|
+
|
|
138
|
+
| Model | File | Role | Parameters |
|
|
139
|
+
|---|---|---|---|
|
|
140
|
+
| Text detector (PP-OCRv6 tiny, INT8 QDQ) | `sumoocr/models/det.onnx` | finds the text lines on the page | 0.43M |
|
|
141
|
+
| **SumoOCR tiny** (INT8 QDQ) | `sumoocr/models/rec.onnx` | reads each line: 40 px high, CTC over 758 characters (`rec.classes.json`) | 0.61M |
|
|
142
|
+
| **Total** | | | **1.04M** |
|
|
143
|
+
|
|
144
|
+
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.
|
|
145
|
+
|
|
146
|
+
## Benchmarks
|
|
147
|
+
|
|
148
|
+
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).
|
|
149
|
+
|
|
150
|
+
| System (CPU) | FUNSD | SROIE | XFUND | OmniDocBench (EN) | Business Docs | pages/s | License |
|
|
151
|
+
|---|---|---|---|---|---|---|---|
|
|
152
|
+
| **SumoOCR tiny** | 83.8 | 91.3 | 95.2 | **91.9** | 98.9 | **3.55** | Apache-2.0 |
|
|
153
|
+
| SumoOCR \* | **85.6** | **94.5** | **96.0** | 90.9 | **99.0** | 0.91 | not released |
|
|
154
|
+
| Paddle tiny rec (our pipeline) | 79.0 | 89.3 | 94.5 | 90.4 | 97.5 | 1.31 | Apache-2.0 |
|
|
155
|
+
| PaddleOCR tiny ¹ | 77.0 | 86.5 | 94.5 | 91.0 | 97.1 | 0.41 | Apache-2.0 |
|
|
156
|
+
| OCRia-nano-1 | 80.9 | 87.0 | 92.7 | 82.2 | 98.0 | 2.15 | OCRia-nano-1 licence |
|
|
157
|
+
| Indra 1.2.0 | 83.4 | 89.2 | 93.6 | 90.0 | 98.2 | 2.07 | modified OpenRAIL-M |
|
|
158
|
+
| Tesseract 5 | 61.9 | 75.0 | 90.7 | 90.2 | 92.3 | 1.07 | Apache-2.0 |
|
|
159
|
+
|
|
160
|
+
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.
|
|
161
|
+
|
|
162
|
+
\* SumoOCR is Docsumo's full OCR engine (not released). It also supports checkboxes, signatures and more complex documents.
|
|
163
|
+
|
|
164
|
+
### Line recognition only
|
|
165
|
+
|
|
166
|
+
The same ground-truth line crops for every recognizer (no detector): character error rate ↓, case and spaces ignored.
|
|
167
|
+
|
|
168
|
+
| Recognizer | SROIE CER ↓ | XFUND CER ↓ | FUNSD CER ↓ |
|
|
169
|
+
|---|---|---|---|
|
|
170
|
+
| SumoOCR tiny | 2.93 % | **1.77 %** | **4.26 %** |
|
|
171
|
+
| PP-OCRv6 tiny rec | **2.62 %** | 1.96 % | 5.38 % |
|
|
172
|
+
| Tesseract 5 (`--psm 7`) | 8.58 % | 9.86 % | 12.92 % |
|
|
173
|
+
|
|
174
|
+
## Speed
|
|
175
|
+
|
|
176
|
+
**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.
|
|
177
|
+
|
|
178
|
+
| Configuration | mean word F1 (4 benchmarks) | pages/s | ms per page, 1 core (mean / P90) | License |
|
|
179
|
+
|---|---|---|---|---|
|
|
180
|
+
| **SumoOCR tiny** | 90.6 | 3.55 | 281 / 546 | Apache-2.0 |
|
|
181
|
+
| OCRia-nano-1 | 85.7 | 2.15 | 464 / 734 | OCRia-nano-1 licence |
|
|
182
|
+
| Indra 1.2.0 | 89.0 | 2.07 | 484 / 857 | modified OpenRAIL-M |
|
|
183
|
+
| Paddle tiny rec (our pipeline) | 88.3 | 1.31 | 764 / 1,456 | Apache-2.0 |
|
|
184
|
+
| Tesseract 5 | 79.4 | 1.07 | 931 / 2,074 | Apache-2.0 |
|
|
185
|
+
| SumoOCR | 91.7 | 0.91 | 1,103 / 1,976 | not released |
|
|
186
|
+
| PaddleOCR 3.7, tiny (PP-OCRv6 tiny det + rec) ¹ | 87.3 | 0.41 | 2,444 / 4,527 | Apache-2.0 |
|
|
187
|
+
|
|
188
|
+
¹ 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.
|
|
189
|
+
|
|
190
|
+
## Training
|
|
191
|
+
|
|
192
|
+
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:
|
|
193
|
+
|
|
194
|
+
- **Docsumo's internal benchmark documents** (their training split).
|
|
195
|
+
- **Public government documents**: US federal publications (IRS, Federal Register, GovInfo, Census Bureau, CFPB, GSA, Federal Reserve) and EU documents from EUR-Lex.
|
|
196
|
+
- **Synthetic rendered text lines**, with sentences from Tatoeba.
|
|
197
|
+
|
|
198
|
+
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)).
|
|
199
|
+
|
|
200
|
+
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.
|
|
201
|
+
|
|
202
|
+
## Limitations
|
|
203
|
+
|
|
204
|
+
- **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.
|
|
205
|
+
- **Printed text.** Handwriting was not a training target and was not measured here.
|
|
206
|
+
- **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).
|
|
207
|
+
- **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).
|
|
208
|
+
- **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).
|
|
209
|
+
|
|
210
|
+
## Files
|
|
211
|
+
|
|
212
|
+
| File | What |
|
|
213
|
+
|---|---|
|
|
214
|
+
| `sumoocr/models/det.onnx` | text detector (PP-OCRv6 tiny, INT8 QDQ, opset-20 Gelu), 0.7 MB |
|
|
215
|
+
| `sumoocr/models/rec.onnx` | SumoOCR tiny recognizer (INT8 QDQ, opset-20 Gelu), 1.1 MB |
|
|
216
|
+
| `sumoocr/models/rec.classes.json` | the 758 output classes (0 = CTC blank, last = space) |
|
|
217
|
+
| `sumoocr/models/config.json` | input height and pre-processing of both models |
|
|
218
|
+
| `sumoocr/` | the Python package (`pip install sumoocr`) |
|
|
219
|
+
| `REPORT.md`, `charts/` | benchmark report |
|
|
220
|
+
| `LICENSE`, `NOTICE` | Apache-2.0; PaddleOCR attribution |
|
|
221
|
+
|
|
222
|
+
## License
|
|
223
|
+
|
|
224
|
+
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.
|
|
225
|
+
|
|
226
|
+
## Citation
|
|
227
|
+
|
|
228
|
+
```bibtex
|
|
229
|
+
@misc{sumoocrtiny2026,
|
|
230
|
+
title = {SumoOCR tiny: a 0.6M-parameter text-line recognizer for business documents},
|
|
231
|
+
author = {Docsumo},
|
|
232
|
+
year = {2026},
|
|
233
|
+
url = {https://huggingface.co/docsumo/sumoOCR-tiny}
|
|
234
|
+
}
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
---
|
|
238
|
+
|
|
239
|
+
Need checkbox and signature detection, more complex documents, or higher accuracy? Try [Docsumo](https://www.docsumo.com).
|