Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

modify customize.md for ch #5002

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 20 additions & 12 deletions doc/doc_ch/customize.md
Original file line number Diff line number Diff line change
@@ -1,30 +1,38 @@
# 如何生产自定义超轻量模型
# 如何训练自定义超轻量模型

生产自定义的超轻量模型可分为三步:训练文本检测模型、训练文本识别模型、模型串联预测
可分为通过下面三步训练自定义超轻量模型:文本检测模型训练、文本识别模型训练、模型预测

## step1:训练文本检测模型
## step1:文本检测模型训练

PaddleOCR提供了EAST、DB两种文本检测算法,均支持MobileNetV3、ResNet50_vd两种骨干网络,根据需要选择相应的配置文件,启动训练。例如,训练使用MobileNetV3作为骨干网络的DB检测模型(即超轻量模型使用的配置):
PaddleOCR提供了EAST、DB两种文本检测算法,均支持MobileNetV3、ResNet50_vd两种骨干网络,选择相应的配置文件开始训练。例如,使用MobileNetV3作为骨干网络DB检测模型来训练(即超轻量模型使用的配置):
```
python3 tools/train.py -c configs/det/det_mv3_db.yml 2>&1 | tee det_db.log
```
更详细的数据准备和训练教程参考文档教程中[文本检测模型训练/评估/预测](./detection.md)。
详细教程见[文本检测模型训练/评估/预测](./detection.md)。

## step2:训练文本识别模型
## step2:文本识别模型训练

PaddleOCR提供了CRNN、Rosetta、STAR-Net、RARE四种文本识别算法,均支持MobileNetV3、ResNet34_vd两种骨干网络,根据需要选择相应的配置文件,启动训练。例如,训练使用MobileNetV3作为骨干网络的CRNN识别模型(即超轻量模型使用的配置):
PaddleOCR提供了CRNN、Rosetta、STAR-Net、RARE四种文本识别算法,均支持MobileNetV3、ResNet34_vd两种骨干网络,选择相应的配置文件开始训练。例如,使用MobileNetV3作为骨干网络CRNN识别模型来训练(即超轻量模型使用的配置):
```
python3 tools/train.py -c configs/rec/rec_chinese_lite_train.yml 2>&1 | tee rec_ch_lite.log
```
更详细的数据准备和训练教程参考文档教程中[文本识别模型训练/评估/预测](./recognition.md)。
详细教程见[文本识别模型训练/评估/预测](./recognition.md)。

## step3:模型串联预测
## step3:模型预测

PaddleOCR提供了检测和识别模型的串联工具,可以将训练好的任一检测模型和任一识别模型串联成两阶段的文本识别系统。输入图像经过文本检测、检测框矫正、文本识别、得分过滤四个主要阶段输出文本位置和识别结果,同时可选择对结果进行可视化
PaddleOCR提供了一个使用文本检测模型和文本识别模型进行预测文本识别系统。输入图像经过文本检测、检测框矫正、文本识别、置信度过滤处理,输出文本位置和文本内容,同时提供识别结果可视化

在执行预测时,需要通过参数image_dir指定单张图像或者图像集合的路径、参数det_model_dir指定检测inference模型的路径和参数rec_model_dir指定识别inference模型的路径。可视化识别结果默认保存到 ./inference_results 文件夹里面。
参数:

参数image_dir为单张图像或者图像集合的路径;
参数det_model_dir为检测inference模型的路径;
参数rec_model_dir为识别inference模型的路径。

结果:

可视化识别结果默认保存到 ./inference_results 文件夹里面。

```
python3 tools/infer/predict_system.py --image_dir="./doc/imgs/11.jpg" --det_model_dir="./inference/det/" --rec_model_dir="./inference/rec/"
```
更多的文本检测、识别串联推理使用方式请参考文档教程中的[基于预测引擎推理](./inference.md)。
详细教程见[基于预测引擎推理](./inference.md)。