@app.route('/', methods = ['POST'])
def predict():
if request.method == 'POST':
base64img = request.get_json()['img'].encode('utf-8')
img = base64.b64decode(base64img)
with open('imgtemp.png', 'wb') as f:
f.write(img)
img = cv2.imread('imgtemp.png', 1)
img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
payload = {
'instances': [{'input_image': img.tolist()}]
}
r = requests.post(url, json = payload)
pred = json.loads(r.content.decode('utf-8'))
return pred