oxocr 0.1.1__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.
Files changed (177) hide show
  1. oxocr-0.1.1/.gitignore +156 -0
  2. oxocr-0.1.1/LICENSE +21 -0
  3. oxocr-0.1.1/PKG-INFO +234 -0
  4. oxocr-0.1.1/README.md +203 -0
  5. oxocr-0.1.1/README_zh.md +203 -0
  6. oxocr-0.1.1/docs/adding-a-model.md +168 -0
  7. oxocr-0.1.1/docs/adding-a-stage.md +128 -0
  8. oxocr-0.1.1/docs/cli.md +246 -0
  9. oxocr-0.1.1/docs/images/logo.svg +7 -0
  10. oxocr-0.1.1/docs/packaging.md +102 -0
  11. oxocr-0.1.1/docs/testing.md +98 -0
  12. oxocr-0.1.1/oxocr/__init__.py +135 -0
  13. oxocr-0.1.1/oxocr/cli.py +555 -0
  14. oxocr-0.1.1/oxocr/config.py +421 -0
  15. oxocr-0.1.1/oxocr/config_data/ocr_corrections.json +10 -0
  16. oxocr-0.1.1/oxocr/errors.py +117 -0
  17. oxocr-0.1.1/oxocr/facade.py +396 -0
  18. oxocr-0.1.1/oxocr/models/__init__.py +1 -0
  19. oxocr-0.1.1/oxocr/models/anaksor_ocr/__init__.py +4 -0
  20. oxocr-0.1.1/oxocr/models/anaksor_ocr/detector.py +143 -0
  21. oxocr-0.1.1/oxocr/models/anaksor_ocr/geometry.py +152 -0
  22. oxocr-0.1.1/oxocr/models/anaksor_ocr/longline.py +79 -0
  23. oxocr-0.1.1/oxocr/models/anaksor_ocr/pipeline.py +174 -0
  24. oxocr-0.1.1/oxocr/models/anaksor_ocr/recognizer.py +132 -0
  25. oxocr-0.1.1/oxocr/models/anaksor_ocr/specs.py +87 -0
  26. oxocr-0.1.1/oxocr/models/anaksor_ocr/text.py +181 -0
  27. oxocr-0.1.1/oxocr/models/base.py +353 -0
  28. oxocr-0.1.1/oxocr/models/duguang_ocr/__init__.py +4 -0
  29. oxocr-0.1.1/oxocr/models/duguang_ocr/detector.py +156 -0
  30. oxocr-0.1.1/oxocr/models/duguang_ocr/pipeline.py +150 -0
  31. oxocr-0.1.1/oxocr/models/duguang_ocr/recognizer.py +143 -0
  32. oxocr-0.1.1/oxocr/models/duguang_ocr/seglink.py +374 -0
  33. oxocr-0.1.1/oxocr/models/duguang_ocr/specs.py +159 -0
  34. oxocr-0.1.1/oxocr/models/indra_ocr/__init__.py +5 -0
  35. oxocr-0.1.1/oxocr/models/indra_ocr/detector.py +107 -0
  36. oxocr-0.1.1/oxocr/models/indra_ocr/lm.py +248 -0
  37. oxocr-0.1.1/oxocr/models/indra_ocr/mathrec.py +116 -0
  38. oxocr-0.1.1/oxocr/models/indra_ocr/orient.py +178 -0
  39. oxocr-0.1.1/oxocr/models/indra_ocr/pipeline.py +202 -0
  40. oxocr-0.1.1/oxocr/models/indra_ocr/preproc.py +198 -0
  41. oxocr-0.1.1/oxocr/models/indra_ocr/recognizer.py +130 -0
  42. oxocr-0.1.1/oxocr/models/indra_ocr/rtl.py +106 -0
  43. oxocr-0.1.1/oxocr/models/indra_ocr/specs.py +208 -0
  44. oxocr-0.1.1/oxocr/models/indra_ocr/vocab.py +47 -0
  45. oxocr-0.1.1/oxocr/models/languages.py +148 -0
  46. oxocr-0.1.1/oxocr/models/openthai_ocr/__init__.py +4 -0
  47. oxocr-0.1.1/oxocr/models/openthai_ocr/detector.py +116 -0
  48. oxocr-0.1.1/oxocr/models/openthai_ocr/geometry.py +136 -0
  49. oxocr-0.1.1/oxocr/models/openthai_ocr/order.py +175 -0
  50. oxocr-0.1.1/oxocr/models/openthai_ocr/pipeline.py +318 -0
  51. oxocr-0.1.1/oxocr/models/openthai_ocr/recognizer.py +120 -0
  52. oxocr-0.1.1/oxocr/models/openthai_ocr/specs.py +89 -0
  53. oxocr-0.1.1/oxocr/models/openthai_ocr/text.py +91 -0
  54. oxocr-0.1.1/oxocr/models/pix2text/__init__.py +1 -0
  55. oxocr-0.1.1/oxocr/models/pix2text/pipeline.py +163 -0
  56. oxocr-0.1.1/oxocr/models/pix2text/specs.py +114 -0
  57. oxocr-0.1.1/oxocr/models/pix2text/tokenizer.py +54 -0
  58. oxocr-0.1.1/oxocr/models/rapid_latex_ocr/__init__.py +6 -0
  59. oxocr-0.1.1/oxocr/models/rapid_latex_ocr/pipeline.py +171 -0
  60. oxocr-0.1.1/oxocr/models/rapid_latex_ocr/preproc.py +95 -0
  61. oxocr-0.1.1/oxocr/models/rapid_latex_ocr/specs.py +64 -0
  62. oxocr-0.1.1/oxocr/models/rapid_ocr/__init__.py +1 -0
  63. oxocr-0.1.1/oxocr/models/rapid_ocr/classifier.py +66 -0
  64. oxocr-0.1.1/oxocr/models/rapid_ocr/detector.py +177 -0
  65. oxocr-0.1.1/oxocr/models/rapid_ocr/pipeline.py +138 -0
  66. oxocr-0.1.1/oxocr/models/rapid_ocr/recognizer.py +108 -0
  67. oxocr-0.1.1/oxocr/models/rapid_ocr/specs.py +421 -0
  68. oxocr-0.1.1/oxocr/pipeline.py +154 -0
  69. oxocr-0.1.1/oxocr/postprocess/__init__.py +1 -0
  70. oxocr-0.1.1/oxocr/postprocess/assemblers.py +124 -0
  71. oxocr-0.1.1/oxocr/postprocess/base.py +328 -0
  72. oxocr-0.1.1/oxocr/postprocess/corrections.py +198 -0
  73. oxocr-0.1.1/oxocr/postprocess/ghost.py +77 -0
  74. oxocr-0.1.1/oxocr/postprocess/grouping.py +36 -0
  75. oxocr-0.1.1/oxocr/postprocess/joiners.py +162 -0
  76. oxocr-0.1.1/oxocr/postprocess/normalize.py +58 -0
  77. oxocr-0.1.1/oxocr/postprocess/render.py +43 -0
  78. oxocr-0.1.1/oxocr/preprocess/__init__.py +1 -0
  79. oxocr-0.1.1/oxocr/preprocess/base.py +208 -0
  80. oxocr-0.1.1/oxocr/preprocess/dark_to_light.py +135 -0
  81. oxocr-0.1.1/oxocr/preprocess/pad_border.py +73 -0
  82. oxocr-0.1.1/oxocr/preprocess/theme.py +73 -0
  83. oxocr-0.1.1/oxocr/registry/__init__.py +1 -0
  84. oxocr-0.1.1/oxocr/registry/catalog.py +24 -0
  85. oxocr-0.1.1/oxocr/registry/download.py +163 -0
  86. oxocr-0.1.1/oxocr/registry/registry.py +224 -0
  87. oxocr-0.1.1/oxocr/runtime/__init__.py +1 -0
  88. oxocr-0.1.1/oxocr/runtime/executor.py +178 -0
  89. oxocr-0.1.1/oxocr/runtime/imageops.py +390 -0
  90. oxocr-0.1.1/oxocr/runtime/images.py +84 -0
  91. oxocr-0.1.1/oxocr/runtime/pool.py +196 -0
  92. oxocr-0.1.1/oxocr/runtime/session.py +55 -0
  93. oxocr-0.1.1/oxocr/runtime/worker.py +86 -0
  94. oxocr-0.1.1/oxocr/types.py +459 -0
  95. oxocr-0.1.1/oxocr/visual.py +295 -0
  96. oxocr-0.1.1/pyproject.toml +70 -0
  97. oxocr-0.1.1/test/conftest.py +210 -0
  98. oxocr-0.1.1/test/contract/test_extension_contract.py +197 -0
  99. oxocr-0.1.1/test/data/anaksor/sign.jpg +0 -0
  100. oxocr-0.1.1/test/data/indra/cjk.png +0 -0
  101. oxocr-0.1.1/test/data/indra/korean.png +0 -0
  102. oxocr-0.1.1/test/data/indra/letter.png +0 -0
  103. oxocr-0.1.1/test/data/indra/math.png +0 -0
  104. oxocr-0.1.1/test/data/indra/math1.png +0 -0
  105. oxocr-0.1.1/test/data/indra/math2.png +0 -0
  106. oxocr-0.1.1/test/data/indra/math_line.png +0 -0
  107. oxocr-0.1.1/test/data/indra/world.png +0 -0
  108. oxocr-0.1.1/test/data/latex_ocr/1.png +0 -0
  109. oxocr-0.1.1/test/data/latex_ocr/2.png +0 -0
  110. oxocr-0.1.1/test/data/latex_ocr/5.png +0 -0
  111. oxocr-0.1.1/test/data/latex_ocr/6.png +0 -0
  112. oxocr-0.1.1/test/data/latex_ocr/latex-1.png +0 -0
  113. oxocr-0.1.1/test/data/openthai/thai_lines.png +0 -0
  114. oxocr-0.1.1/test/data/openthai/thai_page.png +0 -0
  115. oxocr-0.1.1/test/data/ppocr/det-1.jpg +0 -0
  116. oxocr-0.1.1/test/data/ppocr/general_ocr_001.png +0 -0
  117. oxocr-0.1.1/test/data/ppocr/general_ocr_002.png +0 -0
  118. oxocr-0.1.1/test/data/ppocr/ocr_detection.jpg +0 -0
  119. oxocr-0.1.1/test/data/ppocr/ocr_recognition_icdar13.jpg +0 -0
  120. oxocr-0.1.1/test/integration/test_anaksor_models.py +199 -0
  121. oxocr-0.1.1/test/integration/test_duguang_models.py +169 -0
  122. oxocr-0.1.1/test/integration/test_indra_models.py +373 -0
  123. oxocr-0.1.1/test/integration/test_latex_ocr_models.py +145 -0
  124. oxocr-0.1.1/test/integration/test_mfr_models.py +112 -0
  125. oxocr-0.1.1/test/integration/test_offline_models.py +197 -0
  126. oxocr-0.1.1/test/integration/test_openthai_models.py +289 -0
  127. oxocr-0.1.1/test/script/_common.py +85 -0
  128. oxocr-0.1.1/test/script/run_offline_anaksor.py +53 -0
  129. oxocr-0.1.1/test/script/run_offline_duguang.py +43 -0
  130. oxocr-0.1.1/test/script/run_offline_indra.py +87 -0
  131. oxocr-0.1.1/test/script/run_offline_latex_ocr.py +41 -0
  132. oxocr-0.1.1/test/script/run_offline_mfr.py +49 -0
  133. oxocr-0.1.1/test/script/run_offline_openthai.py +53 -0
  134. oxocr-0.1.1/test/script/run_offline_ppocr.py +49 -0
  135. oxocr-0.1.1/test/test-data/seglink_golden.npz +0 -0
  136. oxocr-0.1.1/test/unit/test_affine.py +59 -0
  137. oxocr-0.1.1/test/unit/test_anaksor_geometry.py +190 -0
  138. oxocr-0.1.1/test/unit/test_anaksor_longline.py +120 -0
  139. oxocr-0.1.1/test/unit/test_anaksor_recognizer.py +215 -0
  140. oxocr-0.1.1/test/unit/test_anaksor_specs.py +102 -0
  141. oxocr-0.1.1/test/unit/test_anaksor_text.py +140 -0
  142. oxocr-0.1.1/test/unit/test_assemblers.py +84 -0
  143. oxocr-0.1.1/test/unit/test_box.py +57 -0
  144. oxocr-0.1.1/test/unit/test_cli.py +697 -0
  145. oxocr-0.1.1/test/unit/test_config.py +80 -0
  146. oxocr-0.1.1/test/unit/test_corrections.py +68 -0
  147. oxocr-0.1.1/test/unit/test_download.py +363 -0
  148. oxocr-0.1.1/test/unit/test_duguang_recognizer.py +205 -0
  149. oxocr-0.1.1/test/unit/test_duguang_seglink.py +99 -0
  150. oxocr-0.1.1/test/unit/test_duguang_specs.py +125 -0
  151. oxocr-0.1.1/test/unit/test_ghost.py +33 -0
  152. oxocr-0.1.1/test/unit/test_grouping.py +35 -0
  153. oxocr-0.1.1/test/unit/test_imageops.py +91 -0
  154. oxocr-0.1.1/test/unit/test_imageops_cc_rotate.py +93 -0
  155. oxocr-0.1.1/test/unit/test_indra_detector.py +110 -0
  156. oxocr-0.1.1/test/unit/test_indra_lm.py +108 -0
  157. oxocr-0.1.1/test/unit/test_indra_preproc.py +108 -0
  158. oxocr-0.1.1/test/unit/test_indra_rtl.py +70 -0
  159. oxocr-0.1.1/test/unit/test_indra_specs.py +108 -0
  160. oxocr-0.1.1/test/unit/test_indra_vocab.py +65 -0
  161. oxocr-0.1.1/test/unit/test_joiners.py +58 -0
  162. oxocr-0.1.1/test/unit/test_latex_ocr_preproc.py +97 -0
  163. oxocr-0.1.1/test/unit/test_latex_ocr_specs.py +61 -0
  164. oxocr-0.1.1/test/unit/test_mfr_specs.py +61 -0
  165. oxocr-0.1.1/test/unit/test_mfr_tokenizer.py +74 -0
  166. oxocr-0.1.1/test/unit/test_normalize.py +27 -0
  167. oxocr-0.1.1/test/unit/test_openthai_geometry.py +223 -0
  168. oxocr-0.1.1/test/unit/test_openthai_order.py +88 -0
  169. oxocr-0.1.1/test/unit/test_openthai_recognizer.py +121 -0
  170. oxocr-0.1.1/test/unit/test_openthai_specs.py +126 -0
  171. oxocr-0.1.1/test/unit/test_openthai_text.py +106 -0
  172. oxocr-0.1.1/test/unit/test_own_postprocess_gate.py +127 -0
  173. oxocr-0.1.1/test/unit/test_own_preprocess_gate.py +103 -0
  174. oxocr-0.1.1/test/unit/test_pad_border_gate.py +139 -0
  175. oxocr-0.1.1/test/unit/test_ppocr_specs.py +87 -0
  176. oxocr-0.1.1/test/unit/test_registry.py +141 -0
  177. oxocr-0.1.1/test/unit/test_visual.py +166 -0
oxocr-0.1.1/.gitignore ADDED
@@ -0,0 +1,156 @@
1
+ # MY
2
+ test/models/
3
+
4
+ # Byte-compiled / optimized / DLL files
5
+ __pycache__/
6
+ *.py[cod]
7
+ *$py.class
8
+
9
+ # C extensions
10
+ *.so
11
+
12
+ # Distribution / packaging
13
+ .Python
14
+ build/
15
+ develop-eggs/
16
+ dist/
17
+ downloads/
18
+ eggs/
19
+ .eggs/
20
+ lib/
21
+ lib64/
22
+ parts/
23
+ sdist/
24
+ var/
25
+ wheels/
26
+ share/python-wheels/
27
+ *.egg-info/
28
+ .installed.cfg
29
+ *.egg
30
+ MANIFEST
31
+
32
+ # PyInstaller
33
+ *.manifest
34
+ *.spec
35
+
36
+ # Installer logs
37
+ pip-log.txt
38
+ pip-delete-this-directory.txt
39
+
40
+ # Unit test / coverage reports
41
+ htmlcov/
42
+ .tox/
43
+ .nox/
44
+ .coverage
45
+ .coverage.*
46
+ .cache
47
+ nosetests.xml
48
+ coverage.xml
49
+ *.cover
50
+ *.py,cover
51
+ .hypothesis/
52
+ .pytest_cache/
53
+ cover/
54
+
55
+ # Translations
56
+ *.mo
57
+ *.pot
58
+
59
+ # Django stuff
60
+ *.log
61
+ local_settings.py
62
+ db.sqlite3
63
+ db.sqlite3-journal
64
+
65
+ # Flask stuff
66
+ instance/
67
+ .webassets-cache
68
+
69
+ # Scrapy stuff
70
+ .scrapy
71
+
72
+ # Sphinx documentation
73
+ docs/_build/
74
+
75
+ # PyBuilder
76
+ .pybuilder/
77
+ target/
78
+
79
+ # Jupyter Notebook
80
+ .ipynb_checkpoints
81
+
82
+ # IPython
83
+ profile_default/
84
+ ipython_config.py
85
+
86
+ # pyenv
87
+ .python-version
88
+
89
+ # pipenv
90
+ Pipfile.lock
91
+
92
+ # poetry
93
+ poetry.lock
94
+
95
+ # pdm
96
+ .pdm.toml
97
+ __pypackages__/
98
+
99
+ # Celery stuff
100
+ celerybeat-schedule
101
+ celerybeat.pid
102
+
103
+ # SageMath parsed files
104
+ *.sage.py
105
+
106
+ # Environments
107
+ .env
108
+ .venv
109
+ env/
110
+ venv/
111
+ ENV/
112
+ env.bak/
113
+ venv.bak/
114
+
115
+ # Spyder project settings
116
+ .spyderproject
117
+ .spyproject
118
+
119
+ # Rope project settings
120
+ .ropeproject
121
+
122
+ # mkdocs documentation
123
+ /site
124
+
125
+ # mypy
126
+ .mypy_cache/
127
+ .dmypy.json
128
+ dmypy.json
129
+
130
+ # pyright
131
+ .pyright/
132
+
133
+ # pytype
134
+ .pytype/
135
+
136
+ # Cython
137
+ cython_debug/
138
+
139
+ # Ruff
140
+ .ruff_cache/
141
+
142
+ # uv
143
+ .uv/
144
+
145
+ # IDE / editors
146
+ .idea/
147
+ .vscode/
148
+ *.swp
149
+ *.swo
150
+
151
+ # OS files
152
+ .DS_Store
153
+ Thumbs.db
154
+
155
+ # Examples
156
+ examples/
oxocr-0.1.1/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 luckycucu
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
oxocr-0.1.1/PKG-INFO ADDED
@@ -0,0 +1,234 @@
1
+ Metadata-Version: 2.5
2
+ Name: oxocr
3
+ Version: 0.1.1
4
+ Summary: Lightweight Python OCR library on ONNX Runtime with 45 built-in models (PaddleOCR, DuGuang, Indra, formula recognition), no OpenCV dependency / 基于 ONNX Runtime 的轻量级 Python OCR 库,内置 PaddleOCR、读光、Indra、公式识别等 45 个模型,无 OpenCV 依赖
5
+ Author: luckycucu
6
+ License: MIT
7
+ License-File: LICENSE
8
+ Keywords: ocr,onnx,pp-ocr,text-recognition
9
+ Classifier: Development Status :: 3 - Alpha
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Programming Language :: Python :: 3.10
13
+ Classifier: Programming Language :: Python :: 3.11
14
+ Classifier: Programming Language :: Python :: 3.12
15
+ Classifier: Topic :: Scientific/Engineering :: Image Recognition
16
+ Requires-Python: >=3.10
17
+ Requires-Dist: huggingface-hub>=0.23
18
+ Requires-Dist: modelscope-hub>=0.7
19
+ Requires-Dist: numpy>=1.24
20
+ Requires-Dist: onnxruntime>=1.16
21
+ Requires-Dist: pillow>=10.0
22
+ Requires-Dist: pyclipper>=1.3
23
+ Requires-Dist: upolygon>=0.1
24
+ Provides-Extra: dev
25
+ Requires-Dist: mypy; extra == 'dev'
26
+ Requires-Dist: opencv-python-headless; extra == 'dev'
27
+ Requires-Dist: pytest-cov; extra == 'dev'
28
+ Requires-Dist: pytest>=7.0; extra == 'dev'
29
+ Requires-Dist: ruff; extra == 'dev'
30
+ Description-Content-Type: text/markdown
31
+
32
+ <div align="center">
33
+ <img src="docs/images/logo.svg" alt="Logo" width="400" height="400" />
34
+ <p>
35
+ <a href="#license"><img src="https://img.shields.io/badge/License-MIT-blue.svg?logo=opensourceinitiative&logoColor=white" alt="License" /></a>
36
+ <img src="https://img.shields.io/badge/Python-3.10+-FFD43B.svg?logo=python&logoColor=3776AB" alt="Python" />
37
+ <img src="https://img.shields.io/badge/Runtime-ONNX-005CED.svg?logo=onnx&logoColor=white" alt="ONNX Runtime" />
38
+ <img src="https://img.shields.io/badge/Models-45-orange.svg" alt="Models" />
39
+ </p>
40
+ <p>
41
+ <a href="README_zh.md">简体中文</a> ·
42
+ <b>English</b>
43
+ </p>
44
+ </div>
45
+
46
+ **Lightweight Python OCR library powered by ONNX Runtime** — 45 built-in models covering the PaddleOCR series, DuGuang OCR series, Indra OCR series, pix2text_mfr (formula recognition), and more.
47
+
48
+ - **Lightweight dependencies**: mainly numpy, Pillow and onnxruntime — **no OpenCV required**.
49
+ - **Layout output**: 4 layout modes (raw / line / para / layout); output plain text directly, or the raw recognized text-box data.
50
+ - **Visualization**: draw boxes and recognized text back onto the image (`oxocr.visual` / `run --vis`); auto-detects system fonts, no bundled font.
51
+ - **CLI**: Docker-style command design — simple, intuitive and easy to pick up.
52
+
53
+ ## Quick Start
54
+
55
+ ### Installation
56
+
57
+ ```bash
58
+ pip install oxocr
59
+ ```
60
+
61
+ Requires Python ≥ 3.10. Install from source: `pip install -e .` (dev/test dependencies: [docs/testing.md](docs/testing.md)).
62
+
63
+ ### Model Download
64
+
65
+ Model weights are not shipped with the package. Download them before first use (ModelScope preferred, HuggingFace as fallback):
66
+
67
+ ```bash
68
+ oxocr download ppocrv6_small # saved to ~/.oxocr/models by default
69
+ ```
70
+
71
+ You can also download from Python: `oxocr.download_model("ppocrv6_small")`.
72
+
73
+ All model weights are hosted in the following repositories for manual browsing or downloading:
74
+
75
+ - ModelScope (preferred in China): [mscoder/oxocr](https://modelscope.cn/models/mscoder/oxocr)
76
+ - HuggingFace (fallback): [Luoaho/oxocr](https://huggingface.co/Luoaho/oxocr)
77
+
78
+ Use `--source modelscope|huggingface` to pick a download source. On restricted networks, download files manually from the repositories above and place them in the model directory (default `~/.oxocr/models`, customizable via `OXOCR_MODEL_DIR`) for offline use.
79
+
80
+ ### Recognition
81
+
82
+ ```python
83
+ import oxocr
84
+
85
+ # One-liner text extraction (default: ppocrv6_small + para mode)
86
+ text = oxocr.readtext("shot.png")
87
+
88
+ # Full result: infer once, render multiple layouts
89
+ result = oxocr.ocr("shot.png", mode="para")
90
+ print(result.text)
91
+ print(result.as_text("layout")) # switch layout without re-inference
92
+ for item in result.items: # boxes are always in original-image pixel coordinates
93
+ print(item.text, item.score, item.box.as_rect())
94
+
95
+ # Reuse the engine (batch scenarios share a process-level resident session)
96
+ engine = oxocr.OcrEngine(model="ppocrv6_small", postprocess={"mode": "para"})
97
+ results = engine.batch(["a.png", "b.png"])
98
+ ```
99
+
100
+ Specify a local offline model directory:
101
+
102
+ ```python
103
+ text = oxocr.readtext("shot.png", model_dir="test/models")
104
+ ```
105
+
106
+ ### Visualization
107
+
108
+ Draw detection boxes and recognized text back onto the image:
109
+
110
+ ```python
111
+ from oxocr.visual import draw_items, draw_ocr, draw_boxes
112
+ from PIL import Image
113
+
114
+ result = oxocr.ocr("shot.png")
115
+
116
+ vis = draw_items("shot.png", result.items) # side-by-side: boxes | text (BGR ndarray)
117
+ Image.fromarray(vis[:, :, ::-1]).save("vis.png")
118
+
119
+ draw_ocr("shot.png", [it.box for it in result.items],
120
+ [it.text for it in result.items]) # boxes + text panel with scores
121
+ draw_boxes("shot.png", [it.box for it in result.items]) # red boxes only
122
+ ```
123
+
124
+ Or straight from the CLI:
125
+
126
+ ```bash
127
+ oxocr run shot.png --vis vis.png # side-by-side visualization
128
+ oxocr run shot.png --vis vis.png --vis-mode box # boxes only
129
+ ```
130
+
131
+ Fonts are auto-detected from the system (CJK-first candidates); pass `font_path=` / `--font` to use any ttf/ttc — recommended for scripts like Thai or Devanagari that the default font may not cover. See [docs/cli.md](docs/cli.md) for all modes.
132
+
133
+ ## Model List
134
+
135
+ Sorted by open-source release date.
136
+
137
+ | Model | Released | Size (MB) | License | Languages |
138
+ | ------------------------------ | ---------- | --------- | ----------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
139
+ | `anaksor_ocr` | 2026-11-04 | 90.4 | Apache-2.0 | Khmer, English |
140
+ | `openthai2.0_ocr` | 2026-11-01 | 4.0 | Apache-2.0 | Thai, English |
141
+ | `indra_ocr_cjk` | 2026-10-19 | 28.7 | RAIL-M (modified) | Simplified Chinese, Traditional Chinese, Japanese, Korean |
142
+ | `indra_ocr_latin` | 2026-10-19 | 20.7 | RAIL-M (modified) | Latin, English, French, German, Italian, Spanish, Portuguese, Dutch, Polish, Romanian, Czech, Swedish, Norwegian, Danish, Finnish, Hungarian, Turkish, Vietnamese, Indonesian, Malay, Azerbaijani, Afrikaans, Bosnian, Croatian, Welsh, Estonian, Irish, Icelandic, Kurdish, Lithuanian, Latvian, Maltese, Maori, Occitan, Slovak, Slovenian, Albanian, Swahili, Tagalog, Uzbek, Latin, Serbian (Latin), Catalan, Basque, Galician, Luxembourgish, Romansh, Quechua, Hausa, Fula, Akan, Yoruba, Cyrillic, Greek |
143
+ | `indra_ocr_math` | 2026-10-19 | 18.8 | RAIL-M (modified) | latex |
144
+ | `indra_ocr_rtl` | 2026-10-19 | 5.5 | RAIL-M (modified) | Arabic, Persian, Urdu, Pashto, Kurdish, Hebrew |
145
+ | `indra_ocr_world` | 2026-10-19 | 17.4 | RAIL-M (modified) | Hindi, Thai, Bengali, Tamil, Telugu, Burmese, Khmer, Lao, Sinhala, Kannada, Armenian, Amharic |
146
+ | `ppocrv6_medium` | 2026-06-11 | 132.9 | Apache-2.0 | Simplified Chinese, Traditional Chinese, English, Japanese, French, German, Italian, Spanish, Portuguese, Dutch, Polish, Romanian, Czech, Swedish, Norwegian, Danish, Finnish, Hungarian, Turkish, Vietnamese, Indonesian, Malay, Azerbaijani, Afrikaans, Bosnian, Croatian, Welsh, Estonian, Irish, Icelandic, Kurdish, Lithuanian, Latvian, Maltese, Maori, Occitan, Slovak, Slovenian, Albanian, Swahili, Tagalog, Uzbek, Latin, Serbian (Latin), Catalan, Basque, Galician, Luxembourgish, Romansh, Quechua |
147
+ | `ppocrv6_small` | 2026-06-11 | 30.3 | Apache-2.0 | Simplified Chinese, Traditional Chinese, English, Japanese, French, German, Italian, Spanish, Portuguese, Dutch, Polish, Romanian, Czech, Swedish, Norwegian, Danish, Finnish, Hungarian, Turkish, Vietnamese, Indonesian, Malay, Azerbaijani, Afrikaans, Bosnian, Croatian, Welsh, Estonian, Irish, Icelandic, Kurdish, Lithuanian, Latvian, Maltese, Maori, Occitan, Slovak, Slovenian, Albanian, Swahili, Tagalog, Uzbek, Latin, Serbian (Latin), Catalan, Basque, Galician, Luxembourgish, Romansh, Quechua |
148
+ | `ppocrv6_tiny` | 2026-06-11 | 6.6 | Apache-2.0 | Simplified Chinese, Traditional Chinese, English, French, German, Italian, Spanish, Portuguese, Dutch, Polish, Romanian, Czech, Swedish, Norwegian, Danish, Finnish, Hungarian, Turkish, Vietnamese, Indonesian, Malay, Azerbaijani, Afrikaans, Bosnian, Croatian, Welsh, Estonian, Irish, Icelandic, Kurdish, Lithuanian, Latvian, Maltese, Maori, Occitan, Slovak, Slovenian, Albanian, Swahili, Tagalog, Uzbek, Latin, Serbian (Latin), Catalan, Basque, Galician, Luxembourgish, Romansh, Quechua |
149
+ | `ppocrv5_arabic_mobile` | 2025-10-16 | 13.2 | Apache-2.0 | Arabic, Persian, Uyghur, Urdu, Pashto, Kurdish, Sindhi, Balochi, English |
150
+ | `ppocrv5_cyrillic_mobile` | 2025-10-16 | 13.3 | Apache-2.0 | Russian, Belarusian, Ukrainian, Serbian (Cyrillic), Bulgarian, Mongolian, Abkhaz, Adyghe, Kabardian, Avar, Dargwa, Ingush, Chechen, Lak, Lezgian, Tabasaran, Kazakh, Kyrgyz, Tajik, Macedonian, Tatar, Chuvash, Bashkir, Mari, Mordvin, Udmurt, Komi, Ossetian, Buryat, Kalmyk, Tuvan, Sakha, Karakalpak, English |
151
+ | `ppocrv5_devanagari_mobile` | 2025-10-16 | 13.1 | Apache-2.0 | Hindi, Marathi, Nepali, Bihari, Maithili, Old English, Bhojpuri, Magahi, Sadri, Newari, Konkani, Sanskrit, Haryanvi, English |
152
+ | `ppocrv5_eslav_mobile` | 2025-10-16 | 13.1 | Apache-2.0 | Russian, Belarusian, Ukrainian, English |
153
+ | `ppocrv5_korean_mobile` | 2025-10-16 | 18.4 | Apache-2.0 | Korean, English |
154
+ | `ppocrv5_latin_mobile` | 2025-10-16 | 13.1 | Apache-2.0 | French, German, Afrikaans, Italian, Spanish, Bosnian, Portuguese, Czech, Welsh, Danish, Estonian, Irish, Croatian, Uzbek, Hungarian, Serbian (Latin), Indonesian, Occitan, Icelandic, Lithuanian, Maori, Malay, Dutch, Norwegian, Polish, Slovak, Slovenian, Albanian, Swedish, Swahili, Tagalog, Turkish, Latin, Azerbaijani, Kurdish, Latvian, Maltese, Pali, Romanian, Vietnamese, Finnish, Basque, Galician, Luxembourgish, Romansh, Catalan, Quechua |
155
+ | `ppocrv5_ta_mobile` | 2025-10-16 | 13.1 | Apache-2.0 | Tamil, English |
156
+ | `ppocrv5_te_mobile` | 2025-10-16 | 13.1 | Apache-2.0 | Telugu, English |
157
+ | `ppocrv5_el_mobile` | 2025-08-21 | 13.0 | Apache-2.0 | Greek, English |
158
+ | `ppocrv5_en_mobile` | 2025-08-21 | 13.1 | Apache-2.0 | English |
159
+ | `ppocrv5_th_mobile` | 2025-08-21 | 13.1 | Apache-2.0 | Thai, English |
160
+ | `pix2text_mfr_1.5` | 2025-07-07 | 114.1 | MIT | latex |
161
+ | `ppocrv5_ch_mobile` | 2025-05-20 | 21.4 | Apache-2.0 | Simplified Chinese, Traditional Chinese, English, Japanese |
162
+ | `ppocrv5_ch_server` | 2025-05-20 | 165.7 | Apache-2.0 | Simplified Chinese, Traditional Chinese, English, Japanese |
163
+ | `pix2text_mfr` | 2024-02-12 | 112.2 | MIT | latex |
164
+ | `pix2text_mfr_quantized` | 2024-02-12 | 50.8 | MIT | latex |
165
+ | `ppocrv4_arabic_mobile` | 2023-08-07 | 12.4 | Apache-2.0 | Arabic |
166
+ | `ppocrv4_ch_doc_server` | 2023-08-07 | 199.2 | Apache-2.0 | Simplified Chinese, English |
167
+ | `ppocrv4_ch_mobile` | 2023-08-07 | 15.4 | Apache-2.0 | Simplified Chinese, English |
168
+ | `ppocrv4_ch_server` | 2023-08-07 | 195.0 | Apache-2.0 | Simplified Chinese, English |
169
+ | `ppocrv4_devanagari_mobile` | 2023-08-07 | 12.4 | Apache-2.0 | Devanagari |
170
+ | `ppocrv4_en_mobile` | 2023-08-07 | 12.4 | Apache-2.0 | English |
171
+ | `ppocrv4_japan_mobile` | 2023-08-07 | 14.4 | Apache-2.0 | Japanese |
172
+ | `ppocrv4_ka_mobile` | 2023-08-07 | 12.4 | Apache-2.0 | Kannada |
173
+ | `ppocrv4_korean_mobile` | 2023-08-07 | 28.0 | Apache-2.0 | Korean |
174
+ | `ppocrv4_ta_mobile` | 2023-08-07 | 26.4 | Apache-2.0 | Tamil |
175
+ | `ppocrv4_te_mobile` | 2023-08-07 | 26.4 | Apache-2.0 | Telugu |
176
+ | `duguang_ocr_small` | 2023-05-29 | 12.7 | Apache-2.0 | Simplified Chinese, English |
177
+ | `duguang_ocr_large` | 2023-02-06 | 119.8 | Apache-2.0 | Simplified Chinese, English |
178
+ | `duguang_ocr_max` | 2022-08-19 | 151.4 | Apache-2.0 | Simplified Chinese, English |
179
+ | `rapid_latex_ocr` | 2022-05-25 | 170.7 | MIT | latex |
180
+ | `ppocrv3_chinese_cht_mobile` | 2022-05-09 | 13.5 | Apache-2.0 | Traditional Chinese |
181
+ | `ppocrv3_cyrillic_mobile` | 2022-05-09 | 11.4 | Apache-2.0 | Cyrillic |
182
+ | `ppocrv3_en_mobile` | 2022-05-09 | 11.4 | Apache-2.0 | English |
183
+ | `ppocrv3_latin_mobile` | 2022-05-09 | 11.4 | Apache-2.0 | Latin, English |
184
+
185
+ - `RAIL-M (modified)` is short for AI PUBS OPEN RAIL-M (modified).
186
+ - Models whose language column is `latex` are whole-image formula recognizers (formula image → LaTeX, no detection model).
187
+ - Use `oxocr inspect <name>` to view model details.
188
+ - `ppocr` models come from RapidOCR.
189
+
190
+ ```python
191
+ oxocr.readtext("shot.png", model="ppocrv5_ch_server")
192
+ oxocr.readtext("shot.png", model="ppocrv4_korean_mobile")
193
+
194
+ # Orientation classification: three weights available, input shape switches automatically with the weight
195
+ oxocr.readtext("shot.png", use_cls=True,
196
+ config={"model_options": {"params": {"cls_model": "textline_ori_server"}}})
197
+
198
+ # Formula recognition: whole formula image → LaTeX; postprocess skipped by default, LaTeX output as-is
199
+ oxocr.readtext("formula.png", model="pix2text_mfr") # 1.0 original
200
+ oxocr.readtext("formula.png", model="pix2text_mfr_1.5")
201
+ oxocr.readtext("formula.png", model="pix2text_mfr_quantized") # int8 encoder, faster
202
+ oxocr.readtext("formula.png", model="rapid_latex_ocr") # LaTeX-OCR (pix2tex), built-in preprocessing, <1s per formula on CPU
203
+
204
+ # DuGuang OCR: three tiers for Chinese/English; max uses SegLink detection, small/large use DB detection
205
+ oxocr.readtext("shot.png", model="duguang_ocr_large")
206
+ oxocr.readtext("shot.png", model="duguang_ocr_max")
207
+
208
+ # Khmer OCR: Khmer + English/Latin; long lines auto-split and stitched, vertical/180° optional
209
+ oxocr.readtext("shot.png", model="anaksor_ocr")
210
+
211
+ # Thai OCR: Thai + English; full-page auto-rotation/deskew, column-aware reading order, ~0.4s/page on CPU
212
+ oxocr.readtext("shot.png", model="openthai2.0_ocr")
213
+
214
+ # Indra multilingual: pick the dedicated model by dominant language (each recognizer also reads Latin)
215
+ oxocr.readtext("shot.png", model="indra_ocr_cjk") # CJK (Korean jamo auto-composed into syllables)
216
+ oxocr.readtext("shot.png", model="indra_ocr_rtl") # Arabic/Hebrew (logical-order output)
217
+ oxocr.readtext("formula.png", model="indra_ocr_math") # whole-image formula → LaTeX (no detection, same as MFR)
218
+ ```
219
+
220
+ ## CLI
221
+
222
+ Docker-style commands (`run` / `models` / `version`), see [docs/cli.md](docs/cli.md):
223
+
224
+ ```bash
225
+ oxocr run shot.png -m ppocrv6_tiny -M layout # recognize an image, output multi-column layout text
226
+ oxocr run shot.png --vis vis.png # recognize and save a visualization image
227
+ oxocr models ls # list models
228
+ oxocr models inspect ppocrv6_small # inspect model details
229
+ oxocr -h --lang zh # Chinese help (English by default)
230
+ ```
231
+
232
+ ## License
233
+
234
+ The code is open-sourced under the MIT License; model weights are not covered by this license and follow their respective license terms.