我正在学习使用 Tensorflow 服务,但我很难找到包括 Stackoverflow 在内的示例。
我在 TensorFlow 网站上使用花卉示例。训练部分很成功,但部署起来很困难。
我按如下方式运行服务器:
docker run -p 8501:8501 --mount type=bind,source=C:\tmp\saved_models,target=/models/flowers -e MODEL_NAME=flowers -t tensorflow/serving &
要查看所有 SignatureDef,我使用了以下内容
saved_model_cli show --dir c:\tmp\saved_models\1 --all
回应是
MetaGraphDef with tag-set: 'serve' contains the following SignatureDefs:
signature_def['serving_default']:
The given SavedModel SignatureDef contains the following input(s):
inputs['image'] tensor_info:
dtype: DT_STRING
shape: ()
name: DecodeJpeg/contents:0
The given SavedModel SignatureDef contains the following output(s):
outputs['classes'] tensor_info:
dtype: DT_STRING
shape: (5)
name: Const:0
outputs['prediction'] tensor_info:
dtype: DT_FLOAT
shape: (-1, 5)
name: final_result:0
Method name is: tensorflow/serving/predict
正如我在这里看到的那样,它假设有“方法名称是:tensorflow/serving/classify”
为什么我的示例中缺少它?
我的 RESTAPI 请求如下:
http://localhost:8501/v1/models/flowers/versions/1:classify
身体 :
{
"signature_name": "serving_default",
"flowers": [
{
"image": { "b64": "c:/Users/pubud/OneDrive/Pictures/bird.jpg=" },
"rose": "flower"
}
]
}
我得到的错误是:
{
"error": "Expected classification signature method_name to be tensorflow/serving/classify. Was: tensorflow/serving/predict"
}
非常感谢任何帮助。