0
votes

I trained a custom model using Google Cloud AutoML. Now i am trying to access it, using the script provided by Google.

I tried to vary "content" in any kind of ways. I also had a look at the information provided here. Surely i did provide the correct path to the key file. Also i checked on the project ID and model ID. I do have a service account. Billing is enabled too.

export GOOGLE_APPLICATION_CREDENTIALS={key-file-path}

curl -X POST \
  -H "Authorization: Bearer $(gcloud auth application-default print-access-token)" \
  -H "Content-Type: application/json" \
  https://automl.googleapis.com/v1beta1/projects/{my-project-ID}/locations/us-central1/models/{my-model-id}:predict \
  -d '{
    "payload" : {
      "textSnippet": {
           "content": "happy",
            "mime_type": "text/plain"
       },
    }
  }'

I expect the result to be the prediction.

My result looks like this:

  "error": {
"code": 400,
"message": "Invalid JSON payload received. Expected a value.\n“happy”,\n       \n^",
"status": "INVALID_ARGUMENT"}
1
Try using a sentance instead of a word.John Hanley
Or maybe try to delete the last comma within your payload after the "textSnippet" object. Everything else seems ok, I think @JohnHanley s hint will make it.Philipp Möhler
Thanks guys, using a sentence worked. Surprisingly I was also able to use single words afterwards! Deleting the comma seems to have no effect at all.Moritz

1 Answers

0
votes

Thanks for your comments, John Hanley and Phillipp Möhler!

Actually I can't really tell what happened here. I followed Johns advice to use a whole sentence. Doing that enabled me to successfully predict something! Afterwards I was able to use both, single words and sentences.

Deleting the commas seems to have no effect at all.