- pip install paddlepaddle -i https://mirror.baidu.com/pypi/simple
- pip install paddlehub --upgrade -i https://pypi.tuna.tsinghua.edu.cn/simple
- 服务端
hub serving start -m chinese_ocr_db_crnn_mobile -p 5555
- 客户端
pip install shapely、pyclipper
import requests
import json
import cv2
import base64
def cv2_to_base64(image):
data = cv2.imencode('.jpg', image)[1]
return base64.b64encode(data.tostring()).decode('utf8')
# 发送HTTP请求
data = {'images':[cv2_to_base64(cv2.imread("2.jpg"))]}
headers = {"Content-type": "application/json"}
url = "http://gt.g.cn:5555/predict/chinese_ocr_db_crnn_mobile"
print(url)
r = requests.post(url=url, headers=headers, data=json.dumps(data))
print(r)
# 打印预测结果
print(r.json()["results"])