【发布时间】:2020-03-11 13:02:27
【问题描述】:
问题
我一直无法找到描述通过 POST 请求发送 (base64) 图像的方法的来源。我尝试编辑签名,使其接受 base64 图像作为输入,但没有成功。是否可以更改模型以使其接受(base64)图像作为输入?如果不是,我可以在我的客户端上将我创建的图像转换为正确的格式吗? 源代码/日志
我目前正在使用标准签名保存我的 keras 模型:
tf.saved_model.save(model, "path")
get requests 结果表明模型已部署:
{ "version": "4", "state": "AVAILABLE", "status": { "error_code": "OK", "error_message": "" } }
我正在使用“react-native-image-base64”库将我的图像转换为 base64,并使用格式正确的发布请求发送它。 但是,正如错误代码所说,它需要一个浮点数
"error": "Failed to process element: 0 of \'instances\' list. Error: Invalid argument: JSON Value: {"Base64 image string here"} Type: Object is not of expected type: float"
提出以下要求:
curl --request POST \
--url http://192.168.1.75:8501/v1/models/saved_model:predict \
--header 'content-type: application/json' \
--data '
{
"instances":
[
{
"b64": "HBwcIiIiIiIiHh4eGhoaGBgYExMTEBAQERERERERDw8PCQkJBQ.."
}
]
}'
当前签名定义
signature_def['serving_default']:
The given SavedModel SignatureDef contains the following input(s):
inputs['conv2d_input'] tensor_info:
dtype: DT_FLOAT
shape: (-1, 102, 136, 3)
name: serving_default_conv2d_input:0
The given SavedModel SignatureDef contains the following output(s):
outputs['dense'] tensor_info:
dtype: DT_FLOAT
shape: (-1, 2)
name: StatefulPartitionedCall:0
Method name is: tensorflow/serving/predict
【问题讨论】:
-
能否请您分享您的 SignatureDef,以便我们尽力帮助您。谢谢!
-
@TensorflowSupport 我使用的是默认的 signaturedef(也就是没有自定义的)。你知道 TF2 中使用 base64 图像作为输入的 signaturedef 吗?
-
可以通过执行命令
!saved_model_cli show --dir {export_path} --all获取SignatureDef -
@TensorflowSupport 抱歉回复晚了,我将 signaturedef 添加到我原来的问题中
标签: tensorflow tensorflow2.0 tensorflow-serving