【发布时间】:2020-03-06 09:06:03
【问题描述】:
我想为 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 cmets 之后添加:
当我尝试使用如下代码调用未定义签名 (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": "Failed to get input map for signature: info" }'
【问题讨论】:
标签: tensorflow tensorflow-serving tfx