Concurrent first calls could initialize det/cls/rec more than once. Double-check each loader under its own lock.
Fixes#724
Co-authored-by: Yuzhong Zhang <BetterAndBetterII@users.noreply.github.com>
MNNInferSession.__call__ extracted session output via
np.array(out_tensor.getData()).reshape(out_shape), which marshals
tensor contents through a slow per-element Python path. For a
PP-OCRv6 medium recognizer output (~17MB), this cost ~454ms versus
~210ms for the actual GPU inference that produced it.
Switch to getNumpyData(), which exposes the buffer directly. An
explicit copy is required since getNumpyData() returns a view into
memory owned by out_tensor; without it, out_tensor going out of
scope or being reused across shape changes caused intermittent
segfaults.
On a 39-box real-world image, total recognition time dropped from
~22s to ~8.4s. Per-crop output extraction dropped from ~454ms to
~10ms.
Fixes intermittent segfault risk from unmanaged zero-copy tensor
lifetime as a side effect.
* feat(python): support PP-OCRv6 for onnxruntime and openvino
Add PP-OCRv6 rec and det models (tiny/small/medium) for onnxruntime and openvino engines. v6 ships no cls model; reuse PP-OCRv5 cls.
- typings.py: add OCRVersion.PPOCRV6 and ModelType.TINY/SMALL/MEDIUM
- default_models.yaml: add PP-OCRv6 blocks under onnxruntime/openvino with PaddlePaddle official ModelScope URLs, verified SHA256, and dict_url (PaddleOCR dict files)
Verified end-to-end on ch_en_num.jpg with v6 small det+rec + v5 cls (onnxruntime): 18 text lines recognized correctly.
* fix(python): use uniquely-named PP-OCRv6 model URLs to avoid cache collision
PP-OCRv6 official ONNX exports are all named inference.onnx, causing det and rec models to overwrite each other in RapidOCR's cache (cache_dir/Path(url).name). Switch model_dir/dict_url to a mirror with unique filenames (ch_PP-OCRv6_<task>_<size>.onnx) under modelscope.cn/models/jaminmei/PP-OCRv6-onnx@v1.0. SHA256 unchanged (byte-identical files, renamed only).
Verified onnxruntime + openvino: no more redownload-on-collision; second run is pure cache hit.
* test(python): add PP-OCRv6 det/rec unit tests for onnxruntime and openvino
Mirror the test_ppocrv5_det/rec_mobile pattern. v6 small det on ch_en_num.jpg -> 18 boxes; v6 small rec on text_rec.jpg -> '韩国小馆'. Parametrized over the two engines v6 supports (ONNXRUNTIME, OPENVINO). Existing 100 tests unaffected (verified via collect-only).
Verified: 4 new tests pass (onnxruntime + openvino x det/rec).
* chore(python): switch PP-OCRv6 model URLs to official RapidAI/RapidOCR repo
- det/rec x tiny/small/medium now point to modelscope.cn/RapidAI/RapidOCR (official SWHL conversion, not contributor mirror)
- update SHA256 to the official files' hashes
- drop rec dict_url: official ONNX embeds the character list in metadata (session.have_key() path), matching v4/v5 onnx convention
- verified: 4 v6 unit tests pass; det benchmark Hmean identical to prior mirror-based run (0.8263/0.8492/0.8421 for tiny/small/medium)
* chore: add pyproject toml configuration
* build: migrate RapidOCR wheel packaging to pyproject.toml
- add PEP 517 setuptools build configuration
- derive package version from git tags via setuptools-scm
- move wheel model preparation into an explicit tools script
- generate MANIFEST.in for default model assets before building
- avoid importing rapidocr during package metadata generation
* ci: build release wheels from validated git tags
* build: align package runtime support with Python 3.8
- set Requires-Python to >=3.8
- remove Python 3.6 and 3.7 classifiers
- make wheel asset preparation script type hints Python 3.8 compatible
- clarify split between build-time and wheel runtime support
* Update to_markdown.py
修改重排规则:
中文段落
表格/多栏
标题与正文混排
OCR 框轻微倾斜
* Potential fix for pull request finding
refactor: format function call for readability
- Wrap `cls.get_gap_text` call into multi-line format
- No functional changes, only code style improvement
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
---------
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
- pass --lang_type into RapidOCR recognition config
- skip CLI visualization when OCR or word results are empty
- validate parameter update keys before applying config updates
- add regression tests for CLI language, empty visualization, and invalid params