Andi Maier
Andi Maier

Reputation: 1034

Google Vision API - tatusCode.RESOURCE_EXHAUSTED

I am new to the Google Vision API and I would like to conduct a label detection of approx. 10 images and I would like to run the vision quickstart.py file. However when I do this with only 3 images then it is successful. With more than 3 images I am getting the error message below. I know that I would need to change something at my setup, but I do not know what I should change.

Here is my error message:

google.gax.errors.RetryError: GaxError(Exception occurred in retry method 
that was not classified as transient, caused by <_Rendezvous of RPC that 
terminated with (StatusCode.RESOURCE_EXHAUSTED, Insufficient tokens for 
quota 'DefaultGroup' and limit 'USER-100s' of service 
'vision.googleapis.com' for consumer 'project_number: XXX'.)>)

Does anybody know what I need to do?

Any help would be much appreciated

Cheers, Andi

Upvotes: 3

Views: 672

Answers (1)

petezurich
petezurich

Reputation: 10204

I ran into the same problem and fixed it with these steps:

  1. Make sure you have the Google Cloud SDK properly installed: https://cloud.google.com/vision/docs/reference/libraries
  2. Setup a Service Account in the Google Cloud backend: https://developers.google.com/identity/protocols/OAuth2ServiceAccount#creatinganaccount
  3. Create a Service Account Key and download it as a JSON file to a local folder. You need to keep the key private.
  4. Export the filepath to the key-file as an environment variable: gcloud auth activate-service-account --key-file path/to/your/keyfile/here
  5. Log out/in of the console.
  6. Make sure, the environment variable is properly set with printenv
  7. Try your py-script again...

Good luck...

Edit: In addition to the mentioned steps 1.-3. you can just do vision_client = vision.Client.from_service_account_json('/path/to/your/keyfile.json') in your script. No need for the env variable then.

Upvotes: 3

Related Questions