|
--- |
|
license: apache-2.0 |
|
tags: |
|
- onnx |
|
- paddleocr |
|
- ocr |
|
- computer-vision |
|
- text-recognition |
|
- text-detection |
|
library_name: onnxruntime |
|
pipeline_tag: image-to-text |
|
base_model: |
|
- PaddlePaddle/PP-OCRv5_server_det |
|
- PaddlePaddle/PP-OCRv5_server_rec |
|
--- |
|
|
|
# PaddleOCR ONNX Models |
|
|
|
PaddleOCR PP-OCRv5 models converted to ONNX format for efficient OCR inference. |
|
|
|
[English](#english) | [中文說明](#中文說明) |
|
|
|
## 中文說明 |
|
|
|
這是 PaddleOCR PP-OCRv5 模型的 ONNX 格式版本,用於高效率的文字辨識推理。 |
|
|
|
### 模型檔案說明 |
|
|
|
| 檔案名稱 | 說明 | |
|
|---------|------| |
|
| `PP-OCRv5_server_det_infer.onnx` | 文字檢測模型 - 偵測圖片中文字的位置 | |
|
| `PP-OCRv5_server_rec_infer.onnx` | 文字辨識模型 - 辨識文字內容 | |
|
| `PP-LCNet_x1_0_textline_ori_infer.onnx` | 文字方向分類模型 | |
|
| `PP-LCNet_x1_0_doc_ori_infer.onnx` | 文件方向修正模型 | |
|
| `UVDoc_infer.onnx` | 文件展平模型 | |
|
| `PP-OCRv5_server_rec_infer.yml` | 字符字典配置檔 | |
|
|
|
### 快速使用 |
|
|
|
```python |
|
from huggingface_hub import hf_hub_download |
|
|
|
# 下載文字檢測模型 |
|
det_model_path = hf_hub_download( |
|
repo_id="marsena/paddleocr-onnx-models", |
|
filename="PP-OCRv5_server_det_infer.onnx" |
|
) |
|
|
|
# 下載文字辨識模型 |
|
rec_model_path = hf_hub_download( |
|
repo_id="marsena/paddleocr-onnx-models", |
|
filename="PP-OCRv5_server_rec_infer.onnx" |
|
) |
|
``` |
|
|
|
### 一次下載所有模型 |
|
|
|
```python |
|
from huggingface_hub import snapshot_download |
|
|
|
# 下載所有模型檔案到本地資料夾 |
|
snapshot_download( |
|
repo_id="marsena/paddleocr-onnx-models", |
|
local_dir="./paddleocr_onnx" |
|
) |
|
``` |
|
|
|
### 支援的語言和文字類型 |
|
|
|
- **語言支援**: 簡體中文、繁體中文、英文、日文 |
|
- **文字類型**: 印刷體、手寫體、直書文字、旋轉文字、彎曲文字 |
|
- **輸入格式**: 圖片檔案 (JPEG, PNG) |
|
- **運行環境**: 支援 CPU 和 GPU 推理 |
|
|
|
--- |
|
|
|
## English |
|
|
|
## Model Files |
|
|
|
| File | Description | |
|
|------|-------------| |
|
| `PP-OCRv5_server_det_infer.onnx` | Text detection model | |
|
| `PP-OCRv5_server_rec_infer.onnx` | Text recognition model | |
|
| `PP-LCNet_x1_0_textline_ori_infer.onnx` | Text orientation classification | |
|
| `PP-LCNet_x1_0_doc_ori_infer.onnx` | Document orientation correction | |
|
| `UVDoc_infer.onnx` | Document unwarping | |
|
| `PP-OCRv5_server_rec_infer.yml` | Character dictionary config | |
|
|
|
## Source Models |
|
|
|
These ONNX models are converted from official PaddlePaddle PP-OCRv5 models: |
|
|
|
- **Detection Model**: [PaddlePaddle/PP-OCRv5_server_det](https://huggingface.co/PaddlePaddle/PP-OCRv5_server_det) |
|
- **Recognition Model**: [PaddlePaddle/PP-OCRv5_server_rec](https://huggingface.co/PaddlePaddle/PP-OCRv5_server_rec) |
|
- **Official Documentation**: [PP-OCRv5 Introduction](https://paddlepaddle.github.io/PaddleOCR/main/en/version3.x/algorithm/PP-OCRv5/PP-OCRv5.html) |
|
|
|
## Usage |
|
|
|
### Download Specific Model |
|
|
|
```python |
|
from huggingface_hub import hf_hub_download |
|
|
|
# Download detection model |
|
det_model_path = hf_hub_download( |
|
repo_id="marsena/paddleocr-onnx-models", |
|
filename="PP-OCRv5_server_det_infer.onnx" |
|
) |
|
|
|
# Download recognition model |
|
rec_model_path = hf_hub_download( |
|
repo_id="marsena/paddleocr-onnx-models", |
|
filename="PP-OCRv5_server_rec_infer.onnx" |
|
) |
|
``` |
|
|
|
### Download All Models |
|
|
|
```python |
|
from huggingface_hub import snapshot_download |
|
|
|
# Download all model files to local directory |
|
snapshot_download( |
|
repo_id="marsena/paddleocr-onnx-models", |
|
local_dir="./paddleocr_onnx" |
|
) |
|
``` |
|
|
|
### ONNX Runtime Inference |
|
|
|
```python |
|
import onnxruntime as ort |
|
import numpy as np |
|
|
|
# Load model |
|
session = ort.InferenceSession("PP-OCRv5_server_det_infer.onnx") |
|
|
|
# Run inference |
|
input_name = session.get_inputs()[0].name |
|
output = session.run(None, {input_name: input_data}) |
|
``` |
|
|
|
## Model Specifications |
|
|
|
- **Languages**: Simplified Chinese, Traditional Chinese, English, Japanese |
|
- **Text Types**: Printed text, handwriting, vertical text, rotated text |
|
- **Input Format**: Images (JPEG, PNG) |
|
- **Output Format**: Bounding boxes + recognized text |
|
- **Runtime**: ONNX Runtime 1.16+ |
|
- **Hardware**: CPU and GPU inference supported |
|
|
|
## License |
|
|
|
These models follow the **Apache License 2.0**, consistent with the original PaddleOCR project. |
|
|
|
- **PaddleOCR Repository**: https://github.com/PaddlePaddle/PaddleOCR |
|
- **License Details**: [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0) |
|
|
|
## Conversion Information |
|
|
|
- **Conversion Tool**: Paddle2ONNX |
|
- **ONNX Version**: 1.12+ |
|
- **Source Framework**: PaddlePaddle 2.5+ |
|
- **Conversion Date**: January 2025 |
|
|
|
## Citation |
|
|
|
If you use these models in your research, please cite the original PaddleOCR paper: |
|
|
|
```bibtex |
|
@misc{paddleocr2020, |
|
title={PaddleOCR: Awesome multilingual OCR toolkits}, |
|
author={PaddlePaddle Authors}, |
|
howpublished = {\url{https://github.com/PaddlePaddle/PaddleOCR}}, |
|
year={2020} |
|
} |
|
``` |
|
|
|
## Issues |
|
|
|
For model usage issues, please report to the original PaddleOCR repository: |
|
- **PaddleOCR Issues**: https://github.com/PaddlePaddle/PaddleOCR/issues |