Skip to content

Commit 219730b

Browse files
committed
Release FormulaOCR 1.1.0
1 parent 4cc3e17 commit 219730b

42 files changed

Lines changed: 8929 additions & 3684 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

FormulaOCR.spec

Lines changed: 101 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,21 @@
11
# -*- mode: python ; coding: utf-8 -*-
22
from pathlib import Path
3-
import importlib.util
3+
import importlib.metadata
44
import os
55
import sys
66

7-
from PyInstaller.utils.hooks import collect_all
7+
from PyInstaller.utils.hooks import collect_data_files
88
from PyInstaller.utils.hooks import copy_metadata
99

10+
# Keep headroom for third-party hooks without relying on the interpreter's
11+
# default recursion limit.
12+
sys.setrecursionlimit(max(sys.getrecursionlimit(), 5000))
13+
1014
# PyInstaller exposes SPECPATH as the directory containing this spec file,
1115
# not the spec filename itself. Taking `.parent` here points one directory
1216
# above the project when the spec is invoked directly.
1317
ROOT = Path(SPECPATH).resolve()
14-
paddleocr_spec = importlib.util.find_spec('paddleocr')
15-
if paddleocr_spec is None or not paddleocr_spec.submodule_search_locations:
16-
raise SystemExit('paddleocr==3.6.0 is required to build FormulaOCR.')
17-
paddleocr_package_dir = Path(
18-
next(iter(paddleocr_spec.submodule_search_locations))
19-
).resolve()
2018
datas = [
21-
(str(paddleocr_package_dir), 'PaddleOCR-main/paddleocr'),
2219
(str(ROOT / 'icon.png'), '.'),
2320
(str(ROOT / 'icon.ico'), '.'),
2421
]
@@ -93,24 +90,59 @@ for dll_names in (
9390
)
9491
if dll_path is not None:
9592
binaries.append((str(dll_path), '.'))
96-
hiddenimports = ['paddle', 'paddlex', 'numpy', 'tokenizers', 'onnxruntime', 'rapid_latex_ocr']
97-
datas += copy_metadata('tokenizers')
98-
datas += copy_metadata('latex2mathml')
99-
datas += copy_metadata('paddleocr')
100-
for package_name in (
101-
'paddle',
102-
'paddlex',
103-
'cv2',
93+
94+
# FormulaOCR loads Paddle's native inference extension directly and does not
95+
# execute the broad paddle package. Keep only the native CPU files proven by
96+
# frozen PP-FormulaNet+ L inference; mklml is dynamically loaded and therefore
97+
# must be listed even though it is not visible in the PE import table.
98+
paddle_distribution = importlib.metadata.distribution('paddlepaddle')
99+
paddle_root = Path(paddle_distribution.locate_file('paddle')).resolve()
100+
libpaddle = next(
101+
(
102+
path
103+
for path in sorted((paddle_root / 'base').glob('libpaddle*'))
104+
if path.is_file() and path.suffix.lower() in {'.pyd', '.so', '.dylib'}
105+
),
106+
None,
107+
)
108+
if libpaddle is None:
109+
raise SystemExit('paddlepaddle native inference extension was not found.')
110+
binaries.append((str(libpaddle), 'paddle/base'))
111+
required_paddle_libraries = {
112+
'common.dll',
113+
'libiomp5md.dll',
114+
'mkldnn.dll',
115+
'mklml.dll',
116+
'phi.dll',
117+
}
118+
for library_name in sorted(required_paddle_libraries):
119+
library_path = paddle_root / 'libs' / library_name
120+
if not library_path.is_file():
121+
raise SystemExit(f'Required Paddle library was not found: {library_path}')
122+
binaries.append((str(library_path), 'paddle/libs'))
123+
hiddenimports = [
124+
'numpy',
104125
'tokenizers',
105-
'pypdfium2',
106-
'latex2mathml',
107126
'onnxruntime',
108-
'rapid_latex_ocr',
109-
):
110-
package_datas, package_binaries, package_hiddenimports = collect_all(package_name)
111-
datas += package_datas
112-
binaries += package_binaries
113-
hiddenimports += package_hiddenimports
127+
'formula_ocr_app.paddle_formula_recognizer',
128+
'formula_ocr_app.model_downloader',
129+
'formula_ocr_app.rapid_recognizer',
130+
'formula_ocr_app.mathcraft_recognizer',
131+
'formula_ocr_app.pix2text_recognizer',
132+
'formula_ocr_app.mixtex_recognizer',
133+
'formula_ocr_app.unimernet_onnx_recognizer',
134+
'formula_ocr_app.rapid_model_downloader',
135+
'formula_ocr_app.mathcraft_model_downloader',
136+
'formula_ocr_app.pix2text_model_downloader',
137+
'formula_ocr_app.mixtex_model_downloader',
138+
'formula_ocr_app.unimernet_onnx_model_downloader',
139+
'formula_ocr_app.paddle_hf_model_downloader',
140+
]
141+
datas += copy_metadata('latex2mathml')
142+
datas += collect_data_files('latex2mathml', include_py_files=False)
143+
# Dynamic backend imports must be visible to static analysis. ONNX Runtime's
144+
# own PyInstaller hook collects the small capi DLL/PYD set; no tools,
145+
# quantization or transformers modules are needed by this application.
114146
hiddenimports = list(dict.fromkeys(hiddenimports))
115147

116148

@@ -123,7 +155,50 @@ a = Analysis(
123155
hookspath=[],
124156
hooksconfig={},
125157
runtime_hooks=[],
126-
excludes=['tensorflow', 'torch', 'torchvision', 'torchaudio', 'modelscope', 'matplotlib', 'sklearn', 'scipy', 'paddle.tensorrt', 'paddlex.inference.serving', 'shapely.tests'],
158+
excludes=[
159+
'tensorflow',
160+
'torch',
161+
'torchvision',
162+
'torchaudio',
163+
'modelscope',
164+
'matplotlib',
165+
'sklearn',
166+
'scipy',
167+
'paddle',
168+
'paddleocr',
169+
'paddlex',
170+
'cv2',
171+
'pypdfium2',
172+
'pandas',
173+
'filelock',
174+
'sqlite3',
175+
'_sqlite3',
176+
'chardet',
177+
'psutil',
178+
'setuptools',
179+
'coloredlogs',
180+
'humanfriendly',
181+
'flatbuffers',
182+
'sympy',
183+
'mpmath',
184+
'numpy.testing',
185+
'numpy.distutils',
186+
'numpy.f2py',
187+
'shapely',
188+
'rapid_latex_ocr',
189+
'onnxruntime.tools',
190+
'onnxruntime.quantization',
191+
'onnxruntime.transformers',
192+
'PIL.AvifImagePlugin',
193+
'PIL.FitsImagePlugin',
194+
'PIL.FliImagePlugin',
195+
'PIL.FpxImagePlugin',
196+
'PIL.Hdf5StubImagePlugin',
197+
'PIL.MicImagePlugin',
198+
'PIL.MpegImagePlugin',
199+
'PIL.SpiderImagePlugin',
200+
'paddle.tensorrt',
201+
],
127202
noarchive=False,
128203
optimize=0,
129204
)

NOTICE.md

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,22 @@
22

33
FormulaOCR depends on open-source OCR and formula-recognition components. This file records the main third-party projects used by the application and the notices users should keep when redistributing binaries or offline model packages.
44

5-
## PaddleOCR
5+
## PaddlePaddle, Paddle model assets, and PaddleX-compatible processing
66

7-
- Project: PaddleOCR
8-
- Repository: https://github.com/PaddlePaddle/PaddleOCR
9-
- Pinned Python package used for builds: `paddleocr==3.6.0`
10-
- Organization: PaddlePaddle / PaddleOCR Authors
7+
- Runtime: PaddlePaddle `paddlepaddle==3.2.0`
8+
- Repositories: https://github.com/PaddlePaddle/Paddle and https://github.com/PaddlePaddle/PaddleX
9+
- Model ecosystem: PaddlePaddle PP-FormulaNet, PP-FormulaNet+, UniMERNet, and `LaTeX_OCR_rec`
10+
- Organization: PaddlePaddle and the respective model authors
1111
- License: Apache License 2.0
12-
- Use in this project: formula recognition through PaddleOCR/PaddleX formula-recognition models.
12+
- Use in this project: direct native inference through `libpaddle`; FormulaOCR implements the required image preprocessing and tokenizer-based decoding locally.
1313

14-
PaddleOCR source code and model files are not vendored in this repository. If you redistribute a packaged build that includes PaddleOCR, PaddlePaddle, PaddleX, runtime libraries, or model weights, keep the original third-party license files, copyright notices, and any model-specific usage terms with the distributed package.
14+
FormulaOCR does not import or redistribute the PaddleOCR or PaddleX Python packages. Its PP-FormulaNet/UniMERNet preprocessing and decoding behavior is compatible with and derived from the Apache-2.0 PaddleX formula-recognition processors. Paddle model files are downloaded separately from official release sources. If you redistribute a packaged build containing PaddlePaddle native libraries or model weights, keep the applicable upstream license, copyright notices, model cards, and usage terms.
1515

1616
Suggested citation or acknowledgement:
1717

1818
```text
19-
This software uses PaddleOCR, an open-source OCR toolkit from the PaddlePaddle ecosystem:
20-
https://github.com/PaddlePaddle/PaddleOCR
19+
This software uses PaddlePaddle native inference and formula-recognition model assets from the Paddle ecosystem:
20+
https://github.com/PaddlePaddle/Paddle
2121
```
2222

2323
## RapidLaTeXOCR and ONNX Runtime
@@ -28,11 +28,11 @@ https://github.com/PaddlePaddle/PaddleOCR
2828
- Use: optional community formula-recognition backend derived from LaTeX-OCR/pix2tex.
2929
- Runtime: Microsoft ONNX Runtime, MIT License.
3030

31-
RapidLaTeXOCR model files are downloaded on demand from the project's official GitHub Release and verified with SHA-256. They are not committed to this repository or included in the default application archive.
31+
RapidLaTeXOCR model files are downloaded on demand from the project's official GitHub Release and verified with SHA-256. FormulaOCR implements the small Pillow/NumPy/ONNX inference adapter locally and does not depend on the RapidLaTeXOCR Python package. The model files are not committed to this repository or included in the default application archive.
3232

3333
## UniMERNet
3434

35-
UniMERNet was developed by Shanghai AI Laboratory and is exposed here through the official PaddleOCR/PaddleX inference model catalog. Users redistributing model weights should retain the upstream model card, license, and attribution applicable to the downloaded release.
35+
UniMERNet was developed by Shanghai AI Laboratory and is exposed here through the official Paddle model catalog. FormulaOCR executes the exported model directly with Paddle Inference. Users redistributing model weights should retain the upstream model card, license, and attribution applicable to the downloaded release.
3636

3737
## UniMERNet Small ONNX
3838

@@ -102,4 +102,12 @@ confirm it before first download/use. Do not include MixTeX weights in a
102102
commercial binary or offline package without written permission from the
103103
upstream rights holder.
104104

105-
The application also uses Python packages listed in `requirements.txt`, including Pillow, paddlepaddle, paddlex, ONNX Runtime, RapidLaTeXOCR, latex2mathml, requests, aiohttp, tokenizers, ftfy, and PyInstaller. Their licenses are controlled by their respective upstream projects.
105+
## Inno Setup Simplified Chinese messages
106+
107+
The Windows installer includes `installer/ChineseSimplified.isl` from the Inno
108+
Setup source repository at commit
109+
`69a2554fc9551f1d3da8df8ba659007dea3f906f`. The translation header credits
110+
Zhenghan Yang (Kira) and is retained verbatim apart from repository line-ending
111+
normalization. This file is used only while compiling the Windows installer.
112+
113+
The application also uses the Python packages listed in `requirements.txt`: Pillow, NumPy, PaddlePaddle, PyYAML, Requests, ONNX Runtime, tokenizers, ftfy, latex2mathml, and PyInstaller. Their licenses are controlled by their respective upstream projects.

0 commit comments

Comments
 (0)