diff --git a/doc/doc_ch/algorithm_det_db.md b/doc/doc_ch/algorithm_det_db.md index 9b52dd74f..fc887743b 100644 --- a/doc/doc_ch/algorithm_det_db.md +++ b/doc/doc_ch/algorithm_det_db.md @@ -23,28 +23,22 @@ 在ICDAR2015文本检测公开数据集上,算法复现效果如下: -|模型|骨干网络|precision|recall|Hmean|下载链接| -| --- | --- | --- | --- | --- | --- | -|DB|ResNet50_vd|86.41%|78.72%|82.38%|[训练模型](https://paddleocr.bj.bcebos.com/dygraph_v2.0/en/det_r50_vd_db_v2.0_train.tar)| -|DB|MobileNetV3|77.29%|73.08%|75.12%|[训练模型](https://paddleocr.bj.bcebos.com/dygraph_v2.0/en/det_mv3_db_v2.0_train.tar)| +|模型|骨干网络|配置文件|precision|recall|Hmean|下载链接| +| --- | --- | --- | --- | --- | --- | --- | +|DB|ResNet50_vd|configs/det/det_r50_vd_db.yml|86.41%|78.72%|82.38%|[训练模型](https://paddleocr.bj.bcebos.com/dygraph_v2.0/en/det_r50_vd_db_v2.0_train.tar)| +|DB|MobileNetV3|configs/det/det_mv3_db.yml|77.29%|73.08%|75.12%|[训练模型](https://paddleocr.bj.bcebos.com/dygraph_v2.0/en/det_mv3_db_v2.0_train.tar)| <a name="2"></a> ## 2. 环境配置 -请先参考[《运行环境准备》](./environment.md)配置PaddleOCR运行环境,参考[《项目克隆》](./clone.md)克隆项目 +请先参考[《运行环境准备》](./environment.md)配置PaddleOCR运行环境,参考[《项目克隆》](./clone.md)克隆项目代码。 <a name="3"></a> ## 3. 模型训练、评估、预测 -<a name="3-1"></a> -### 3.1 训练 +请参考[文本检测训练教程](./detection.md)。PaddleOCR对代码进行了模块化,训练不同的检测模型只需要**更换配置文件**即可。 -<a name="3-2"></a> -### 3.2 评估 - -<a name="3-3"></a> -### 3.3 预测 <a name="4"></a> ## 4. 推理部署 diff --git a/doc/doc_ch/detection.md b/doc/doc_ch/detection.md index 9bf3bb85e..9dc910c5c 100644 --- a/doc/doc_ch/detection.md +++ b/doc/doc_ch/detection.md @@ -10,7 +10,10 @@ * [2.1 启动训练](#21-----) * [2.2 断点训练](#22-----) * [2.3 更换Backbone 训练](#23---backbone---) - * [2.4 知识蒸馏训练](#24---distill---) + * [2.4 混合精度训练](#24---amp---) + * [2.5 分布式训练](#25---fleet---) + * [2.6 知识蒸馏训练](#26---distill---) + * [2.7 其他训练环境(Windows/macOS/Linux DCU)](#27---other---) - [3. 模型评估与预测](#3--------) * [3.1 指标评估](#31-----) * [3.2 测试检测效果](#32-------) @@ -103,9 +106,6 @@ python3 tools/train.py -c configs/det/det_mv3_db.yml \ 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 -# 多机多卡训练,通过 --ips 参数设置使用的机器IP地址,通过 --gpus 参数设置使用的GPU ID -python3 -m paddle.distributed.launch --ips="xx.xx.xx.xx,xx.xx.xx.xx" --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 ``` 上述指令中,通过-c 选择训练使用configs/det/det_db_mv3.yml配置文件。 @@ -116,15 +116,6 @@ python3 -m paddle.distributed.launch --ips="xx.xx.xx.xx,xx.xx.xx.xx" --gpus '0,1 python3 tools/train.py -c configs/det/det_mv3_db.yml -o Optimizer.base_lr=0.0001 ``` -**注意:** 采用多机多卡训练时,需要替换上面命令中的ips值为您机器的地址,机器之间需要能够相互ping通。另外,训练时需要在多个机器上分别启动命令。查看机器ip地址的命令为`ifconfig`。 - -如果您想进一步加快训练速度,可以使用[自动混合精度训练](https://www.paddlepaddle.org.cn/documentation/docs/zh/guides/01_paddle2.0_introduction/basic_concept/amp_cn.html), 以单机单卡为例,命令如下: -```shell -python3 tools/train.py -c configs/det/det_mv3_db.yml \ - -o Global.pretrained_model=./pretrain_models/MobileNetV3_large_x0_5_pretrained \ - Global.use_amp=True Global.scale_loss=1024.0 Global.use_dynamic_loss_scaling=True - ``` - <a name="22-----"></a> ## 2.2 断点训练 @@ -183,15 +174,49 @@ args1: args1 **注意**:如果要更换网络的其他模块,可以参考[文档](./add_new_algorithm.md)。 +<a name="24---amp---"></a> +## 2.4 混合精度训练 -<a name="24---distill---"></a> +如果您想进一步加快训练速度,可以使用[自动混合精度训练](https://www.paddlepaddle.org.cn/documentation/docs/zh/guides/01_paddle2.0_introduction/basic_concept/amp_cn.html), 以单机单卡为例,命令如下: + +```shell +python3 tools/train.py -c configs/det/det_mv3_db.yml \ + -o Global.pretrained_model=./pretrain_models/MobileNetV3_large_x0_5_pretrained \ + Global.use_amp=True Global.scale_loss=1024.0 Global.use_dynamic_loss_scaling=True + ``` -## 2.4 知识蒸馏训练 +<a name="26---fleet---"></a> +## 2.5 分布式训练 + +多机多卡训练时,通过 `--ips` 参数设置使用的机器IP地址,通过 `--gpus` 参数设置使用的GPU ID: + +```bash +python3 -m paddle.distributed.launch --ips="xx.xx.xx.xx,xx.xx.xx.xx" --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 +``` + +**注意:** 采用多机多卡训练时,需要替换上面命令中的ips值为您机器的地址,机器之间需要能够相互ping通。另外,训练时需要在多个机器上分别启动命令。查看机器ip地址的命令为`ifconfig`。 + + +<a name="26---distill---"></a> + +## 2.6 知识蒸馏训练 PaddleOCR支持了基于知识蒸馏的检测模型训练过程,更多内容可以参考[知识蒸馏说明文档](./knowledge_distillation.md)。 +**注意:** 知识蒸馏训练目前只支持PP-OCR使用的`DB`和`CRNN`算法。 +<a name="27---other---"></a> +## 2.7 其他训练环境 + +- Windows GPU/CPU + +- macOS + +- Linux DCU + + <a name="3--------"></a> # 3. 模型评估与预测 @@ -206,22 +231,22 @@ PaddleOCR计算三个OCR检测相关的指标,分别是:Precision、Recall python3 tools/eval.py -c configs/det/det_mv3_db.yml -o Global.checkpoints="{path/to/weights}/best_accuracy" ``` -* 注:`box_thresh`、`unclip_ratio`是DB后处理所需要的参数,在评估EAST模型时不需要设置 <a name="32-------"></a> ## 3.2 测试检测效果 -测试单张图像的检测效果 +测试单张图像的检测效果: ```shell python3 tools/infer_det.py -c configs/det/det_mv3_db.yml -o Global.infer_img="./doc/imgs_en/img_10.jpg" Global.pretrained_model="./output/det_db/best_accuracy" ``` -测试DB模型时,调整后处理阈值 +测试DB模型时,调整后处理阈值: ```shell python3 tools/infer_det.py -c configs/det/det_mv3_db.yml -o Global.infer_img="./doc/imgs_en/img_10.jpg" Global.pretrained_model="./output/det_db/best_accuracy" PostProcess.box_thresh=0.6 PostProcess.unclip_ratio=2.0 ``` +* 注:`box_thresh`、`unclip_ratio`是DB后处理参数,其他检测模型不支持。 -测试文件夹下所有图像的检测效果 +测试文件夹下所有图像的检测效果: ```shell python3 tools/infer_det.py -c configs/det/det_mv3_db.yml -o Global.infer_img="./doc/imgs_en/" Global.pretrained_model="./output/det_db/best_accuracy" ``` diff --git a/doc/features.png b/doc/features.png index af55a82a1..56f937455 100644 Binary files a/doc/features.png and b/doc/features.png differ