LoginSignup
1
0

More than 3 years have passed since last update.

【GCP】Video IntelligenceのAutoML Video ClassificationをCurlで叩いたらエラーが出た話

Last updated at Posted at 2019-10-06

はじめに

GCPのAutoML Video Classification(ベータ版)をCurl経由で試した際に
延々と引っ掛かったエラーについての備忘用記事です。

エラー
"Invalid JSON payload received. Unknown name \"inputConfig\": Cannot find field.\nInvalid JSON payload received. Unknown name \"outputConfig\": Cannot find field."

使用したコマンドは、GCPのブラウザ画面から学習を進めた際に表示されていたコマンドを使用しました。

request.json
{
  "inputConfig": {
    "gcsSource": {
      "inputUris": ["gs://your-bucket-name/your-input-file.csv"]
    }
  },
  "outputConfig": {
    "gcsDestination": {
      "outputUriPrefix": "gs://your-storage-path"
    }
  }
}
使用コマンド
curl -X POST -H "Content-Type: application/json" \
  -H "Authorization: Bearer $(gcloud auth application-default print-access-token)" \
  https://automl.googleapis.com/v1beta1/projects/{your_project_id}/locations/us-central1/models/{your_model_id}:predict \
  -d @request.json

結論

URIもしくはJSON bodyが間違っていました。
URIのコマンド部分が「predict」ではなく、「batchPredict」にすると動きます。

つまり最後の画面に表示されているコマンドとJSONの組み合わせが嘘です。

公式ドキュメントには正しいコマンドが書かれています。

curl -X POST -H "Content-Type: application/json" \
  -H "Authorization: Bearer $(gcloud auth application-default print-access-token)" \
  https://automl.googleapis.com/v1beta1/projects/{your_project_id}/locations/us-central1/models/{your_model_id}:batchPredict \
  -d @request.json

おわりに

公式ドキュメントを読めば防げましたね。。。
ちょっと納得いかないけど

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0