在执行过程中,此行出现错误:
image = Image.open(io.BytesIO(decoded))
我已经检查了js脚本,数据已成功编码为base64 我认为js和flask数据交互之间存在一些问题,但我无法解决。
def predict_img():
message = request.get_json(force=True)
encoded = message['image']
decoded = base64.b64decode(encoded)
image = Image.open(io.BytesIO(decoded))
pro_img = preprocess_img(image, target_size=(32,32))
pred = model.predict(processed_img)
def pre_val(res):
x = np.where(res == np.amax(res))
x=x[0]
return x[0]
idx = pre_val(pred[0])
response = {'predictionImg' : str(classes[idx])}
return jsonify(response)
OSError:无法识别图像文件<_io.BytesIO对象位于0x00000225634CB5C8>