一、安裝paddle
- 安裝python3.6
yum install python3
- 升級pip
python -m pip install -U pip
- 安裝paddle
python3 -m pip install paddlepaddle -i https://mirror.baidu.com/pypi/simple
- 驗證安裝是否成功
python3
import paddle
paddle.utils.run_check()
//出現PaddlePaddle is installed successfully!則安裝成功
二、安裝paddleOCR
- 安裝git
yum install git
- 使用git下載paddleOCR
git clone https://gitee.com/PaddlePaddle/PaddleOCR.git
- 切換路徑並安裝依賴
cd PaddleOCR
pip install -r requirements.txt
- 錯誤處理(無則跳過)
python-Levenshtein安裝錯誤
error: command 'gcc' failed with exit status 1錯誤
統一解決方法:
sudo yum install python3-devel
- 安裝inference model(參考官網)
!mkdir inference && cd inference
# 下載中英文檢測模型並解壓
wget https://paddleocr.bj.bcebos.com/dygraph_v2.0/ch/ch_ppocr_mobile_v2.0_det_infer.tar && tar xf ch_ppocr_mobile_v2.0_det_infer.tar
# 下載中英文方向分類器模型並解壓
wget https://paddleocr.bj.bcebos.com/dygraph_v2.0/ch/ch_ppocr_mobile_v2.0_cls_infer.tar && tar xf ch_ppocr_mobile_v2.0_cls_infer.tar
# 下載中英文識別模型並解壓
wget https://paddleocr.bj.bcebos.com/dygraph_v2.0/ch/ch_ppocr_mobile_v2.0_rec_infer.tar && tar xf ch_ppocr_mobile_v2.0_rec_infer.tar
- 快速運行
python3 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/"