google-app-enginegoogle-cloud-platformgoogle-predictiongoogle-cloud-ml-engine

Error Uploading data to deployed model for prediction from appengine. works fine from local system


I am facing problem Uploading data from appengine to deployed model for prediction. The function works fine from my local system, But when I deploy the application I get some error saying that data is not Json Serializable.I don't understand this any help will be appreciated.

Sample Code:

#convert Image to bse64 encoding
img = base64.b64encode(open("Images-Predict/"+filename, "rb").read());
#convert to valid json data
json_data={"key":"0", "image_bytes": {"b64": img}}

#Calling model for prediction
response = service.projects().predict(
    name=name,
    body={'instances': [json_data]}
).execute()

Output Log from appenginelog file

<code>log file</code>


Solution

  • It looks like img is bytes, so try converting to string:

    img = img.decode('utf-8')