我想为 SavadModel 添加额外的签名,它将返回业务描述并使用 TensorFlow Serving 提供服务。
@tf.function
def info():
return json.dumps({
'name': 'My model',
'description': 'This is model description.',
'project': 'Product ABCD',
'type': 'some_type',
...
})
正如 TensorFlow Core 手册https://www.tensorflow.org/guide/saved_model#identifying_a_signature_to_export中所写,我可以轻松导出接受提供 tf.TensorSpec 的参数的签名。
是否可以在没有参数的情况下导出签名并在服务器上调用它?
在@EricMcLachlan 评论后添加:
当我尝试使用如下代码调用没有定义签名(input_signature=[])的函数时:
data = json.dumps({"signature_name": "info", "inputs": None})
headers = {"content-type": "application/json"}
json_response = requests.post('http://localhost:8501/v1/models/my_model:predict', data=data, headers=headers)
我在响应中得到下一个错误:
'_content': b'{ "error": "未能获取签名的输入映射:信息" }'