def post(self):
''' curl --request POST -data-binary "@fname.jpg" --header "Content-Type: image/jpg" http://localhost:8899/pic
??????? ...
'''
global cf,lock
body = self.request.body
try:
img = Image.open(StringIO.StringIO(body))
img = cv.cvtColor(np.array(img), cv.COLOR_RGB2BGR)
lock.acquire()
pred = cf.predicate(img)
lock.release()
rx = { "result": [] }
for i in range(0, 3):
r = { 'title': pred[i][1], 'score': float(pred[i][2]) }
rx['result'].append(r)
self.finish(rx)
except Exception as e:
print e
self.finish(str(e))
# ?????????????? url?????????????? ..
评论列表
文章目录