繁体   English   中英

Google ML Engine 上的批量预测

[英]Batch prediction on the Google ML Engine

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"}

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

('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)

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

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM