Downloads · 30 days
11
8% of all-time downloads
AXERA-TECH/PPOCR_v6
PPOCR_v6 is a text classification model from AXERA-TECH. Use it when you need a label for a piece of text. The card lists the license as mit.
Downloads · 30 days
11
8% of all-time downloads
All-time downloads
133
Public
Repo size
132 MB
Likes
0
Public
Click a slice to open those files.
.axmodel82.1 MB · 66%
From the Hugging Face model README
English | 中文
This version of PPOCR_v6 has been converted to run on AXERA NPU with w8a16 quantization.
If you are interested in model conversion, you can export axmodel through the following links:
ax-samples-github, other interesting samples
| Chip | Model | npu_mode | Latency (ms) |
|---|---|---|---|
| PP-OCRv6_small_det | NPU1 | 42.158 | |
| PP-OCRv6_small_det | NPU3 | 23.837 | |
| AX650 | PP-LCNet_x0_25_textline_ori | NPU1 | 0.294 |
| PP-LCNet_x0_25_textline_ori | NPU3 | 0.172 | |
| PP-OCRv6_small_rec | NPU1 | 2.473 | |
| PP-OCRv6_small_rec | NPU3 | 1.073 | |
| - | - | - | |
| PP-OCRv6_small_det | NPU1 | \ | |
| PP-OCRv6_small_det | NPU2 | 186.738 | |
| AX630c | PP-LCNet_x0_25_textline_ori | NPU1 | 0.428 |
| PP-LCNet_x0_25_textline_ori | NPU2 | 0.381 | |
| PP-OCRv6_small_rec | NPU1 | 25.251 | |
| PP-OCRv6_small_rec | NPU2 | 9.535 | |
| - | - | - | |
| PP-OCRv6_small_det | NPU1 | \ | |
| PP-OCRv6_small_det | NPU2 | 198.401 | |
| AX615 | PP-LCNet_x0_25_textline_ori | NPU1 | 0.851 |
| PP-LCNet_x0_25_textline_ori | NPU2 | 0.728 | |
| PP-OCRv6_small_rec | NPU1 | 36.178 | |
| PP-OCRv6_small_rec | NPU2 | 8.036 |
Benchmarking command:
ax_run_model -w 10 -r 100 -m xx.axmodel
Recognition and detection ONNX model sources: small-det-onnx and small-rec-onnx from PaddlePaddle/PP-OCRv6
Text direction classifier: AXERA-TECH/PPOCR_v5
Download all files from this repository to your device.
PPOCR_v6# tree -L 1
.
|-- 11.jpg # Test image
|-- README-zh.md
|-- README.md
|-- axmodel # Axmodel files for each version
|-- cls.json # Text direction classifier axmodel conversion config
|-- dataset # Quantization dataset & test dataset
|-- det.json # Detection model axmodel conversion config
|-- fonts # Rendering fonts
|-- onnx # Original ONNX files for each model
|-- ppocrv6_ax.py # Axmodel inference pipeline
|-- ppocrv6_onnx.py # ONNX inference pipeline
|-- rec.json # Recognition model axmodel conversion config
|-- res-ax.jpg # Axmodel inference result
|-- res-onnx.jpg # ONNX inference result
|-- run_det_ax.py # Detection axmodel accuracy test script
|-- run_det_onnx.py # Detection ONNX accuracy test script
|-- run_rec_ax.py # Recognition axmodel accuracy test script
`-- run_rec_onnx.py # Recognition ONNX accuracy test script
cd dataset
sh download_quant_dataset.sh
sh download_val_dataset.sh
cd ..
pulsar2 build --config det.json
pulsar2 build --config cls.json
pulsar2 build --config rec.json
python3 run_det_onnx.py --resize_mode letterbox # resize_mode options: letterbox (default), stretch (official)
"""
Images: 50
GT boxes: 201
DET boxes: 151
Matched: 77
Precision: 0.5099 (50.99%)
Recall: 0.3831 (38.31%)
Hmean (F1): 0.4375
"""
python3 run_det_ax.py --resize_mode letterbox # resize_mode options: letterbox (default), stretch (official)
"""
Images: 50
GT boxes: 201
DET boxes: 150
Matched: 75
Precision: 0.5000 (50.00%)
Recall: 0.3731 (37.31%)
Hmean (F1): 0.4274
"""
Note: When resize_mode is stretch, it follows the official approach of directly resizing to the model input size. When resize_mode is letterbox, it pads the bottom-right corner, which has a smaller gap from the dynamic-input ONNX model and achieves better metrics in this test. You can download the inference.onnx with dynamic input shape from small-det-onnx for comparison.
python3 run_rec_onnx.py
"""
Total samples: 2077
Correct (exact match): 1563
Accuracy: 0.7525 (75.25%)
Norm Edit Distance: 0.8947
"""
python3 run_rec_ax.py
"""
Total samples: 2077
Correct (exact match): 1518
Accuracy: 0.7309 (73.09%)
Norm Edit Distance: 0.8781
"""
Run inference on AX650 host, such as M4N-Dock (AXERA Pi Pro).
Input image:

python3 ppocrv6_onnx.py --use_angle_cls --visualize --image 11.jpg
python3 ppocrv6_ax.py --use_angle_cls --visualize --image 11.jpg
Output image:

The tiny recognition model has a large quantization error. Metrics are as follows:
onnx-preds:
Total samples: 2077
Correct (exact match): 1271
Accuracy: 0.6119 (61.19%)
Norm Edit Distance: 0.8263
ax-w8a16-preds:
Total samples: 2077
Correct (exact match): 1178
Accuracy: 0.5672 (56.72%)
Norm Edit Distance: 0.7941