0
votes

I am Using Colab for text Classification, it is Multilabel text classification model

 import json

# inputFeature1 
inputFeature1="¿Tiene el arte que gustar a todos? Pues no"  

#inputFeature2
inputFeature2="Una imagen del último día de la exposición ded"


#inputFeature3  
inputFeature3="marabilias"



instances=[{"inputFeature1":[inputFeature1],"inputFeature2=":[inputFeature2],"inputFeature3":[inputFeature3]}]

data = json.dumps({"signature_name": "serving_default", "instances": instances})
print('Data: {} ... {}'.format(data[:50], data[len(data)-52:]))
print(data)
print(requests.post('http://localhost:8501/v1/models/text_model', data=data).content.decode())

Error is

{ "error": "Malformed request: POST /v1/models/text_model" } Tensorflow Serving 
1

1 Answers

0
votes

Without knowing the model signature, I believe the issue is with your instances= statement. Change it to: instances=[{"inputFeature1":inputFeature1,"inputFeature2=":inputFeature2,"inputFeature3":inputFeature3}]

You were passing the feature value as a list [] rather than just the values. When we pass the values for json.dumps, we need to send a list of dicts.

The value of dicts need not be a list.

Also, make sure you are checking your model signature for the data type for input features. You can use saved_model_cli show --dir /path/to/your/model --all rfom command line.