PaddleOCR Training Model Reference

PaddleOCR Training Model Reference

This article introduces NV graphics card training. CPU training is for reference only. Please go to the official website for information on some different places.

最后更新 3/30/2022 11:00 AM
Dream.Machine
预计阅读 4 分钟
分类
.NET
标签
.NET C# mode training

This article introduces NV graphics card training. CPU training is for reference only. Please go to the official website for information on some different places.

Official address:

must-install environment

  • Python 3.9(3.10):初期测试一直有问题后作者改为3.9,如果有需要自行验证3.10https://www.python.org/

  • Python:是执行脚本的关键词,需要配置环境变量,下面的很多组件都需要配置环境变量,具体的请参考互联网信息。

  • pip: 作者本身不会 Python,这个理解应该是一个安装的插件。可以安装第三方库,如果 pip3 无法执行 可以切换成 pip,具体原因不明。

  • pip 网络问题: 可以在使用 pip 的时候加参数-i https://pypi.tuna.tsinghua.edu.cn/simple

例如:pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pyspider,这样就会从清华这边的镜像去安装 pyspider 库。

  • CUDA

https://developer.nvidia.com/cuda-downloads

The author installed version 10.2

  • CUDNN

https://developer.nvidia.com/cudnn

Overwrite and save to CUDA directory after download

  • PaddleOCR

https://github.com/PaddlePaddle/PaddleOCR

Clone the project locally

  • cd PaddleOCR

pip3 install -r requirements.txt

Third-party python libraries required to install OCR

  • PPOCRLabel

This is a annotation tool for creating learning data. It is not necessary but very convenient.

cd ./PPOCRLabel # 将目录切换到PPOCRLabel文件夹下
pip install pyqt5 # 安装QT5 运行环境
pip3 install -r requirements.txt
python PPOCRLabel.py --lang ch # 启动工具,如果启动没反应那么就是缺少环境
  • ch_ppocr_mobile_v2.0_rec

预训练模型(其他模型可以参考地址:models_list.md

ch_ppocr_mobile_v2.0_rec_pre.tar

  • Training parameter document

config.md

本地配置文件路径: PaddleOCR-release-2.4\configs\rec\ch_ppocr_v2.0\rec_chinese_lite_train_v2.0.yml

  • Modified value:
epoch_num: 1000 #循环次数
data_dir: ./train_data/ #训练数据目录
label_file_list: ["./train_data/train_list.txt"] #训练数据的比对文本
batch_size_per_card: 128 #使用的数量(太大启动不起来,可以自行修改)

  • Training catalog explanation
PaddleOCR-release-2.4\train_data
PaddleOCR-release-2.4\train_data\crop_img #用工具做好的图片放到这里
PaddleOCR-release-2.4\train_data\train_list.txt #训练的文本信息
PaddleOCR-release-2.4\train_data\val_list.txt   #验证文本信息 (目前作者使用的和训练文本一样的内容)内容如下

PaddleOCR-release-2.4\pretrain_models  #从官网下载的预训练模型放到这里
PaddleOCR-release-2.4\output #训练输出目录
PaddleOCR-release-2.4\output\inference #最终导出模型
  • training script
//训练模型
python tools/train.py -c configs/rec/ch_ppocr_v2.0/rec_chinese_lite_train_v2.0.yml -o Global.pretrained_model=./pretrain_models/best_accuracy
//导出模型
python tools/export_model.py -c configs/rec/ch_ppocr_v2.0/rec_chinese_lite_train_v2.0.yml -o Global.checkpoints=output/rec_chinese_lite_v2.0/latest Global.save_inference_dir=output/inference
//使用训练预测(预测文件夹)
python tools/infer_rec.py -c configs/rec/ch_ppocr_v2.0/rec_chinese_lite_train_v2.0.yml -o Global.checkpoints=output/rec_chinese_lite_v2.0/latest Global.load_static_weights=false Global.infer_img=trainTest/
//使用训练预测(预测单个文件)
python tools/infer_rec.py -c configs/rec/ch_ppocr_v2.0/rec_chinese_lite_train_v2.0.yml -o Global.checkpoints=output/rec_chinese_lite_v2.0/latest Global.load_static_weights=false Global.infer_img=trainTest/1000.jpg
//使用导出模型预测
python tools/infer/predict_rec.py --image_dir="./trainTest/" --det_model_dir="./ch_PP-OCRv2_det_infer/"  --rec_model_dir="./output/inference/" --cls_model_dir="./ch_ppocr_mobile_v2.0_cls_infer/"

Author: Dream Machine

Website: www.dmskin.com

Keep Exploring

延伸阅读

更多文章
同分类 / 同标签 4/22/2026

Support for. NET by operating system versions (250707 update)

Use virtual machines and test machines to test the support of each version of the operating system for. NET. After installing the operating system, it is passed by measuring the corresponding running time of the installation and being able to run the Stardust Agent.

继续阅读
同分类 / 同标签 2/7/2026

Summary of experience in using AOT

From the very beginning of project creation, you should develop a good habit of conducting AOT release testing in a timely manner whenever new features are added or newer syntax is used.

继续阅读