1.官方文档
https://github.com/PaddlePaddle/PaddleOCR/blob/release/2.7/deploy/pdserving/README_CN.md
安装最新版:https://github.com/PaddlePaddle/Serving/blob/v0.8.3/doc/Latest_Packages_CN.md
2.pip3安装whl时要换源,换成百度的:-i https://mirror.baidu.com/pypi/simple
https://www.w3xue.com/exp/article/20236/84224.html
0.准备
只能使用python3.9,否则3.2步过不了。
1.安装paddlepaddle
不用sudo,pip3 install paddlepaddle==2.6.1 -i https://pypi.tuna.tsinghua.edu.cn/simple
2.安装OCR
cd /opt
sudo git clone https://gitee.com/paddlepaddle/PaddleOCR.git
进入PaddleOCR,即cd PaddleOCR
不用sudo,pip3 install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple
这其中若某个库找不到,可以单独pip3安装,如提示其中shapely找不到,重新换源,即, pip3 install shapely -i 其他源
3.准备PaddleServing运行环境
3.1#安装serving,用于启动服务,要安装最新版,所有版本在:https://pypi.tuna.tsinghua.edu.cn/simple/paddle-serving-server/
sudo wget https://paddle-serving.bj.bcebos.com/test-dev/whl/paddle_serving_server-0.9.0-py3-none-any.whl
pip3 install paddle_serving_server-0.9.0-py3-none-any.whl -i https://pypi.tuna.tsinghua.edu.cn/simple
安装失败:grpcio,grpcio-tools。通过单独安装并换源-i https://pypi.mirrors.ustc.edu.cn/simple/
3.2#安装client,用于向服务发送请求, 所有版本:https://pypi.tuna.tsinghua.edu.cn/simple/paddle-serving-client/
#cp39 => python 3.9版本要对应,否则报 ERROR: paddle_serving_client-0.9.0-cp39-none-any.whl is not a supported wheel on this platform.
sudo wget https://paddle-serving.bj.bcebos.com/test-dev/whl/paddle_serving_client-0.9.0-cp39-none-any.whl
pip3 install paddle_serving_client-0.9.0-cp39-none-any.whl -i https://pypi.tuna.tsinghua.edu.cn/simple
3.3#安装serving-app https://pypi.tuna.tsinghua.edu.cn/simple/paddle-serving-app/
sudo wget https://paddle-serving.bj.bcebos.com/test-dev/whl/paddle_serving_app-0.9.0-py3-none-any.whl
安装
pip3 install paddle_serving_app-0.9.0-py3-none-any.whl -i https://pypi.tuna.tsinghua.edu.cn/simple
模型转换
使用PaddleServing做服务化部署时,需要将保存的inference模型转换为serving易于部署的模型。
首先,下载PP-OCR的inference模型
/opt/PaddleOCR/deploy/pdserving
#下载并解压 OCR 文本检测模型
sudo wget https://paddleocr.bj.bcebos.com/PP-OCRv3/chinese/ch_PP-OCRv3_det_infer.tar -O ch_PP-OCRv3_det_infer.tar && tar -xf ch_PP-OCRv3_det_infer.tar
#下载并解压 OCR 文本识别模型
sudo wget https://paddleocr.bj.bcebos.com/PP-OCRv3/chinese/ch_PP-OCRv3_rec_infer.tar -O ch_PP-OCRv3_rec_infer.tar && tar -xf ch_PP-OCRv3_rec_infer.tar
python3 -m paddle_serving_client.convert --dirname ./ch_PP-OCRv3_det_infer/ --model_filename inference.pdmodel --params_filename inference.pdiparams --serving_server ./ppocr_det_v3_serving/ --serving_client ./ppocr_det_v3_client/