飞桨PaddlePaddle-源于产业实践的开源深度学习平台
飞桨PaddlePaddle-源于产业实践的开源深度学习平台
pip3 install numpy
sudo pip3 install matplotlib
sudo pip3 install opencv-python
wget https://mirrors.tuna.tsinghua.edu.cn/pypi/web/packages/9c/6f/220c45977e6f85cbe63cd978c5cb774aa7c71ef9fb52b45f69c2611af010/opencv_python-4.1.2.30-cp38-cp38-manylinux1_x86_64.whl#sha256=5fec35916a6b9ce935f2e2806084303fd4e3fbb0c973a8db8f54b5aca54613cb
pip install opencv_python-4.1.2.30-cp38-cp38-manylinux1_x86_64.whl
#查看cv版本
python3
import cv2
cv2.__version__
执行一遍,一条条试)
当遇到缺少依赖包的时候,就查找下依赖包名称,然后安装即可。
ImportError: libSM.so.6: cannot open shared object file: No such file or dir
yum whatprovides libSM.so.6
yum install libSM-1.2.2-2.el7.x86_64 --setopt=protected_multilib=false -y
yum whatprovides libXrender.so.1
yum install libXrender-0.9.10-1.el7.x86_64 --setopt=protected_multilib=false -y
yum whatprovides libXext.so.6
yum install libXext-1.3.3-3.el7.x86_64 --setopt=protected_multilib=false -y
yum whatprovides libXrender.so.1
yum install libXrender-0.9.10-1.el7.x86_64 --setopt=protected_multilib=false -y
yum whatprovides libXrender.so.1
yum install libXrender-0.9.10-1.el7.x86_64 --setopt=protected_multilib=false -y
# 在终端中输入以下命令:
cd ~
mkdir style_transfer
cd style_transfer
hub install chinese_ocr_db_crnn_server==1.2.0
pip install shapely pyclipper
测试代码:
hub run chinese_ocr_db_crnn_server --input_path "/root/image/1.png"
hub run chinese_ocr_db_crnn_server --input_path "/PATH/TO/IMAGE"
vim /root/.paddlehub/modules/chinese_ocr_db_crnn_mobile/module.py
conda activate paddle_env
import requests
import json
import cv2
import base64
def cv2_to_base64(image):
data = cv2.imencode('.png', image)[1]
return base64.b64encode(data.tostring()).decode('utf8')
# 发送HTTP请求
data = {'images':[cv2_to_base64(cv2.imread("/root/image/1.png"))]}
headers = {"Content-type": "application/json"}
url = "http://127.0.0.1:8866/predict/chinese_ocr_db_crnn_server"
r = requests.post(url=url, headers=headers, data=json.dumps(data))
# 打印预测结果
print(r.json()["results"])