我使用builder
api将虹膜模型保存为SavedModel,并通过docker进行部署:
docker run -p 8503:8501 -v $PWD/my_model3:/models/my_model3 -e MODEL_NAME=my_model3 -t tensorflow/serving
非常好,我可以使用tf的行格式(instances
的{{3}},如下所示:
URL :Predict API
请求:
{
"signature_name": "predict",
"instances": [
{
"size": [5.1, 3.3, 1.7, 0.5]
}
]
}
响应:
{
"predictions": [
{
"probabilities": [
0.998033,
0.00196652,
1.84558e-18
],
"predicted_classes": 0,
"logits": [
19.9882,
13.7587,
-20.8436
]
}
]
}
根据Predict API,inputs
还支持列格式,例如:
{
"inputs": {
"tag": ["foo", "bar"],
"signal": [[1, 2, 3, 4, 5], [3, 4, 1, 2, 5]],
"sensor": [[[1, 2], [3, 4]], [[4, 5], [6, 8]]]
}
}
但是对我来说似乎不起作用,请求正文如下:
请求:
{
"signature_name": "predict",
"inputs":
{
"size": [[5.1, 3.3, 1.7, 0.5]]
}
}
并返回错误:
{ "error": "JSON Value: {\n \"signature_name\": \"predict\",\n \"inputs\": {\n \"size\": [\n [\n 5.1,\n 3.3,\n 1.7,\n 0.5\n ]\n ]\n }\n} not formatted correctly. Expecting object with \'instances\' key and a list/array as the value." }
有人使用列格式可以帮助我吗?感谢您的提示!
============
我的环境: