Commit b3b02997 authored by yangql's avatar yangql
Browse files

格式修改

parent 3859b205
# PaddleOCR
## 论文
PaddleOCR通过det、rec、cls三个模型分别实现字符检测、字符识别和字符方向分类的应用
## 模型介绍
目前已知运行速度最快、支持最广,完全开源免费并支持离线快速部署的多平台多语言OCR。。
det模型主要用DB算法,参考论文如下:
https://arxiv.org/pdf/1911.08947.pdf
rec模型主要用SVTR算法,参考论文如下:
https://arxiv.org/pdf/2205.00159.pdf
cls模型用mobilenetv3实现通用分类,参考论文如下:
https://arxiv.org/pdf/1905.02244.pdf
## 模型结构
PaddleOCR使用ch_PP-OCRv3_det + ch_ppocr_mobile_v2.0_cls + ch_PP-OCRv3_rec三个模型进行图像中的文本识别。
det:
## Python版本推理
![image](https://developer.hpccube.com/codes/modelzoo/paddleocr/-/raw/main/configs/det/dbnet-arc.png)
本次采用PaddleOCR模型基于ONNXRuntime推理框架进行图像文本识别,模型文件下载链接:https://pan.baidu.com/s/1uGHhimKLb5k5f9xaFmNBwQ , 提取码:ggvz ,并将ch_PP-OCRv3_det_infer.onnx、ch_ppocr_mobile_v2.0_cls_infer.onnx、ch_PP-OCRv3_rec_infer.onnx模型文件保存在Resource/Models文件夹下。下面介绍如何运行python代码示例,Python示例的详细说明见Doc目录下的Tutorial_Python.md。
rec:
### 下载镜像
![image](https://developer.hpccube.com/codes/modelzoo/paddleocr/-/raw/main/configs/rec/SVTR-arc.png)
在光源中下载镜像:
cls:
```python
![image](https://developer.hpccube.com/codes/modelzoo/paddleocr/-/raw/main/configs/cls/mobilenetv3-arc.png)
## 算法原理
## 环境配置
### Docker
拉取镜像:
```
docker pull image.sourcefind.cn:5000/dcu/admin/base/custom:ort1.14.0_migraphx3.0.0-dtk22.10.1
```
创建并启动容器,安装相关依赖:
```
docker run --shm-size 16g --network=host --name=paddleocr_ort --privileged --device=/dev/kfd --device=/dev/dri --group-add video --cap-add=SYS_PTRACE --security-opt seccomp=unconfined -v $PWD/paddleocr_ort:/home/paddleocr_ort -it <Your Image ID> /bin/bash
### 设置Python环境变量
# 激活dtk
source /opt/dtk/env.sh
```
## 数据集
## 推理
### Python版本推理
本次采用PaddleOCR模型基于ONNXRuntime推理框架进行图像文本识别,模型文件下载链接:https://pan.baidu.com/s/1uGHhimKLb5k5f9xaFmNBwQ , 提取码:ggvz ,并将ch_PP-OCRv3_det_infer.onnx、ch_ppocr_mobile_v2.0_cls_infer.onnx、ch_PP-OCRv3_rec_infer.onnx模型文件保存在Resource/Models文件夹下。下面介绍如何运行python代码示例,Python示例的详细说明见Doc目录下的Tutorial_Python.md。
#### 设置Python环境变量
```
export PYTHONPATH=/opt/dtk/lib:$PYTHONPATH
```
### 安装依赖
#### 运行示例
```python
# 进入paddleocr ort工程根目录
cd <path_to_paddleocr_ort>
......@@ -35,54 +63,30 @@ cd Python/
# 安装依赖
pip install -r requirements.txt
```
### 运行示例
```python
python paddleocr.py
```
如下所示,通过输入图像,PaddleOCR模型可以识别出文字和文本框。
```
[[[[245.0, 9.0], [554.0, 8.0], [554.0, 27.0], [245.0, 28.0]], '人生活的真实写照:善有善报,恶有恶报。', '0.9306996673345566'], [[[9.0, 49.0], [522.0, 50.0], [522.0, 69.0], [9.0, 68.0]], '我们中国人有一句俗语说:“种瓜得瓜,种豆得豆。”而这就是每个', '0.9294075581335253'], [[[84.0, 105.0], [555.0, 104.0], [555.0, 125.0], [85.0, 127.0]], "every man's life: good begets good, and evil leads to evil.", '0.8932319914301237'], [[[28.0, 147.0], [556.0, 146.0], [556.0, 168.0], [28.0, 169.0]], 'melons; if he sows beans, he will reap beans." And this is true of', '0.900923888185131'], [[[0.0, 185.0], [524.0, 188.0], [524.0, 212.0], [0.0, 209.0]], 'We Chinese have a saying:"If a man plants melons, he will reap', '0.9216671202863965'], [[[295.0, 248.0], [553.0, 248.0], [553.0, 264.0], [295.0, 264.0]], '它不仅适用于今生,也适用于来世。', '0.927988795673146'], [[[14.0, 289.0], [554.0, 290.0], [554.0, 307.0], [14.0, 306.0]], '一每一个行为都有一种结果。在我看来,这种想法是全宇宙的道德基础;', '0.88565122719967'], [[[9.0, 330.0], [521.0, 330.0], [521.0, 349.0], [9.0, 349.0]], '假如说过去的日子曾经教给我们一些什么的话,那就是有因必有果一', '0.9162070232052957'], [[[343.0, 388.0], [555.0, 388.0], [555.0, 405.0], [343.0, 405.0]], 'in this world and the next.', '0.8764956444501877'], [[[15.0, 426.0], [554.0, 426.0], [554.0, 448.0], [15.0, 448.0]], 'opinion, is the moral foundation of the universe; it applies equally', '0.9183026262815448'], [[[62.0, 466.0], [556.0, 468.0], [556.0, 492.0], [62.0, 490.0]], 'effect - every action has a consequence. This thought, in my', '0.9308378403304053']]
```
## C++版本推理
### C++版本推理
本次采用PaddleOCR模型基于ONNXRuntime推理框架进行图像文本识别,模型文件下载链接:https://pan.baidu.com/s/1uGHhimKLb5k5f9xaFmNBwQ , 提取码:ggvz ,并将ch_PP-OCRv3_det_infer.onnx、ch_ppocr_mobile_v2.0_cls_infer.onnx、ch_PP-OCRv3_rec_infer.onnx模型文件保存在Resource/Models文件夹下。下面介绍如何运行python代码示例,Python示例的详细说明见Doc目录下的Tutorial_Cpp.md。
### 下载镜像
```
docker pull image.sourcefind.cn:5000/dcu/admin/base/custom:ort1.14.0_migraphx3.0.0-dtk22.10.1
```
### 构建工程
#### 构建工程
```
rbuild build -d depend
```
### 设置环境变量
#### 设置环境变量
将依赖库依赖加入环境变量LD_LIBRARY_PATH,在~/.bashrc中添加如下语句:
```
export LD_LIBRARY_PATH=<path_to_paddleocr_ort>/depend/lib64/:$LD_LIBRARY_PATH
```
然后执行:
```
source ~/.bashrc
source /opt/dtk/env.sh
```
### 运行示例
```cpp
```
# 进入paddleocr ort工程根目录
cd <path_to_paddleocr_ort>
......@@ -93,8 +97,13 @@ cd build/
./PaddleOCR
```
如下所示,通过输入图像,PaddleOCR模型可以识别出文字和文本框,结果保存在/Resource/Images/文件夹中。
## result
### python版本
```
[[[[245.0, 9.0], [554.0, 8.0], [554.0, 27.0], [245.0, 28.0]], '人生活的真实写照:善有善报,恶有恶报。', '0.9306996673345566'], [[[9.0, 49.0], [522.0, 50.0], [522.0, 69.0], [9.0, 68.0]], '我们中国人有一句俗语说:“种瓜得瓜,种豆得豆。”而这就是每个', '0.9294075581335253'], [[[84.0, 105.0], [555.0, 104.0], [555.0, 125.0], [85.0, 127.0]], "every man's life: good begets good, and evil leads to evil.", '0.8932319914301237'], [[[28.0, 147.0], [556.0, 146.0], [556.0, 168.0], [28.0, 169.0]], 'melons; if he sows beans, he will reap beans." And this is true of', '0.900923888185131'], [[[0.0, 185.0], [524.0, 188.0], [524.0, 212.0], [0.0, 209.0]], 'We Chinese have a saying:"If a man plants melons, he will reap', '0.9216671202863965'], [[[295.0, 248.0], [553.0, 248.0], [553.0, 264.0], [295.0, 264.0]], '它不仅适用于今生,也适用于来世。', '0.927988795673146'], [[[14.0, 289.0], [554.0, 290.0], [554.0, 307.0], [14.0, 306.0]], '一每一个行为都有一种结果。在我看来,这种想法是全宇宙的道德基础;', '0.88565122719967'], [[[9.0, 330.0], [521.0, 330.0], [521.0, 349.0], [9.0, 349.0]], '假如说过去的日子曾经教给我们一些什么的话,那就是有因必有果一', '0.9162070232052957'], [[[343.0, 388.0], [555.0, 388.0], [555.0, 405.0], [343.0, 405.0]], 'in this world and the next.', '0.8764956444501877'], [[[15.0, 426.0], [554.0, 426.0], [554.0, 448.0], [15.0, 448.0]], 'opinion, is the moral foundation of the universe; it applies equally', '0.9183026262815448'], [[[62.0, 466.0], [556.0, 468.0], [556.0, 492.0], [62.0, 490.0]], 'effect - every action has a consequence. This thought, in my', '0.9308378403304053']]
```
### C++版本
```
TextBox[0](+padding)[score(0.711119),[x: 293, y: 58], [x: 604, y: 58], [x: 604, y: 79], [x: 293, y: 79]]
......@@ -125,7 +134,7 @@ crnnTime[11](38.051758ms)
https://developer.hpccube.com/codes/modelzoo/paddleocr_ort
## 参考
## 参考资料
https://github.com/RapidAI/RapidOCR
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment