Google Cloud AutoML Vision“ importData”服务产生错误400必填字段无效

时间:2019-11-18 18:36:51

标签: google-cloud-automl

我已经在Google Cloud AutoML Vision中创建了一个数据集,但是当我尝试将数据导入到该数据集时,我总是遇到错误。

这是我创建数据集的方式:

(automl-vision)  ?   >cat dataset-create.sh 
#!/bin/bash

source set-vars.sh

curl -X POST \
-H "Authorization: Bearer "$(gcloud auth application-default print-access-token) \
-H "Content-Type: application/json; charset=utf-8" \
-d @dataset-create.json \
https://automl.googleapis.com/v1beta1/projects/$PROJECT_ID/locations/$REGION_NAME/datasets

(automl-vision)  ?   >cat dataset-create.json 
{
  "displayName": "flowers2",
  "imageClassificationDatasetMetadata": {
    "classificationType": "MULTICLASS"
  }
}
(automl-vision)  ?   >./dataset-create.sh 
{
  "name": "projects/164318150633/locations/us-central1/datasets/ICN2946422881602502656",
  "displayName": "flowers2",
  "createTime": "2019-11-18T04:53:09.446058Z",
  "etag": "AB3BwFrKSmh8TBU-RcwcjMgyL6qRJUNNRBE1HQSXcoUQg4sUZdeE13sArn2phh5zdY_i",
  "imageClassificationDatasetMetadata": {
    "classificationType": "MULTICLASS"
  }
}

这是我尝试导入数据的方式:

(automl-vision)  ?   >cat dataset-import.sh
#!/bin/bash

if [ $# -ne 1 ]; then
  printf "Usage: dataset-import [DATASET_ID]\n"
  exit 1
fi

export DATASET_ID=$1
source set-vars.sh

curl -X POST \
-H "Authorization: Bearer "$(gcloud auth application-default print-access-token) \
-H "Content-Type: application/json; charset=utf-8" \
-d @dataset-import.json https://automl.googleapis.com/v1beta1/projects/$PROJECT_ID/locations/$REGION_NAME/datasets/$DATASET_ID:importData

(automl-vision)  ?   >cat dataset-import.json 
{ 
    "inputConfig": { 
        "gcsSource": { 
            "inputUris": [ 
                "gs://annotator-1286-vcm/csv/all_data.csv" 
            ] 
        } 
    } 
} 

这是我得到的错误:

(automl-vision)  ?   >time ./dataset-import.sh ICN2946422881602502656
{
  "name": "projects/164318150633/locations/us-central1/operations/ICN1487619441171628032",
  "metadata": {
    "@type": "type.googleapis.com/google.cloud.automl.v1beta1.OperationMetadata",
    "createTime": "2019-11-18T04:58:17.472864Z",
    "updateTime": "2019-11-18T04:58:17.472864Z",
    "importDataDetails": {}
  }
}

real    0m1.418s
user    0m0.348s
sys 0m0.193s

(automl-vision)  ?   >cat operation-get-status.sh 
#!/bin/bash

if [ $# -ne 1 ]; then
  printf "usage: get-training-status.sh [operation-id]\n"
  exit 1
fi

export OPERATION_ID="$1"
source set-vars.sh

curl -X GET \
-H "Authorization: Bearer "$(gcloud auth application-default print-access-token) \
https://automl.googleapis.com/v1beta1/projects/$PROJECT_ID/locations/$REGION_NAME/operations/operation-id

(automl-vision)  ?   >./operation-get-status.sh ICN1487619441171628032
{
  "error": {
    "code": 400,
    "message": "List of found errors:\t1.Field: name; Message: Required field is invalid\t",
    "status": "INVALID_ARGUMENT",
    "details": [
      {
        "@type": "type.googleapis.com/google.rpc.BadRequest",
        "fieldViolations": [
          {
            "field": "name",
            "description": "Required field is invalid"
          }
        ]
      }
    ]
  }
}

the documentation,据我所知,我所做的一切正确。

到目前为止,我已经尝试过:

我在SO上搜索了类似的问题,但没有找到可行的解决方案。

我尝试使用数据集NAME代替DATASET_ID。

(automl-vision)  ?   >time ./dataset-import.sh flowers2
{
  "error": {
    "code": 400,
    "message": "List of found errors:\t1.Field: name; Message: Required field is invalid\t",
    "status": "INVALID_ARGUMENT",
    "details": [
      {
        "@type": "type.googleapis.com/google.rpc.BadRequest",
        "fieldViolations": [
          {
            "field": "name",
            "description": "Required field is invalid"
          }
        ]
      }
    ]
  }
}

real    0m1.266s
user    0m0.350s
sys 0m0.174s

本教程中flowers数据集的默认csv似乎没有标题,但是the documentation表示需要标题。我找不到有关是否需要特定标头名称的信息,因此我选择了“图像”,“花”。

之前:

(automl-vision)  ?   >head -3 all_data.csv 
gs://annotator-1286-vcm/img/flower_photos/daisy/100080576_f52e8ee070_n.jpg,daisy
gs://annotator-1286-vcm/img/flower_photos/daisy/10140303196_b88d3d6cec.jpg,daisy
gs://annotator-1286-vcm/img/flower_photos/daisy/10172379554_b296050f82_n.jpg,daisy

之后:

(automl-vision)  ?   >head -3 all_data.csv 
image,flower
gs://annotator-1286-vcm/img/flower_photos/daisy/100080576_f52e8ee070_n.jpg,daisy
gs://annotator-1286-vcm/img/flower_photos/daisy/10140303196_b88d3d6cec.jpg,daisy

相同的结果。

我尝试将第一个标头字段更改为“名称”:

(automl-vision)  ?   >head -3 all_data.csv 
name,flower
gs://annotator-1286-vcm/img/flower_photos/daisy/100080576_f52e8ee070_n.jpg,daisy
gs://annotator-1286-vcm/img/flower_photos/daisy/10140303196_b88d3d6cec.jpg,daisy

相同的结果

0 个答案:

没有答案