0

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>

Krunal
  • 77,632
  • 48
  • 245
  • 261
Akhil_Singh_Rana
  • 355
  • 1
  • 2
  • 10

1 Answers1

0

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

img = img.decode('utf-8')
rhaertel80
  • 8,254
  • 1
  • 31
  • 47
  • Thanks for your response, I tried that but again It works from local system, I thought it should work this time from App-Engine as well, but again the same error data not serializable. It works when I call the model from Terminal using the same img encoding. – Akhil_Singh_Rana Jun 16 '17 at 17:51
  • It worked for me after saving the data into Json file using string encoding. Thanks for your help – Akhil_Singh_Rana Jun 18 '17 at 17:16