Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
384 views
in Technique[技术] by (71.8m points)

How to call Predict API with Deployed Google AutoML Tensorflow on Docker?

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.

  1. 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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...