将数据上传到已部署模型以从 AppEngine 进行预测时出错。在本地系统上工作正常
Error Uploading data to deployed model for prediction from appengine. works fine from local system
我在将数据从 appengine 上传到部署的模型进行预测时遇到问题。该功能在我的本地系统上运行良好,但是当我部署应用程序时,我收到一些错误消息,提示数据不是 Json Serializable.I 不明白这一点,我们将不胜感激。
示例代码:
#convert Image to bse64 encoding
img = base64.b64encode(open("Images-Predict/"+filename, "rb").read());
#convert to valid json data
json_data={"key":"0", "image_bytes": {"b64": img}}
#Calling model for prediction
response = service.projects().predict(
name=name,
body={'instances': [json_data]}
).execute()
从 appengine 输出日志log file
看起来 img
是字节,所以尝试转换为字符串:
img = img.decode('utf-8')
我在将数据从 appengine 上传到部署的模型进行预测时遇到问题。该功能在我的本地系统上运行良好,但是当我部署应用程序时,我收到一些错误消息,提示数据不是 Json Serializable.I 不明白这一点,我们将不胜感激。
示例代码:
#convert Image to bse64 encoding
img = base64.b64encode(open("Images-Predict/"+filename, "rb").read());
#convert to valid json data
json_data={"key":"0", "image_bytes": {"b64": img}}
#Calling model for prediction
response = service.projects().predict(
name=name,
body={'instances': [json_data]}
).execute()
从 appengine 输出日志log file
看起来 img
是字节,所以尝试转换为字符串:
img = img.decode('utf-8')