【问题标题】:gcloud local predictiongcloud 本地预测
【发布时间】:2018-04-07 17:51:54
【问题描述】:

我在 Google 云上训练了一个 Pet 数据集,然后使用 gcloud 将训练后的模型下载到本地 PC。 任务:使用训练好的模型在本地对测试集进行分类

A) 如果我像使用 gcloud 一样

    $ gcloud ml-engine local predict --model-dir=saved_model/ --json-instances=inputs.json

错误:prediction_lib.PredictionError:(4,“运行图表时出现异常:long() 以 10 为底的无效文字:'\xff\xd8\xff\xe0'”)

【问题讨论】:

  • 你能提供inputs.json的内容吗(随意“编辑”二进制blob)。
  • 看起来您的模型接受了一个 numpy 图形数组,但输入包含一些字符串(jpeg 字符串?)。您可以运行: $ saved_model_cli show --dir ${YOUR_LOCAL_MODEL_DIR --all 并在此处粘贴结果以及 rhaertel80 所说的 input.json 的 sn-p 吗?
  • JSON:{ “B64”:“/ 9J / 4AAQSkZJRgABAQAAAQABAAD / 2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAxNDQ0Hyc5PTgyPC4zNDL / 2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjL / wAARCAMABAADASIAAhEBAxEB / 8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL / 8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4 + T .................. .......
  • signature_def['serving_default']: The given SavedModel SignatureDef contains the following input(s): inputs['inputs'] tensor_info: dtype: DT_UINT8 shape: (-1, -1, -1, 3) name: image_tensor:0 The given SavedModel SignatureDef contains the following output(s): outputs['detection_boxes'] tensor_info: dtype: DT_FLOAT shape: (-1, 300, 4) name: detection_boxes:0 outputs['detection_classes'] tensor_info: dtype: DT_FLOAT shape: (-1, 300) name: detection_classes:0

标签: python tensorflow google-cloud-platform tensorboard google-cloud-ml-engine


【解决方案1】:

您的模型确实接受图像的数组,而不是 JPG 字符串。请看答案 tensorflow serving prediction not working with object detection pets example

如果您想使用当前输入,可以使用 --input_type encoded_image_string_tensor 重新导出模型。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-07-25
    • 1970-01-01
    • 2019-02-16
    • 2020-12-31
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多