chineseocr/darknet-ocr

利用docker镜像服务把识别结果保存到本地(不需要编译GPU)

yfq512 opened this issue · 1 comments

docker镜像服务 的方法怎么用代码的方式上传图像,并将识别结果保存到本地

由于一直无法编译GPU,但是可以用docker启动本地服务,因此可以用post请求的方式来获得识别结果,例子如下:(运行下面的代码之前要记得开启docker服务)
import requests
import json
import base64

imgpath = './timg.jpg'
imgbase64 = None
with open(imgpath,'rb') as f:
imgbase64 = base64.b64encode(f.read())
imgString2 = imgbase64.decode('utf-8')
imgString = 'base64,' + imgString2
data = {"imgString":imgString}
header = {'Content-Type':'application/x-www-form-urlencoded; charset=UTF-8'}
postUrl = 'http://127.0.0.1:8080/text'
data = json.dumps(data)
r = requests.post(postUrl, data=data, headers=header).text
print(r)