I am using tensorflow_model_server to serve a SavedModel. I keep getting this response code 400 and following error:
{ "error": "The first dimension of paddings must be the rank of inputs[4,2] [1,1,1,208,770,3]\\n\\t [[{{node Generator/FlatConv/sequential/zero_padding2d/Pad}}]]" }
Output from saved-model-cli show ...
MetaGraphDef with tag-set: 'serve' contains the following SignatureDefs:
signature_def['__saved_model_init_op']:
The given SavedModel SignatureDef contains the following input(s):
The given SavedModel SignatureDef contains the following output(s):
outputs['__saved_model_init_op'] tensor_info:
dtype: DT_INVALID
shape: unknown_rank
name: NoOp
Method name is:
signature_def['serving_default']:
The given SavedModel SignatureDef contains the following input(s):
inputs['input_1'] tensor_info:
dtype: DT_FLOAT
shape: (-1, -1, -1, 3)
name: serving_default_input_1:0
The given SavedModel SignatureDef contains the following output(s):
outputs['output_1'] tensor_info:
dtype: DT_FLOAT
shape: (-1, -1, -1, 3)
name: StatefulPartitionedCall:0
Method name is: tensorflow/serving/predict
WARNING:tensorflow:From /tensorflow-1.15.0/python3.6/tensorflow_core/python/ops/resource_variable_ops.py:1781: calling BaseResourceVariable.__init__ (from tensorflow.python.ops.resource_variable_ops) with constraint is deprecated and will be removed in a future version.
Instructions for updating:
If using Keras pass *_constraint arguments to layers.
Defined Functions:
Function Name: '_default_save_signature'
Option #1
Callable with:
Argument #1
input_1: TensorSpec(shape=(?, ?, ?, 3), dtype=tf.float32, name='input_1')
Pre-processing
img_path = "/content/input_images/my_img.jpg"
img = np.array(Image.open(img_path).convert("RGB"))
img = np.expand_dims(img, 0).astype(np.float32) / 127.5 - 1
Request code:
payload = {
"instances": [{'input_1': [input_image.tolist()]}]
}
headers = {"content-type": "application/json"}
json_response = requests.post('http://localhost:8501/v1/models/my_model:predict', data=json.dumps(payload), headers=headers)
print("Request complete")
print (json_response)
response_text = json_response.text
response_text
Response / Output
Request complete
<Response [400]>
'{ "error": "The first dimension of paddings must be the rank of inputs[4,2] [1,1,1,449,674,3]\\n\\t [[{{node Generator/FlatConv/sequential/zero_padding2d/Pad}}]]" }'
Code is run on Colab
I do not understand what is wrong here.
TensorFlow Serving is a flexible, high-performance serving system for machine learning models, designed for production environments. TensorFlow Serving makes it easy to deploy new algorithms and experiments, while keeping the same server architecture and APIs. TensorFlow Serving provides out-of-the-box integration with TensorFlow models, but ...
The following NEW packages will be installed: tensorflow-model-server 0 upgraded, 1 newly installed, 0 to remove and 119 not upgraded. Need to get 335 MB of archives. After this operation, 0 B of additional disk space will be used.
Note: This example is running TensorFlow Serving natively, but you can also run it in a Docker container, which is one of the easiest ways to get started using TensorFlow Serving.
You can update with: [X ] If running on TensorFlow, check that you are up-to-date with the latest version. The installation instructions can be found here. [ X] Provide a link to a GitHub Gist of a Python script that can reproduce your issue (or just copy the script here if it is short).
It means that your input data shoud be four dimensions array, while you have 6d
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With