"Prediction failed: Error during model execution: Unable to decode bytes as JPEG, PNG, GIF, or BMP"
"Prediction failed: Error during model execution: Unable to decode bytes as JPEG, PNG, GIF, or BMP"
我在 gcloud ml-engine 上部署了一个 keras 模型,但在尝试在线预测时收到上述错误。
我按照@Chase Midler 的示例代码 (which is an adaptation of Hayato Yoshikawa's sample code from here 进行了保存和部署。但是,它抱怨不存在 preprocess_image 函数。我假设这是一个自定义函数,用于在将图像传递给模型之前对图像执行的任何操作;那是对的吗?因此,我只是简单地评论了这一行。
我继续将保存的模型部署到 gcloud ml 引擎并尝试进行在线预测。不幸的是,我收到以下 "unable to decode bytes as JPEG, PNG, GIF, or 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)]]\")"
}
可能是什么问题?
问题已解决。我用于测试的 json 请求是问题所在。我在 Python 中手动生成了它,然后将它发送给了 Chase Midler,后者检测到他在我的 json 请求中遇到了类似的问题。我后来用下面的代码更正了它。
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`
我在 gcloud ml-engine 上部署了一个 keras 模型,但在尝试在线预测时收到上述错误。
我按照@Chase Midler 的示例代码
我继续将保存的模型部署到 gcloud ml 引擎并尝试进行在线预测。不幸的是,我收到以下 "unable to decode bytes as JPEG, PNG, GIF, or 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)]]\")"
}
可能是什么问题?
问题已解决。我用于测试的 json 请求是问题所在。我在 Python 中手动生成了它,然后将它发送给了 Chase Midler,后者检测到他在我的 json 请求中遇到了类似的问题。我后来用下面的代码更正了它。
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`