Skip to content
This repository has been archived by the owner on Nov 16, 2023. It is now read-only.

Error while inferencing from the tensorflow_serving #4

Open
Delvify opened this issue Oct 15, 2019 · 0 comments
Open

Error while inferencing from the tensorflow_serving #4

Delvify opened this issue Oct 15, 2019 · 0 comments

Comments

@Delvify
Copy link

Delvify commented Oct 15, 2019

The saved_model_cli of the saved model is

MetaGraphDef with tag-set: 'serve' contains the following SignatureDefs:

signature_def['serving_default']:
  The given SavedModel SignatureDef contains the following input(s):
    inputs['input_image'] tensor_info:
        dtype: DT_FLOAT
        shape: (-1, 299, 299, 3)
        name: input_1_1:0
  The given SavedModel SignatureDef contains the following output(s):
    outputs['predictions_1/Softmax:0'] tensor_info:
        dtype: DT_FLOAT
        shape: (-1, 1000)
        name: predictions_1/Softmax:0
  Method name is: tensorflow/serving/predict

The feature of image is generated as

img = image.load_img(img_path, target_size=(299, 299))
img = image.img_to_array(img)
# img = np.expand_dims(img, axis=0)
img = preprocess_input(img)
img.shape()
 Ret: (299, 299, 3)
data = json.dumps({"signature_name": "serving_default", "instances": [img.tolist()]})
print('Data: {} ... {}'.format(data[:50], data[len(data)-52:]))
 Ret: Data: {"signature_name": "serving_default", "instances": ... 805, -0.08235293626785278, -0.18431371450424194]]]]}

And while doing the prediction from the served model,

headers = {"content-type": "application/json"}
response = requests.post('http://localhost:8501/v1/model/inception:predict', data=data, headers=headers)
predictions = json.loads(response.text)['predictions']

Ret : KeyError                                  Traceback (most recent call last)
<ipython-input-148-5835e27c0dc9> in <module>
      1 headers = {"content-type": "application/json"}
      2 response = requests.post('http://localhost:8501/v1/model/inception:predict', data=data, headers=headers)
----> 3 predictions = json.loads(response.text)['predictions']

KeyError: 'predictions'

Or

response.text
 Ret: '{ "error": "Malformed request: POST /v1/model/inception:predict" }' 
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant