【问题标题】:"Prediction failed: Error during model execution: Unable to decode bytes as JPEG, PNG, GIF, or BMP"“预测失败:模型执行期间出错:无法将字节解码为 JPEG、PNG、GIF 或 BMP”
【发布时间】:2018-09-01 13:23:39
【问题描述】:

我在 gcloud ml-engine 上部署了一个 keras 模型,但在尝试在线预测时收到上述错误。

我按照@Chase Midler 的示例代码from here 进行保存和部署(这是对Hayato Yoshikawa 的示例代码from here 的改编。但是,它抱怨不存在preprocess_image 函数。我认为这是一个自定义函数有人想在将图像传递给模型之前对其进行处理;对吗?因此,我只是将那行注释掉了。

我继续将保存的模型部署到 gcloud ml 引擎并尝试在线预测。不幸的是,我收到以下“无法将字节解码为 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)]]\")"
}

可能是什么问题?

【问题讨论】:

  • 你检查过这个帖子吗? stackoverflow.com/questions/46687348/… 你可以编辑你的帖子并包含更多关于你为预测发送的信息吗?
  • 谢谢,问题已解决。我的 json 请求是问题所在。我将它发送给 Chase Midler,他检测到他在我的 json 请求中遇到了类似的问题。我后来改正了。谢谢 OK 关闭。

标签: python tensorflow keras tensorflow-serving google-cloud-ml


【解决方案1】:

问题已解决。我用于测试的 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`

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-12-12
    • 2018-08-20
    • 2016-07-06
    相关资源
    最近更新 更多