ARM端部署PP-OCR_V3(系统环境)
一、预准备
-
下载对应的whl:下载安装Linux预测库 根据系统(win和linux),语言(C++,C,Python),语言版本,CUDA版本,Jetson版本,硬件系统(nano,NX,TX,AGX)等等,一定要选对了
-
升级 pip
如果您到 pip 默认源的网络连接较差,临时使用本镜像站来升级 pip:python3.7 -m pip install -i https://pypi.tuna.tsinghua.edu.cn/simple --upgrade pip
python3.7 -m pip install --upgrade pip
-
换源
python3.7 -m pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
二、安装PaddlePaddle
python3.7 -m pip install -U paddlepaddle_gpu-2.3.2-cp37-cp37m-linux_aarch64.whl
>解决警告:
>```
>WARNING: The scripts pip, pip3 and pip3.6 are installed in '/home/agx2/.local/bin' which is not on PATH.
>Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
> ```
>解决方法:
>```
>sudo gedit ~/.bashrc
>export PATH=/home/agx2/.local/bin:$PATH #最后一行添加
>source ~/.bashrc
>```
---
三、下载PaddleOCR代码并安装依赖
首先 clone PaddleOCR 代码:
git clone https://github.com/PaddlePaddle/PaddleOCR
然后,安装依赖:
cd PaddleOCR
python3.7 -m pip install -r requirements.txt
python -m pip install paddleocr
报错 :
note: This error originates from a subprocess, and is likely not a problem with pip. error: subprocess-exited-with-error × pip subprocess to install build dependencies did not run successfully. │ exit code: 1 ╰─> See above for output. note: This error originates from a subprocess, and is likely not a problem with pip.
解决:
sudo python3.7 -m pip install opencv-contrib-python
- 注释掉requirements.txt中的:
#opencv-contrib-python==4.4.0.46
- 继续执行
python3.7 -m pip install -r requirements.txt
四、执行预测
从文档模型库中获取PPOCR模型,下面以PP-OCRv3模型为例,介绍在PPOCR模型在jetson上的使用方式:
下载并解压PP-OCRv3模型:
wget https://paddleocr.bj.bcebos.com/PP-OCRv3/chinese/ch_PP-OCRv3_det_infer.tar
wget https://paddleocr.bj.bcebos.com/PP-OCRv3/chinese/ch_PP-OCRv3_rec_infer.tar
tar xf ch_PP-OCRv3_det_infer.tar
tar xf ch_PP-OCRv3_rec_infer.tar
执行文本检测预测:
cd PaddleOCR
python3.7 tools/infer/predict_det.py --det_model_dir=./ch_PP-OCRv3_det_infer --image_dir=./doc/imgs/french_0.jpg --use_gpu=True
报错:
OSError: Could not find lib geos_c or load any of its variants ['libgeos_c.so.1', 'libgeos_c.so'].
解决:
-
sudo apt-get install libgeos-dev
-
再次执行
python3.7 tools/infer/predict_det.py --det_model_dir=./ch_PP-OCRv3_det_infer --image_dir=./doc/imgs/french_0.jpg --use_gpu=True
-
结果在
./inference_results
中
conda 环境的使用
conda环境的设置没有太大的变化,
- 需要在arm端安装miniconda
- 创建conda中的python环境,按照paddlepaddle的情况去配置
- conda环境中的python要安装这几个包:
pip install rospkg catkin_tools
- 执行的节点代码开头的
#! /usr/bin/env python3.7
改为#! /home/gsh/anaconda3/envs/pplabel/bin/python
- 按照系统环境以上过程进行即可
- 报错,缺少libgeos_c.os
- 解决:
conda install geopandas