title: "Prediction failed: Error during model execution: Unable to decode bytes as JPEG, PNG, GIF, or BMP"
body: <p>I deployed a keras model onto gcloud ml-engine, but received above error upon attempted online prediction.</p>
  
  <p>I saved and deployed by following @Chase Midler's sample code <a href="https://stackoverflow.com/questions/48216067/tensorflow-serving-prediction-as-b64-output-top-result/48245749#48245749">from here</a> (which is an adaptation of Hayato Yoshikawa's sample code <a href="https://medium.com/google-cloud/serverless-transfer-learning-with-cloud-ml-engine-and-keras-335435f31e15" rel="nofollow noreferrer">from here</a>. 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.</p>
  
  <p>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:</p>
  
  <pre><code>{
    "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)]]\")"
  }
  </code></pre>
  
  <p>What could the problem be?</p>