paddleocr 使用教程

打开从github上下载的最新PaddleOCR

先对整个项目有一个总体的认识吧:从上到下文件夹依次为:configs、deploy、doc、inference、inference_results、ppocr、PPOCRLabel、StyleText、Tools共9个文件夹。

1、configs文件夹

这个文件夹下是方向分类、文本检测、文字识别的配置文件。配置文件中描述的内容包括如何训练、模型结构、优化器、训练参数、训练数据来源等。

先看训练的脚本train.sh:

# recommended paddle.__version__ == 2.0.0
python3 -m paddle.distributed.launch --gpus '0,1,2,3,4,5,6,7'  tools/train.py -c configs/rec/rec_mv3_none_bilstm_ctc.yml

上面的脚本可以看出python环境使用的是python3。

paddle.distributed.launch:启动分布式运行。

--gpus:设置使用的GPU的序号(需要是多GPU卡的机器,通过命令watch nvidia-smi查看GPU的序号)。

tools/train.py:训练的启动脚本。

-c configs/rec/rec_mv3_none_bilstm_ctc.yml:配置文件,例子中的配置文件是启动识别训练的。(训练包括:文本检测训练、文本方向判断训练、文字识别训练)

配置文件目录分别对应下面的三个目录:

从上到下依次为:方向分类、文本检测、文字识别。

参考:2.6mnist手写数字识别之资源配置(含分布式)精讲(百度架构师手把手带你零基础实践深度学习原版笔记系列)

2、deploy文件夹

这个文件夹主要是部署相关内容,也是最后需要学习的地方,暂时可以略过。

3、doc文件夹

这个文件夹包括一些测试图片。还有一个很重要的PP-OCR论文。

4、inference文件夹

这个文件夹下放着3个模型,分别是方向分类模型、文本检测模型、文本识别模型。

5、inference_results文件夹

这个文件夹是运行脚本后生成的目录,里面存放的是结果标注显示图片。

inference.sh脚本如下:

# 预测image_dir指定的单张图像
# python tools/infer/predict_system.py --image_dir="./doc/imgs/11.jpg" --det_model_dir="./inference/ch_ppocr_mobile_v2.0_det_infer/"  --rec_model_dir="./inference/ch_ppocr_mobile_v2.0_rec_infer/" --cls_model_dir="./inference/ch_ppocr_mobile_v2.0_cls_infer/" --use_angle_cls=True --use_space_char=True
# 预测image_dir指定的图像集合
# python tools/infer/predict_system.py --image_dir="./doc/imgs/" --det_model_dir="./inference/ch_ppocr_mobile_v2.0_det_infer/"  --rec_model_dir="./inference/ch_ppocr_mobile_v2.0_rec_infer/" --cls_model_dir="./inference/ch_ppocr_mobile_v2.0_cls_infer/" --use_angle_cls=True --use_space_char=True
# 如果想使用CPU进行预测,需设置use_gpu参数为False
python tools/infer/predict_system.py --image_dir="./doc/imgs/" --det_model_dir="./inference/ch_ppocr_mobile_v2.0_det_infer/"  --rec_model_dir="./inference/ch_ppocr_mobile_v2.0_rec_infer/" --cls_model_dir="./inference/ch_ppocr_mobile_v2.0_cls_infer/" --use_angle_cls=True --use_space_char=True --use_gpu=False

6、ppocr文件夹

这个文件夹是ppocr的主干,具体内容如下:

data:数据加载、数据扩充。

losses:分类、检测、识别模型的损失函数。

metrics:

modeling:模型组建,包含:模型结构、backbone、heads、necks、transforms。

optimizer:学习率、学习策略、优化器、正则化。

postprocess:后处理。

utils:实用工具。

7、PPOCRLabel文件夹

标注工具文件夹,等用的时候再详细笔记。

8、StyleText文件夹

风格迁移文件夹用于生成样本数据,扩充训练样本。

9、Tools文件夹

包括训练、推理、评估的python脚本。可以通在根目录下写shell文件直接调用。

猜你喜欢

转载自blog.csdn.net/juluwangriyue/article/details/113574712
今日推荐