I have trained classifier model with AutoML. I have exported the TensorFlow model and build a docker image. When I run the image it accepts HTTP POST API calls on port 8501
However I'm having trouble to correctly call the predict or classify API.
I have tried POST calls using Postman on
1)
http://localhost:8501/v1/models/default:classify
{
"examples": [
{
"feature_A": "7",
"feature_B": "-0.019000",
"feature_C": "-0.008000"
}
]
}
This will produce a json output, but completely ignore the features. Changing features doesn't affect output values.
http://localhost:8501/v1/models/default:predict
{"instances":["1","-0.018000","-0.022000"]}
this will produce error: "error": "Could not parse example input, value: '1'
[[{{node ParseExample/ParseExampleV2}}]
Without quotes too, it gives error: "error": "Failed to process element: 0 of 'instances' list. Error: Invalid argument: JSON Value: 1 Type: Number is not of expected type: string"
I also tried:
{
"instances": [
{
"feature_A": "7",
"feature_B": "-0.019000",
"feature_C": "-0.008000"
}
]
}
but that also gives error: Failed to process element: 0 key: feature_A of 'instances' list. Error: Invalid argument: JSON object: does not have named input: feature_A
What is the correct json request for calling classify or predict?
P.S. Seems like the input signature of the exported model is string instead of array of floats:
"metadata": {"signature_def": {
"signature_def": {
"classification": {
"inputs": {
"inputs": {
"dtype": "DT_STRING",
"tensor_shape": {
"dim": [
{
"size": "-1",
"name": ""
}
],
"unknown_rank": false
},
"name": "input_example_tensor:0"
}
},
question from:
https://stackoverflow.com/questions/65878837/how-to-call-predict-api-with-deployed-google-automl-tensorflow-on-docker 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…