Python 在googleml上运行导出的Inception:Expected float32 get';str';

Python 在googleml上运行导出的Inception:Expected float32 get';str';,python,tensorflow,machine-learning,google-cloud-ml,Python,Tensorflow,Machine Learning,Google Cloud Ml,我使用这个示例重新训练了Inception模型,并使用--saved_model_dir标志导出模型,以便最终提供服务 我成功地将最终的模型上传到了Google ML引擎,现在我正试图从中进行预测 我的请求如下所示: {"image": {"b64": "/9j/4AAQxh6AP/2Q== ..."}} 但我得到了一个错误,说: {"error": "Prediction failed: Error processing input: Expected float32, got '\\xff

我使用这个示例重新训练了Inception模型,并使用--saved_model_dir标志导出模型,以便最终提供服务

我成功地将最终的模型上传到了Google ML引擎,现在我正试图从中进行预测

我的请求如下所示:

{"image": {"b64": "/9j/4AAQxh6AP/2Q== ..."}}
但我得到了一个错误,说:

{"error": "Prediction failed: Error processing input: Expected float32, got '\\xff\\xd8\\xff\\xe0 ...' of type 'str' instead."}

retain.py中的导出示例是否未导出用于Google ML引擎的模型?

错误消息表明导出的模型需要浮点数组而不是原始图像字节。我通过代码来确认这一点。具体来说,调用以获取在中创建的大小为输入张量的
调用,如下所示():

因此,预期数据如下所示:

{
  "image": [
    [
      [0.0, 0.0, 0.0],
        # ... (num entries = height)
    ],
    # (num entries = width)
  ]
}
当然,这是一种相当低效的图像编码方式(浮动为ASCII)。如果预期的图像大小很小(通常是200 x 200),这并不可怕。如果示例的作者允许导出模型,并调用
add_jpeg\u decoding
作为模型的入口点,这将允许您在当前尝试发送数据时发送数据,那会更好

{
  "image": [
    [
      [0.0, 0.0, 0.0],
        # ... (num entries = height)
    ],
    # (num entries = width)
  ]
}