简体   繁体   English

“预测失败:模型执行期间出错:无法将字节解码为JPEG,PNG,GIF或BMP”

[英]“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.

相关问题 InvalidArgumentError:断言失败:[无法将字节解码为 JPEG、PNG、GIF 或 BMP] - InvalidArgumentError: assertion failed: [Unable to decode bytes as JPEG, PNG, GIF, or BMP] Tensorflow 预测错误,invalidArgumentError:断言失败:[无法将字节解码为 JPEG、PNG、GIF 或 BMP] - Tensorflow prediciton error, invalidArgumentError: assertion failed: [Unable to decode bytes as JPEG, PNG, GIF, or BMP] 使用 tf.image.decode_image 时出错“b'无法将字节解码为 JPEG、PNG、GIF 或 BMP'” - Error using tf.image.decode_image " b'Unable to decode bytes as JPEG, PNG, GIF, or BMP'" Tensorflow Keras 错误:未知的图像文件格式。 需要 JPEG、PNG、GIF、BMP 之一 - Tensorflow Keras error: Unknown image file format. One of JPEG, PNG, GIF, BMP required Tensorflow 无法解码 tfrecords 中的 jpeg 字节 - Tensorflow failed to decode jpeg bytes in tfrecords 未知的图像文件格式。 需要 JPEG、PNG、GIF、BMP 之一 - Unknown image file format. One of JPEG, PNG, GIF, BMP required 在使用Tensorflow 1.6和ml-engine的模型执行期间,预测失败。 它们应该兼容 - Prediction failed during model execution with tensorflow 1.6 and ml-engine. They should be compatible tensorflow.python.framework.errors_impl.InvalidArgumentError:未知的图像文件格式。 需要 JPEG、PNG、GIF、BMP 之一 - tensorflow.python.framework.errors_impl.InvalidArgumentError: Unknown image file format. One of JPEG, PNG, GIF, BMP required 如何在wxpython中获取png或jpeg或bmp图片 - How to get png or jpeg or bmp pictures in wxpython 正则表达式首先以 jpg|jpeg|gif|png 结尾 - Regex first ends with jpg|jpeg|gif|png
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM