orc学习

参考地址:https://github.com/PaddlePaddle/PaddleOCR/tree/develop/thirdparty/paddleOcrSpringBoot

 ctpn算法:水平文字检测

hub serving部署方案

 

 

 

 

 

 docker部署paddlepaddle和paddlehub和模型服务

#需要将PaddleHub和PaddlePaddle统一升级到2.0版本
!pip install paddlehub==2.0.0 -i https://pypi.tuna.tsinghua.edu.cn/simple 
!pip install paddlepaddle==2.0.0 -i https://pypi.tuna.tsinghua.edu.cn/simple 
#该Module依赖于第三方库shapely、pyclipper,使用该Module之前,请先安装shapely、pyclipper
!pip install shapely -i https://pypi.tuna.tsinghua.edu.cn/simple 
!pip install pyclipper -i https://pypi.tuna.tsinghua.edu.cn/simple
# coding: utf8
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("/PATH/TO/IMAGE"))]}
headers = {"Content-type": "application/json"}
url = "http://127.0.0.1:8866/predict/chinese_ocr_db_crnn_mobile"
r = requests.post(url=url, headers=headers, data=json.dumps(data))

# 打印预测结果
print(r.json()["results"])
docker pull paddlepaddle/paddle:2.0.2
docker pull hub.baidubce.com/paddlepaddle/paddle:2.0.2

docker run --name paddle_test -it -d -v paddle:/paddle -p 8868:8866  9cf11d607020  /bin/bash

curl -H "Content-Type:application/json" -X POST --data "{"images": ["填入图片Base64编码(需要删除'data:image/jpg;base64,')"]}" http://localhost:8866/predict/ocr_system

hub serving start -m chinese_ocr_db_crnn_mobile -p 8866
hub serving start -m chinese_ocr_db_crnn_server -p 8866


paddlehub地址
https://github.com/PaddlePaddle/PaddleHub/blob/release/v2.1/README_ch.md
PaddleHub一键OCR中文识别:https://aistudio.baidu.com/aistudio/projectdetail/507159
原文地址:https://www.cnblogs.com/liubaihui/p/14624506.html