0

I deployed a keras model onto gcloud ml-engine, but received above error upon attempted online prediction.

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.

I proceeded to deploy the saved model to gcloud ml engine and attempt an online prediction. Unfortunately I received the following "unable to decode bytes as JPEG, PNG, GIF, or BMP" error:

{
  "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?

halfer
  • 19,824
  • 17
  • 99
  • 186
  • 1
    Have you checked this thread? https://stackoverflow.com/questions/46687348/decoding-tfrecord-with-tfslim And can you edit your post and include more info on what you sending for the prediction? – VictorGGl Apr 06 '18 at 09:42
  • Thank you, the problem is resolved. My json request was the problem. I sent it to Chase Midler who detected that he obtained a similar problem with my json request. I since corrected it. Thanks OK to close. – VeryVeryGoodNews Apr 07 '18 at 17:13

1 Answers1

0

The problem is resolved. The json request I was using for testing was the problem. 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. 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`
Matteo Italia
  • 123,740
  • 17
  • 206
  • 299