indra-ocr 0.3.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.
@@ -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 [yyyy] [name of copyright owner]
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,305 @@
1
+ Metadata-Version: 2.4
2
+ Name: indra-ocr
3
+ Version: 0.3.0
4
+ Summary: Fast CPU OCR: line detection, CTC recognition, reading order and markdown, on ONNX Runtime
5
+ License-Expression: Apache-2.0
6
+ Requires-Python: >=3.10
7
+ Description-Content-Type: text/markdown
8
+ License-File: LICENSE
9
+ Requires-Dist: numpy
10
+ Requires-Dist: opencv-python-headless
11
+ Requires-Dist: onnxruntime
12
+ Requires-Dist: pypdfium2
13
+ Requires-Dist: huggingface_hub
14
+ Provides-Extra: tesseract
15
+ Requires-Dist: pytesseract; extra == "tesseract"
16
+ Provides-Extra: test
17
+ Requires-Dist: pytest; extra == "test"
18
+ Requires-Dist: pillow; extra == "test"
19
+ Requires-Dist: pikepdf; extra == "test"
20
+ Dynamic: license-file
21
+
22
+ <p align="center">
23
+ <img src="assets/datalab-logo.png" alt="Datalab Logo" width="150"/>
24
+ </p>
25
+ <h1 align="center">Datalab</h1>
26
+ <p align="center">
27
+ <strong>State of the Art models for Document Intelligence</strong>
28
+ </p>
29
+ <p align="center">
30
+ <a href="https://opensource.org/licenses/Apache-2.0"><img src="https://img.shields.io/badge/Code%20License-Apache_2.0-green.svg" alt="Code License"></a>
31
+ <a href="https://www.datalab.to/pricing"><img src="https://img.shields.io/badge/Model%20License-OpenRAIL--M-blue.svg" alt="Model License"></a>
32
+ <a href="https://discord.gg/KuZwXNGnfH"><img src="https://img.shields.io/badge/Discord-Join%20us-5865F2?logo=discord&logoColor=white" alt="Discord"></a>
33
+ <a href="https://huggingface.co/datalab-to/indra-ocr"><img src="https://img.shields.io/badge/Models-Hugging%20Face-yellow" alt="Models"></a>
34
+ </p>
35
+ <p align="center">
36
+ <a href="https://www.datalab.to"><img src="https://img.shields.io/badge/Homepage-datalab.to-blue" alt="Homepage"></a>
37
+ <a href="https://documentation.datalab.to"><img src="https://img.shields.io/badge/Docs-Read%20the%20docs-blue" alt="Docs"></a>
38
+ <a href="https://www.datalab.to/playground"><img src="https://img.shields.io/badge/Datalab%20Playground-Try%20it-orange" alt="Datalab Playground"></a>
39
+ </p>
40
+
41
+ <hr/>
42
+
43
+ # Indra OCR
44
+
45
+ Indra OCR is a 1M-parameter OCR model that reads up to 49 pages per second CPU. It turns PDFs and images into markdown, plain text, or JSON with boxes, and it has these features:
46
+
47
+ - Throughput - 49 pages/s, 11-17x faster than Tesseract and PaddleOCR on the same machine and pages ([table](#throughput))
48
+ - Latency - ~230 ms per page on 4 x86 vCPUs, 12-24x faster than Tesseract and PaddleOCR
49
+ - Accuracy - scores 41.3 on [OmniParseBench](https://github.com/datalab-to/omni_parse_bench) text, ahead of PaddleOCR's PP-OCR text models (35.8) and Tesseract (19.3). Its headline score (62.1) beats PaddleOCR's full PP-StructureV3 pipeline (58.4).
50
+ - Layout and boxes - a bounding box for every line and every layout block, with block labels (headings, lists, tables, captions, footnotes, page headers) and reading order
51
+ - Digital PDFs - reads the PDF's own text layer in any script, and OCRs only what is missing
52
+ - Small - about 18 MB of models on ONNX Runtime, no PyTorch
53
+
54
+ The main recognizer, `rec.onnx`, has about 1M parameters. See [benchmarks](#benchmarks) for the full results and [limitations](#limitations) for what it does not do yet.
55
+
56
+ Indra OCR is named for [Indra](https://en.wikipedia.org/wiki/Indra).
57
+
58
+ <img src="assets/benchmarks/throughput.png" width="700px"/>
59
+
60
+ ## Try Datalab's Managed Platform
61
+
62
+ Indra OCR is built for speed on CPUs. When you need the highest accuracy, on handwriting, math, complex tables and degraded scans, our managed platform runs [Chandra](https://github.com/datalab-to/chandra), our state of the art OCR model, with zero data retention by default, SOC 2 Type 2, and custom BAAs.
63
+
64
+ If you have high volume workloads, we offer a batch processing service that can handle 1B+ pages a day.
65
+
66
+ Get started with **$5 in free credits** - [sign up](https://www.datalab.to/?utm_source=gh-indra) - or try Chandra in our [public playground](https://www.datalab.to/playground?utm_source=gh-indra).
67
+
68
+ ## Quickstart
69
+
70
+ ```shell
71
+ pip install git+https://github.com/datalab-to/indra.git
72
+
73
+ indra-ocr paper.pdf # markdown to stdout
74
+ indra-ocr *.pdf --out results/ # one .md per input, all cores
75
+ indra-ocr scan.png --format json # lines, boxes, layout blocks, confidences
76
+
77
+ indra-ocr-viewer # local web viewer on http://localhost:8765
78
+ ```
79
+
80
+ The first run downloads the models (about 18 MB) from [Hugging Face](https://huggingface.co/datalab-to/indra-ocr).
81
+
82
+ ## Examples
83
+
84
+ Real Indra OCR outputs on OmniParseBench pages. Colored boxes are layout blocks with their label, faint blue boxes are lines, drawn from the JSON output with no edits.
85
+
86
+ <table>
87
+ <tr>
88
+ <td width="50%"><img src="assets/examples/rotated_letter.png"/><br/><sub>Scanned upside down: Indra OCR turns the page upright, reads both columns in order and finds the headings.</sub></td>
89
+ <td width="50%"><img src="assets/examples/table_pmc.png"/><br/><sub>A journal page with two tables, output as HTML with their captions.</sub></td>
90
+ </tr>
91
+ </table>
92
+
93
+ **[See more examples, with the markdown output for each →](EXAMPLES.md)**
94
+
95
+
96
+ # License
97
+
98
+ The code is [Apache 2.0](LICENSE). The model weights use a modified OpenRAIL-M license ([LICENSE](https://huggingface.co/datalab-to/indra-ocr/blob/main/LICENSE)).
99
+
100
+ # Commercial usage
101
+
102
+ This code is Apache 2.0, and our model weights use a modified OpenRAIL-M license (free for research, personal use, and startups under $20M funding/revenue, cannot be used competitively with our API). To remove the OpenRAIL license requirements, or for broader commercial licensing, visit our pricing page [here](https://www.datalab.to/pricing?utm_source=gh-indra).
103
+
104
+ # Installation
105
+
106
+ ```shell
107
+ pip install git+https://github.com/datalab-to/indra.git
108
+ ```
109
+
110
+ Python 3.10 or newer. It installs ONNX Runtime, OpenCV and pypdfium2, and no PyTorch. The models download from Hugging Face on the first run and are cached. To use a local copy, set `INDRA_OCR_MODEL_DIR` or pass `--model-dir`.
111
+
112
+ # Usage
113
+
114
+ ## CLI
115
+
116
+ ```shell
117
+ indra-ocr paper.pdf # markdown to stdout
118
+ indra-ocr *.pdf --out results/ # one .md per input
119
+ indra-ocr scan.png --format json # lines, boxes, layout blocks, confidences, timings
120
+ indra-ocr paper.pdf --format text # plain text, one line per detected line
121
+ indra-ocr paper.pdf --mode ocr --timings # ignore the text layer, OCR every page; timings on stderr
122
+ indra-ocr paper.pdf --keep-furniture # keep page headers and footers in the markdown
123
+ indra-ocr *.pdf --out results/ --cores 8 # limit the cores (default: all usable cores)
124
+ indra-ocr paper.pdf --math # write math as LaTeX (off by default; slower on math pages)
125
+ ```
126
+
127
+ **CLI Options:**
128
+ - `--out DIR`: write one file per input (`.md`, `.txt` or `.jsonl`)
129
+ - `--format [md|text|json]`: output format (default: md)
130
+ - `--mode [auto|ocr|text]`: `auto` reads the text layer where it passes the checks and OCRs elsewhere (default). `ocr` never reads the text layer. `text` uses the text layer even when the checks fail
131
+ - `--model-order`: order text-layer lines with the order model, not the PDF content order
132
+ - `--no-image-ocr`: on text-layer pages, do not OCR text inside images
133
+ - `--cores N`: cores to use, one worker process each (default: all usable cores)
134
+ - `--dpi`: render resolution for PDFs (default: 200)
135
+ - `--max-pages N`: read at most N pages per file
136
+ - `--password`: password for encrypted PDFs
137
+ - `--keep-furniture`: keep page headers and footers in the markdown
138
+ - `--math`: write math as LaTeX (`$...$`); off by default, see [Math](#math)
139
+ - `--timings`: print per-page source and time to stderr
140
+ - `--model-dir`: folder with the models (default: download)
141
+
142
+ The CLI continues past files it cannot read, and exits with 1 if any failed.
143
+
144
+ ## From python
145
+
146
+ ```python
147
+ import indra_ocr
148
+
149
+ conv = indra_ocr.load(threads=4) # mode="auto" | "ocr" | "text"
150
+ for i, page in conv.convert("paper.pdf"):
151
+ print(page.source, page.timings["total_ms"])
152
+ print(page.markdown) # headings, lists, tables as HTML
153
+ page.blocks # [{"label", "bbox", "text"}] in reading order
154
+ page.lines # [Line(box, text, conf)] in reading order
155
+ ```
156
+
157
+ For many pages or files, `convert_many` runs one single-threaded worker process per core, one page per task, and returns results in input order:
158
+
159
+ ```python
160
+ import indra_ocr
161
+
162
+ if __name__ == "__main__": # worker processes re-import this file
163
+ for path, result in indra_ocr.convert_many(["a.pdf", "b.pdf"], cores=None):
164
+ if isinstance(result, indra_ocr.InputError):
165
+ continue # unreadable or locked file
166
+ for i, page in result:
167
+ print(path, i, page.source)
168
+ ```
169
+
170
+ Without the `if __name__ == "__main__":` guard (needed on macOS and Windows), `convert_many` warns and reads everything in one process.
171
+
172
+ `indra_ocr.load` takes `path` (model folder), `threads`, `dpi`, `mode`, `pdf_order`, `image_ocr`, `furniture` and `math`. `conv.convert` takes `max_pages` and `password`.
173
+
174
+ ## Viewer
175
+
176
+ ```shell
177
+ indra-ocr-viewer --port 8765 # open http://localhost:8765
178
+ ```
179
+
180
+ A local web viewer: drop in a PDF or an image, and each page shows its lines, layout blocks and reading order over the page, with the rendered markdown, the markdown source, the lines with their confidences, the JSON output and the time of each stage. The pipeline options (text layer or OCR, math, headers and footers, reading order, OCR of text inside images, dpi, page limit) are set in the page, and lines, blocks, block labels and reading order can each be shown or hidden. Files stay on your machine. `--tesseract` lets the page compare with Tesseract (needs `pytesseract` and a Tesseract install). Over SSH, forward the port: `ssh -N -L 8765:localhost:8765 host`.
181
+
182
+ ## Output
183
+
184
+ Every page is a `Page` with:
185
+
186
+ - `markdown`: headings (`##`), paragraphs, lists, and tables as HTML. Page headers and footers are left out unless `furniture=True` / `--keep-furniture`
187
+ - `text`: one line per detected line, in reading order
188
+ - `lines`: `Line(box, text, conf)`, box is `x0, y0, x1, y1` in image pixels
189
+ - `blocks`: layout blocks in reading order, `{"label", "bbox", "text"}`
190
+ - `source`: `text` (PDF text layer), `ocr`, `hybrid` (text layer + OCR of text inside images) or `error`
191
+ - `rotation`, `skew`: the quarter or half turn applied (degrees), and the small tilt straightened
192
+ - `timings`: per-step milliseconds, with `total_ms`
193
+ - `note`: why the page took its path
194
+
195
+ Block labels: `Text`, `Section-Header`, `Page-Header`, `Page-Footer`, `List-Group`, `Table`, `Caption`, `Footnote`, `Table-Of-Contents`, `Form`. `--format json` writes one JSON object per page with all of these fields.
196
+
197
+ # Languages
198
+
199
+ **OCR (scans and images):** Latin (about 50 languages), Cyrillic, Greek, Devanagari, Bengali, and Chinese (simplified and traditional). Each line with Chinese characters goes to the Chinese recognizer.
200
+
201
+ **Text layer (digital PDFs): any script.** We checked text mode on 1,125 pages from 75 language families. On pages whose layer passes the checks, Indra OCR keeps at least 98% of the layer's characters in every family, including Arabic, Hebrew, Persian, Urdu, Thai, Khmer, Lao, Myanmar, Georgian, Armenian, Ethiopic, the Indic scripts, Chinese, Japanese and Korean. Right-to-left lines keep their right-to-left order.
202
+
203
+ # Limitations
204
+
205
+ - No handwriting.
206
+ - Math comes out as plain text unless `--math` is on (see [Math](#math)).
207
+ - No OCR of right-to-left scripts, Japanese kana, Korean Hangul, or scripts outside the OCR list above. The Chinese recognizer reads only the Chinese characters in Japanese text, and a Hangul line comes out as wrong Chinese characters. These scripts work through a digital PDF's text layer.
208
+ - No vertical text (such as traditional Chinese newspapers).
209
+ - Very wide, banner-shaped pages read poorly.
210
+ - Labels inside engineering drawings often come out as small tables.
211
+ - Pages above 100 megapixels at 200 dpi render at a lower dpi, so small text on them can be lost.
212
+ - The orientation model turns about half of the upright Arabic and Hebrew pages that go to OCR by mistake. Do not rely on it for those scripts.
213
+
214
+ # Math
215
+
216
+ Math is off by default. With `--math` (or `indra_ocr.load(math=True)`), a small classifier finds the lines that hold math, and a second recognizer reads them as text with inline LaTeX (`we have $x _ { i } \leq 1$`).
217
+
218
+ On OmniParseBench (all 2,937 pages, default settings otherwise):
219
+
220
+ | | headline | text | tables | layout | math tests |
221
+ |---|---|---|---|---|---|
222
+ | Indra OCR | 62.1 | 41.4 | 56.4 | 88.5 | 14.3 |
223
+ | Indra OCR `--math` | **66.8** | **57.5** | 54.8 | 88.1 | **56.5** |
224
+ | PaddleOCR PP-StructureV3 | 58.4 | 55.6 | 47.8 | 71.7 | – |
225
+
226
+ - With `--math`, Indra OCR is ahead of PaddleOCR's PP-StructureV3 on the headline, text, tables and layout. Without it, PP-StructureV3 leads on text.
227
+ - Tables lose 1.5 points: numbers in some table cells are read as math.
228
+ - `--math` is slower. On x86 (AMD EPYC Genoa), one page at a time on 4 cores in auto mode, the median page takes ~360 ms with `--math` and ~210 ms without. With one single-threaded worker per core, throughput is about 30% lower on 4 cores and 35% lower on 32 (4.8 vs 6.8 and 29.2 vs 44.9 pages/s, measured in one container on 300 OmniParseBench pages).
229
+ - The cost falls on the pages where the math path runs. In auto mode, pages read through a digital PDF's text layer slow down most: their median time per page goes from 130 ms to 345 ms in the throughput run (one single-threaded worker per core).
230
+ - Old scanned math gains little (22.2 to 23.1).
231
+
232
+ The math models download only when `--math` is on.
233
+
234
+ # Benchmarks
235
+
236
+ ## OmniParseBench
237
+
238
+ [OmniParseBench](https://github.com/datalab-to/omni_parse_bench) has 16,288 pass/fail tests on 2,937 pages. The headline is the mean of the text, tables and layout families. All runs: x86, 4 vCPUs per engine, one page at a time, every engine on the same pages with the same scorer and its default settings.
239
+
240
+ <img src="assets/benchmarks/speed_score.png" width="700px"/>
241
+
242
+ | engine | headline | text | tables | layout | median ms / page |
243
+ |---|---|---|---|---|---|
244
+ | Indra OCR (auto: text layer + OCR) | 62.1 | 41.3 | **56.4** | **88.6** | **228** |
245
+ | Indra OCR (OCR only) | 57.5 | 33.5 | 50.9 | 88.2 | 303 |
246
+ | Indra OCR `--math` (auto) | **66.8** | **57.5** | 54.8 | 88.1 | ~360† |
247
+ | PaddleOCR PP-OCRv6 small, text models only (RapidOCR) | – | 35.8 | 0.0 | – | 2,685 |
248
+ | PaddleOCR PP-StructureV3 (2,918 pages\*) | 58.4 | 55.6 | 47.8 | 71.7 | 40,958 |
249
+ | Tesseract 5 (our run, Latin model) | – | 19.3 | 0.0 | – | 5,496 |
250
+
251
+ - The PP-OCR text models and Tesseract output lines, not tables or layout blocks, so their table scores are 0 and their layout family is not scored.
252
+ - PP-StructureV3 is PaddleOCR's full document pipeline (layout, tables, formulas). Without `--math`, it reads text better than Indra OCR (55.6 vs 41.3). With `--math`, Indra OCR is ahead on text too (57.5). It takes about 180 times as long per page as Indra OCR's default mode. \*One of its 150 shards stalled for 6 hours on its first page, so its row leaves out 19 pages.
253
+ - Faster settings exist, but we did not score their accuracy. Tesseract with the `eng` model and 1 thread takes 3.4 s a page (6.1 s as run). PP-StructureV3 without formula, seal and chart recognition, unwarping and orientation, and with its mobile OCR models, takes 10.5 s a page. Indra OCR is still 15-45x faster per page.
254
+ - The OmniParseBench leaderboard's own Tesseract run scores 17.6 on text.
255
+ - Median latency varies by about 15% between runs of the same code. †The `--math` latency is from a separate run on x86 (AMD EPYC Genoa, 4 cores, one page at a time), where the default mode gave 208 ms.
256
+
257
+ **Chinese** (136 OmniParseBench Chinese tests): Indra OCR 64.7, PaddleOCR PP-OCRv5 mobile Chinese text models 65.4, PP-StructureV3 68.4.
258
+
259
+ ## olmOCR-bench
260
+
261
+ Born-digital splits and old scans, our harness, 200 dpi:
262
+
263
+ | split | Indra OCR | Tesseract 4 |
264
+ |---|---|---|
265
+ | headers_footers | 91.2 | 35.5 |
266
+ | multi_column | 70.0 | 70.4 |
267
+ | long_tiny_text | 67.9 | 64.0 |
268
+ | table_tests | 60.5 | 1.0 |
269
+ | old_scans | 20.0 | 18.4 |
270
+
271
+ ## Throughput
272
+
273
+ The CLI and `convert_many` run one single-threaded worker process per usable core, one page per task, so a single long PDF also uses every core. `--cores` limits it.
274
+
275
+ Pages per second. Every engine ran on the same x86 machine (AMD EPYC, no GPU) on the same 300 OmniParseBench pages, with one single-threaded worker per core, OCR mode and default settings. Indra OCR is the mean of 3 runs. The other engines ran once.
276
+
277
+ | engine | 4 cores | 8 cores | 16 cores | 32 cores |
278
+ |---|---|---|---|---|
279
+ | Indra OCR | **7.3** | **14.2** | **27.2** | **49.4** |
280
+ | Indra OCR `--math`† | ~5 | – | – | ~30 |
281
+ | PaddleOCR PP-OCRv6 small, text models only (RapidOCR) | 0.65 | 1.24 | 2.42 | 4.28 |
282
+ | Tesseract 5 | 0.78 | 1.37 | 2.27 | 2.92 |
283
+ | PaddleOCR PP-StructureV3\* | ≤ 0.022 | ≤ 0.044 | ≤ 0.089 | ≤ 0.18 |
284
+
285
+ At 32 cores, Indra OCR is 11.5x PaddleOCR's PP-OCR text models, 16.9x Tesseract and about 280x PP-StructureV3 (against its upper bound). \*PP-StructureV3 ran a time-capped subset of the pages, so its numbers are upper bounds. †`--math` ran in a separate container with the same CPU type and the same pages, where it gave 4.8 pages/s on 4 cores and 29.2 on 32, against 6.8 and 44.9 without it (about 30% and 35% lower).
286
+
287
+ Model loading and one warm-up page per worker are not timed. A short 300-page job through `convert_many`, model loading included, runs at 7.2 pages/s on 4 cores and 37.7 on 32.
288
+
289
+ ## Reproducing
290
+
291
+ ```shell
292
+ pip install 'omni-parse-bench[benchmark]'
293
+ python bench/opb_indra.py --out runs/opb_auto --mode auto --procs 8
294
+ ```
295
+
296
+ Each page runs in a single-threaded worker process, page headers and footers kept. `--mode ocr` gives the OCR-only row, `--limit N` scores the first N pages, and `--models` points at a local model folder. The run writes `summary.json` (the benchmark's own summary, plus median and p90 ms per page) and `pages.jsonl` (per page: time, source, tests passed).
297
+
298
+ # Credits
299
+
300
+ Thank you to the following open source projects:
301
+
302
+ - [ONNX Runtime](https://github.com/microsoft/onnxruntime)
303
+ - [pypdfium2](https://github.com/pypdfium2-team/pypdfium2)
304
+ - [OpenCV](https://github.com/opencv/opencv)
305
+ - [Hugging Face Hub](https://github.com/huggingface/huggingface_hub)