1.下载paddlepaddle安装包
https://paddleinference.paddlepaddle.org.cn/master/user_guides/download_lib.html#python
选择:Jetpack4.4(4.5): nv_jetson-cuda10.2-trt7-all
2.安装
apt-get install libgeos-dev # shapely 包
git clone https://github.com/PaddlePaddle/PaddleOCR.git
pip3 install -r requirements.txt
注意,删除opencv-contrib-python==4.4.0.46,编译时间长,而且编译报错
pip3 install shapely==1.5.9
3.测试
# -*- coding: UTF-8 -*-
from paddleocr import PaddleOCR,draw_ocr
# Paddleocr supports Chinese, English, French, German, Korean and Japanese.
# You can set the parameter `lang` as `ch`, `en`, `fr`, `german`, `korean`, `japan`
# to switch the language model in order.
ocr = PaddleOCR(use_angle_cls=True, lang='ch') # need to run only once to download and load model into memory
img_path = './doc/imgs/1.jpg'
result = ocr.ocr(img_path, cls=True)
print("-"*10)
for line in result:
print(line)
tools/infer/utility.py # 配置gpu开关
4.PPOCRLabel文本标注
python -m pip install paddlepaddle -i https://mirror.baidu.com/pypi/simple
pip install PPOCRLabel # 安装 cpu版本
# PPOCRLabel文字识别标注工具
PPOCRLabel --lang ch # 启动【普通模式】,用于打【检测+识别】场景的标签
PPOCRLabel --lang ch --kie True # 启动 【KIE 模式】,用于打【检测+识别+关键字提取】场景的标签
>>> import paddle
>>> paddle.utils.run_check()
...
PaddlePaddle is installed successfully! Let's start deep learning with PaddlePaddle now.
5.训练
1.切分数据
python gen_ocr_train_val_test.py --trainValTestRatio 6:2:2 --datasetRootPath <数据地址>
2.1 训练分割网络
python tools/train.py -c configs/rec/ch_ppocr_v2.0/rec_chinese_common_train_v2.0.yml
2.2 训练分类网络
5.参考
https://blog.csdn.net/weixin_44065323/article/details/118862091