README.md 3.74 KB
Newer Older
dcuai's avatar
dcuai committed
1
# chineseocr_lite
chenxj's avatar
chenxj committed
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
## 论文
chineseocr_lite通过det、rec、cls三个模型分别实现字符检测、字符识别和字符方向分类的应用

det模型主要用DB算法,参考论文如下:

https://arxiv.org/pdf/1911.08947.pdf

rec模型主要用crnn算法,参考论文如下:

https://arxiv.org/pdf/1507.05717.pdf

cls模型用resnet实现通用分类,参考论文如下:

https://arxiv.org/pdf/1512.03385.pdf
## 模型结构
det:

chenzk's avatar
chenzk committed
19
![image](https://developer.sourcefind.cn/codes/modelzoo/chineseocr_lite_onnx/-/raw/main/configs/dbnet-arc.png)
chenxj's avatar
chenxj committed
20
21
22

rec:

chenzk's avatar
chenzk committed
23
![image](https://developer.sourcefind.cn/codes/modelzoo/chineseocr_lite_onnx/-/raw/main/configs/crnn-arc.png)
chenxj's avatar
chenxj committed
24
25
26

cls:

chenzk's avatar
chenzk committed
27
![image](https://developer.sourcefind.cn/codes/modelzoo/chineseocr_lite_onnx/-/raw/main/configs/resnet-arc.png)
chenxj's avatar
chenxj committed
28
## 算法原理
chenzk's avatar
chenzk committed
29
![image](https://developer.sourcefind.cn/codes/modelzoo/chineseocr_lite_onnx/-/raw/main/configs/ocr.png)
chenxj's avatar
chenxj committed
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
## 数据集
推荐使用icdar2015数据集[icdar2015](https://rrc.cvc.uab.es/?ch=4&com=downloads)

检测模型训练集文件结构
```
/PaddleOCR/train_data/icdar2015/text_localization/
  └─ icdar_c4_train_imgs/         Training data of icdar dataset
  └─ ch4_test_images/             Testing data of icdar dataset
  └─ train_icdar2015_label.txt    Training annotation of icdar dataset
  └─ test_icdar2015_label.txt     Test annotation of icdar dataset
```
识别模型训练集文件结构
```
|-train_data
  |-rec
    |- rec_gt_train.txt
    |- train
        |- word_001.png
        |- word_002.jpg
        |- word_003.jpg
        | ...
    |-ic15_data
        |- rec_gt_test.txt
        |- test
            |- word_001.jpg
            |- word_002.jpg
            |- word_003.jpg
            | ...
```
## 环境配置
[光源](https://www.sourcefind.cn/#/service-details)可拉取训练以及推理的docker镜像,在[光合开发者社区](https://cancon.hpccube.com:65024/4/main/)可下载paddle安装包用于模型测试。chineseocr_lite_onnx推荐的镜像如下:
```
dcuai's avatar
dcuai committed
62
63
docker pull image.sourcefind.cn:5000/dcu/admin/base/custom:ort1.15.0_migraphx4.2.2_dtk2404
docker run -d -t --privileged --shm-size=32g --device=/dev/kfd --device=/dev/dri/ --network=host --group-add video --name chineseocr-test -v /opt/hyhal:/opt/hyhal:ro image.sourcefind.cn:5000/dcu/admin/base/custom:ort1.15.0_migraphx4.2.2_dtk2404 bash
dcuai's avatar
dcuai committed
64
docker exec -it chineseocr-test bash
dcuai's avatar
dcuai committed
65
source /opt/dtk/env.sh
chenxj's avatar
chenxj committed
66
cd chineseocr_lite_onnx
dcuai's avatar
dcuai committed
67
pip install paddlepaddle-2.5.2_dtk2404_das1.0+gitbb99f03d-cp310-cp310-manylinux2014_x86_64.whl (光合开发者社区下载https://cancon.hpccube.com:65024/4/main/paddle/DAS1.0)
chenxj's avatar
chenxj committed
68
69
pip3 install -r requirements.txt
```
dcuai's avatar
dcuai committed
70
71
## 训练
### 测试
chenxj's avatar
chenxj committed
72
73
74
75
76
77
78
79
80
81
82
83
84
检测模型
```
python3 -m paddle.distributed.launch --gpus '0,1,2,3' tools/eval.py -c configs/det_mv3_db.yml -o Global.pretrained_model=./models/dbnet.onnx
```
识别模型
```
python3 -m paddle.distributed.launch --gpus '0,1,2,3' tools/eval.py -c configs/ch_PP-OCRv3_rec.yml -o Global.pretrained_model=./models/crnn_lite_lstm.onnx
```
## 推理
```
python3 main.py --img_dir="./images/" --det_model_dir="./models/dbnet.onnx" --rec_model_dir="./models/crnn_lite_lstm.onnx" --cls_model_dir="./models/angle_net.onnx" --use_angle_cls=1 --warmup=1
```
## result
chenzk's avatar
chenzk committed
85
![image](https://developer.sourcefind.cn/codes/modelzoo/chineseocr_lite_onnx/-/raw/main/dbnet/test.jpg)
dcuai's avatar
dcuai committed
86
### 精度
chenxj's avatar
chenxj committed
87
88
89
90
91
92
93
94
95
96
97
98
99
100

检测模型测试
| Model | Precision | Recall |
| :------: | :------: |:------: |
| det | 0.6969 | 0.2291  |

识别模型测试
| Model | Acc | 
| :------: | :------: |
| rec | 0.1160 | 
## 应用场景
### 算法类别
ocr
### 热点应用行业
dcuai's avatar
dcuai committed
101
制造,金融,交通,教育,医疗
chenxj's avatar
chenxj committed
102
## 源码仓库及问题反馈
chenzk's avatar
chenzk committed
103
https://developer.sourcefind.cn/codes/modelzoo/chineseocr_lite_onnx
dcuai's avatar
dcuai committed
104
## 参考资料
chenxj's avatar
chenxj committed
105
* [chineseocr_lite](https://github.com/DayBreak-u/chineseocr_lite)
sugon_cxj's avatar
sugon_cxj committed
106