Commit Graph
7 Commits
Author SHA1 Message Date
SWHL 92c2d93a40 test: update PP-OCRv4/v5 unit testings 2026-06-22 22:07:04 +08:00
JinmingMei 9fe06b676c feat(python): support PP-OCRv6 (onnxruntime + openvino, det + rec) (#692)
* 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)
2026-06-18 21:18:58 +08:00
SWHL 80bbdc9615 test(tensorrt): skip TensorRT tests when not installed and exclude from parametrized suites 2026-02-26 17:34:30 +08:00
locviettriandCursor b132a915e7 feat(inference_engine): add TensorRT engine support (#623)
* feat(inference_engine): add TensorRT engine support

- Add TensorRT inference session with dynamic shape support
- Implement automatic engine building and caching per GPU architecture
- Add pre-allocated buffers with pinned memory optimization
- Support FP16/FP32/INT8 precision modes
- Add optimization profiles for det/rec/cls models
- Include comprehensive error handling and resource cleanup
- Add unit tests for TensorRT engine (skipped when unavailable)
- Add TensorRT configuration section in config.yaml

* fix(tensorrt): dynamically allocate output buffers to prevent overflow

* Update test_engine.py with TensorRT support final version

* feat(tensorrt): add model_type to engine cache key

- Include model_type in TensorRT engine cache key generation
- Ensures proper cache differentiation based on model_type

* fix(tensorrt): update maximum shape configurations for input and output tensors

- Increased max_shape values in config.yaml and engine_builder.py to 2048 for both detection and recognition tasks.
- Updated default maximum shapes in memory_utils.py to reflect the new limits for input and output buffers.

* feat(tensorrt): implement square input handling for MULTI models

- Added functionality to check if the model requires square input based on configuration.
- Implemented padding of input to square shape and cropping of output back to original dimensions.
- Introduced methods to determine maximum profile size and handle square input requirements for TensorRT inference.

---------

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-05 08:09:21 +08:00
SWHL 3a4a91020b test(mnn): add mnn unit testings 2026-01-28 22:18:58 +08:00
SWHL 5cd7de1e47 refactor: refactor paddle inference code (#622)
* refactor: refactor paddle inference code

* fix(paddle): correct typo and improve device env setup
2026-01-05 21:19:25 +08:00
SWHL 017b8fd5c7 feat: add en/el/th ppocr_v5_rec_mobile paddle/onnx/openvino (#546)
* feat: add en/el/th ppocr_v5_rec_mobile paddle/onnx/openvino

* test: change to a more secure code
2025-09-06 17:50:05 +08:00