Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
yfq512 opened this issue Jul 23, 2020 · 1 comment

Comments

@yfq512
Copy link

yfq512 commented Jul 23, 2020

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

@yfq512 yfq512 changed the title docker镜像服务 怎么把识别结果保存到本地? 利用docker镜像服务把识别结果保存到本地 Aug 10, 2020
@yfq512 yfq512 changed the title 利用docker镜像服务把识别结果保存到本地 利用docker镜像服务把识别结果保存到本地(不需要编译GPU) Aug 10, 2020
@yfq512
Copy link
Author

yfq512 commented Aug 10, 2020

由于一直无法编译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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant