[英]“Prediction failed: Error during model execution: Unable to decode bytes as JPEG, PNG, GIF, or BMP”
I deployed a keras model onto gcloud ml-engine, but received above error upon attempted online prediction. 我在gcloud ml-engine上部署了一个keras模型,但在尝试进行在线预测时收到上述错误。
I saved and deployed by following @Chase Midler's sample code from here (which is an adaptation of Hayato Yoshikawa's sample code from here . However, it complained that no preprocess_image function existed. I assume this is a custom function for whatever one wants to do to the image before passing it through the model; is that correct? Hence, I simply commented that line out. 我救,并按照@Chase米德勒的示例代码部署从这里 (这是隼人吉川的示例代码适应从这里 ,但抱怨没有preprocess_image功能的存在。我想这是任何一个想要做自定义函数图像通过模型之前;是正确的吗?因此,我只是将这一行注释掉了。
I proceeded to deploy the saved model to gcloud ml engine and attempt an online prediction. 我着手将保存的模型部署到gcloud ml引擎,并尝试进行在线预测。 Unfortunately I received the following "unable to decode bytes as JPEG, PNG, GIF, or BMP" error: 不幸的是,我收到以下“无法将字节解码为JPEG,PNG,GIF或BMP”错误:
{
"error": "Prediction failed: Error during model execution:
AbortionError(code=StatusCode.INVALID_ARGUMENT, details=
\"assertion failed: [Unable to decode bytes as JPEG, PNG, GIF, or BMP]\n\t
[[Node: import/decode_image/cond_jpeg/cond_png/cond_gif/Assert_1/
Assert = Assert[T=[DT_STRING], summarize=3, _device=
\"/job:localhost/replica:0/task:0/device:CPU:0\"](import/decode_image/cond_jpeg/
cond_png/cond_gif/is_bmp, import/decode_image/cond_jpeg/cond_png/
cond_gif/Assert_1/Assert/data_0)]]\")"
}
What could the problem be? 可能是什么问题?
The problem is resolved. 问题已解决。 The json request I was using for testing was the problem. 我用来测试的json请求就是问题所在。 I had generated it manually in Python and I sent it to Chase Midler who detected that he obtained a similar problem with my json request. 我是用Python手动生成的,然后将其发送给Chase Midler,后者发现他的json请求也遇到了类似的问题。 I since corrected it with the code below. 从那以后,我用下面的代码纠正了它。
python -c 'import base64, sys, json; img = base64.b64encode(open(sys.argv[1], "rb").read()); print json.dumps({"image_bytes": {"b64": img}}) ' dog.jpg &> shepherd_dog.json`
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.