TF Serving Request Error

Hi, I’m trying to test my model on the new image but I’m getting errors on json.

Error message:

Source Code

TF Serving Model
Screenshot from 2021-09-24 15-33-44


The error is “KeyError: predictions”. On this line:

predictions = json_responce.json()["predictions"][0]

To see what keys that response actually has, try:

print( json_responce.json().keys())

I don’t know why the “prediction” works on this first picture but on 2nd picture I getting an error about the “predictions”?

The error message clearly says that the response doesn’t have a “predictions” key. So check what keys there are, that may give you a clue. I’m not sure how tf-serving reports errors, but if you’re lucky there’s may be something in the response that could give more information. Or can you see if the tf-serving process is logging the error?

The response has a “predictions” key. I fixed the problem by removing all the codes in the get_rest_request function. I’m still confused why it doesn’t work if I write it in function