Add comprehensive README with usage examples and license info
Browse files
README.md
ADDED
@@ -0,0 +1,154 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# PaddleOCR ONNX Models
|
2 |
+
|
3 |
+
π₯ **ONNX format models converted from PaddleOCR for easy deployment and testing**
|
4 |
+
|
5 |
+
## π Model Description
|
6 |
+
|
7 |
+
This repository contains ONNX format models converted from [PaddleOCR](https://github.com/PaddlePaddle/PaddleOCR), a practical ultra-lightweight OCR system. These models are optimized for production deployment and cross-platform compatibility.
|
8 |
+
|
9 |
+
## π¦ Model Files
|
10 |
+
|
11 |
+
| File Name | Size | Description |
|
12 |
+
|-----------|------|-------------|
|
13 |
+
| `PP-OCRv5_server_det_infer.onnx` | 84MB | Text detection model - locates text regions in images |
|
14 |
+
| `PP-OCRv5_server_rec_infer.onnx` | 81MB | Text recognition model - recognizes text content |
|
15 |
+
| `UVDoc_infer.onnx` | 30MB | Document rectification model - corrects document perspective |
|
16 |
+
| `PP-LCNet_x1_0_doc_ori_infer.onnx` | 6.5MB | Document orientation detection |
|
17 |
+
| `PP-LCNet_x1_0_textline_ori_infer.onnx` | 6.5MB | Text line orientation detection |
|
18 |
+
| `PP-OCRv5_server_rec_infer.yml` | 145KB | Recognition model configuration file |
|
19 |
+
|
20 |
+
**Total Size:** ~208MB
|
21 |
+
|
22 |
+
## π Quick Start
|
23 |
+
|
24 |
+
### Installation
|
25 |
+
|
26 |
+
```bash
|
27 |
+
pip install huggingface_hub onnxruntime
|
28 |
+
```
|
29 |
+
|
30 |
+
### Download Models
|
31 |
+
|
32 |
+
```python
|
33 |
+
from huggingface_hub import hf_hub_download
|
34 |
+
import os
|
35 |
+
|
36 |
+
def download_paddleocr_models():
|
37 |
+
"""Download all PaddleOCR ONNX models"""
|
38 |
+
model_files = [
|
39 |
+
"PP-OCRv5_server_det_infer.onnx",
|
40 |
+
"PP-OCRv5_server_rec_infer.onnx",
|
41 |
+
"UVDoc_infer.onnx",
|
42 |
+
"PP-LCNet_x1_0_doc_ori_infer.onnx",
|
43 |
+
"PP-LCNet_x1_0_textline_ori_infer.onnx",
|
44 |
+
"PP-OCRv5_server_rec_infer.yml"
|
45 |
+
]
|
46 |
+
|
47 |
+
cache_dir = "models"
|
48 |
+
os.makedirs(cache_dir, exist_ok=True)
|
49 |
+
|
50 |
+
for file in model_files:
|
51 |
+
print(f"Downloading {file}...")
|
52 |
+
hf_hub_download(
|
53 |
+
repo_id="marsena/paddleocr-test",
|
54 |
+
filename=file,
|
55 |
+
local_dir=cache_dir
|
56 |
+
)
|
57 |
+
print("All models downloaded!")
|
58 |
+
|
59 |
+
# Download models
|
60 |
+
download_paddleocr_models()
|
61 |
+
```
|
62 |
+
|
63 |
+
### Basic Usage
|
64 |
+
|
65 |
+
```python
|
66 |
+
import onnxruntime as ort
|
67 |
+
import numpy as np
|
68 |
+
from PIL import Image
|
69 |
+
|
70 |
+
# Load detection model
|
71 |
+
det_session = ort.InferenceSession("models/PP-OCRv5_server_det_infer.onnx")
|
72 |
+
|
73 |
+
# Load recognition model
|
74 |
+
rec_session = ort.InferenceSession("models/PP-OCRv5_server_rec_infer.onnx")
|
75 |
+
|
76 |
+
# Your OCR pipeline implementation here...
|
77 |
+
```
|
78 |
+
|
79 |
+
## π·οΈ Model Tags
|
80 |
+
|
81 |
+
- **Framework:** ONNX
|
82 |
+
- **Task:** Computer Vision, OCR
|
83 |
+
- **Language:** Multi-language support
|
84 |
+
- **Domain:** Text Detection, Text Recognition
|
85 |
+
|
86 |
+
## π§ Technical Details
|
87 |
+
|
88 |
+
### Conversion Process
|
89 |
+
|
90 |
+
These models were converted from PaddlePaddle format to ONNX format for broader compatibility:
|
91 |
+
|
92 |
+
1. **Source:** Original PaddleOCR models from PaddlePaddle Hub
|
93 |
+
2. **Conversion:** PaddlePaddle β ONNX format
|
94 |
+
3. **Optimization:** Model optimization for inference speed
|
95 |
+
4. **Validation:** Output consistency verification
|
96 |
+
|
97 |
+
### System Requirements
|
98 |
+
|
99 |
+
- **Runtime:** ONNX Runtime
|
100 |
+
- **Python:** 3.7+
|
101 |
+
- **Memory:** Minimum 2GB RAM recommended
|
102 |
+
- **Platform:** Cross-platform (Windows, Linux, macOS)
|
103 |
+
|
104 |
+
## π License
|
105 |
+
|
106 |
+
This project follows the **Apache 2.0 License**, consistent with the original PaddleOCR project.
|
107 |
+
|
108 |
+
### Original PaddleOCR License
|
109 |
+
|
110 |
+
```
|
111 |
+
Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved.
|
112 |
+
|
113 |
+
Licensed under the Apache License, Version 2.0 (the "License");
|
114 |
+
you may not use this file except in compliance with the License.
|
115 |
+
You may obtain a copy of the License at
|
116 |
+
|
117 |
+
http://www.apache.org/licenses/LICENSE-2.0
|
118 |
+
|
119 |
+
Unless required by applicable law or agreed to in writing, software
|
120 |
+
distributed under the License is distributed on an "AS IS" BASIS,
|
121 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
122 |
+
See the License for the specific language governing permissions and
|
123 |
+
limitations under the License.
|
124 |
+
```
|
125 |
+
|
126 |
+
## π Acknowledgments
|
127 |
+
|
128 |
+
- **Original Project:** [PaddleOCR](https://github.com/PaddlePaddle/PaddleOCR) by PaddlePaddle Team
|
129 |
+
- **Framework:** [PaddlePaddle](https://github.com/PaddlePaddle/Paddle)
|
130 |
+
- **Conversion Tools:** ONNX ecosystem
|
131 |
+
|
132 |
+
## π Citation
|
133 |
+
|
134 |
+
If you use these models in your research, please cite the original PaddleOCR paper:
|
135 |
+
|
136 |
+
```bibtex
|
137 |
+
@misc{paddleocr2020,
|
138 |
+
title={PaddleOCR: Awesome multilingual OCR toolkits},
|
139 |
+
author={PaddlePaddle Authors},
|
140 |
+
year={2020},
|
141 |
+
howpublished={\url{https://github.com/PaddlePaddle/PaddleOCR}}
|
142 |
+
}
|
143 |
+
```
|
144 |
+
|
145 |
+
## β Issues & Support
|
146 |
+
|
147 |
+
For issues related to:
|
148 |
+
- **Model conversion:** Create an issue in this repository
|
149 |
+
- **Original PaddleOCR:** Visit [PaddleOCR Issues](https://github.com/PaddlePaddle/PaddleOCR/issues)
|
150 |
+
- **ONNX Runtime:** Visit [ONNX Runtime Issues](https://github.com/microsoft/onnxruntime/issues)
|
151 |
+
|
152 |
+
---
|
153 |
+
|
154 |
+
**Note:** This is a community contribution for easier deployment of PaddleOCR models. For production use, please ensure compliance with your specific requirements and test thoroughly.
|