【问题标题】:Batch prediction on the Google ML EngineGoogle ML Engine 上的批量预测
【发布时间】:2019-08-24 23:21:53
【问题描述】:

Google ML Engine 上的批量预测引发异常。

我在 Google ML 引擎上有一个 tensorflow 模型。我的模型对图像进行推断。输入不是一个普通的数组。该模型只接受图片的 b64 编码字符串。

我的输入是托管在 Google Cloud Platform 上的存储桶中的文本文件。 该文件如下所示:

{"image": "b64 encoded image string", "key": "0"}
{"image": "b64 encoded image string", "key": "1"}
{"image": "b64 encoded image string", "key": "2"}

输出应该是所有图像的 infrence,但我得到以下异常:

('Exception during running the graph: Expected image (JPEG, PNG, or GIF), got unknown format starting with \'{\\"image\\": \\"/9j/4\'\n\t [[node encoder/map/while/DecodeJpeg (defined at /usr/local/lib/python2.7/dist-packages/google/cloud/ml/prediction/frameworks/tf_prediction_lib.py:210) ]]', 1)

【问题讨论】:

  • 您在提交工作时使用的数据格式是什么?是 JSON 吗?
  • 是的,我提交作业时数据格式是JSON。

标签: python tensorflow google-cloud-ml


【解决方案1】:

如果您的模型“仅接受图像的 b64 编码字符串”,即签名具有一个输入张量且其数据类型为字符串,则 ML Engine 将输入文件的每一行直接馈送到单个字符串输入张量中。在这种情况下,没有进行 JSON/b64 解码,因此您的模型将获取整行作为输入。

如果您的模型是这种情况,那么您可以通过向模型添加一个新的操作来处理输入中的“键”字段来解决异常。

【讨论】:

    猜你喜欢
    • 2017-12-29
    • 2018-01-12
    • 2019-02-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-10-03
    • 2018-12-09
    • 1970-01-01
    相关资源
    最近更新 更多