簡體   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