README.md 2.71 KB
Newer Older
sugon_cxj's avatar
sugon_cxj committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# PaddleOCR
## 模型介绍
基于百度PaddleOCR的字符识别模型。
## 模型结构
整体包含检测和识别两个模型。
## 数据集
推荐使用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安装包。PaddleOCR推荐的镜像如下:
chenxj's avatar
chenxj committed
38
39
40
```
docker pull image.sourcefind.cn:5000/dcu/admin/base/paddlepaddle:2.3.2-centos7.6-dtk-22.10.1-py37-latest
```
sugon_cxj's avatar
sugon_cxj committed
41
42
43
44

### 训练

检测模型
chenxj's avatar
chenxj committed
45
```
sugon_cxj's avatar
sugon_cxj committed
46
python3 -m paddle.distributed.launch --gpus '0,1,2,3'  tools/train.py -c configs/det/det_mv3_db.yml -o Global.pretrained_model=./pretrain_models/MobileNetV3_large_x0_5_pretrained
chenxj's avatar
chenxj committed
47
```
sugon_cxj's avatar
sugon_cxj committed
48
识别模型
chenxj's avatar
chenxj committed
49
```
sugon_cxj's avatar
sugon_cxj committed
50
python3 -m paddle.distributed.launch --gpus '0,1,2,3'  tools/train.py -c configs/rec/PP-OCRv3/en_PP-OCRv3_rec.yml -o Global.pretrained_model=./pretrain_models/en_PP-OCRv3_rec_train/best_accuracy
chenxj's avatar
chenxj committed
51
```
sugon_cxj's avatar
sugon_cxj committed
52
53
### 测试
检测模型
chenxj's avatar
chenxj committed
54
```
sugon_cxj's avatar
sugon_cxj committed
55
python3 -m paddle.distributed.launch --gpus '0,1,2,3'  tools/eval.py -c configs/det/det_mv3_db.yml -o Global.pretrained_model=./output/db_mv3/best_accuracy.pdparams
chenxj's avatar
chenxj committed
56
```
sugon_cxj's avatar
sugon_cxj committed
57
识别模型
chenxj's avatar
chenxj committed
58
```
sugon_cxj's avatar
sugon_cxj committed
59
python3 -m paddle.distributed.launch --gpus '0,1,2,3'  tools/eval.py -c configs/rec/PP-OCRv3/en_PP-OCRv3_rec.yml -o Global.pretrained_model=./output/v3_en_mobile/best_accuracy.pdparams
chenxj's avatar
chenxj committed
60
```
sugon_cxj's avatar
sugon_cxj committed
61
### 推理
chenxj's avatar
chenxj committed
62
```
sugon_cxj's avatar
sugon_cxj committed
63
python3 tools/infer/predict_system.py --image_dir="./doc/imgs/" --det_model_dir="./ch_PP-OCRv3_det_infer/" --rec_model_dir="./ch_PP-OCRv3_rec_infer/" --use_angle_cls=false --rec_image_shape=3,48,320 --warmup=1
chenxj's avatar
chenxj committed
64
```
sugon_cxj's avatar
sugon_cxj committed
65
66
67
68
69
70
71
72
73
74
75
## 性能和准确率数据

检测模型测试
| Model | Precision | Recall |
| :------: | :------: |:------: |
| det | 0.7054 | 0.7193  |

识别模型测试
| Model | Acc | 
| :------: | :------: |
| rec | 0.6490 | 
chenxj's avatar
chenxj committed
76
## 源码仓库及问题反馈
chenxj's avatar
chenxj committed
77
https://developer.hpccube.com/codes/modelzoo/paddleocr
sugon_cxj's avatar
sugon_cxj committed
78
79
80
## 参考
* [PaddleOCR](https://github.com/PaddlePaddle/PaddleOCR)