Get predictions from Tensorflow Serve SavedModel

Viewed 87

I have a SavedModel that I've managed to load. With the command saved_model_cli show --dir <model_dir> --all I get the following output:

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

signature_def['serving_default']:
  The given SavedModel SignatureDef contains the following input(s):
    inputs['inputs'] tensor_info:
        dtype: DT_STRING
        shape: (-1)
        name: Placeholder:0
  The given SavedModel SignatureDef contains the following output(s):
    outputs['classes'] tensor_info:
        dtype: DT_STRING
        shape: (-1, -1)
        name: Reshape:0
    outputs['scores'] tensor_info:
        dtype: DT_FLOAT
        shape: (-1, 2)
        name: truediv:0
  Method name is: tensorflow/serving/classify

I'm trying to run the model to get a prediction, but for some reason I keep getting an error:

DataLossError:  Failed skipping unrequested field
     [[{{node PartitionedCall/DecodeProtoSparseV2}}]] [Op:__inference_pruned_389668]

Function call stack:
pruned

I have discovered that this error is defined in the struct2tensor package but unfortunately I don't see how I can fix it.

The way in which I am preparing my input and calling the model is the following:

df = pd.read_csv('mydata.csv', converters={i: str for i in range(0, 500)})
df = df.fillna('')
input = tf.convert_to_tensor([df.iloc[1]])
model.signatures['serving_default'](input)

I'm not sure if this is the right way. I've tried many approaches (like loading the whole row, aoncerting it to a string, and then making it into a tf.Tensor) but I still get the same error.

0 Answers
Related