Google Vision API - tatusCode.RESOURCE_EXHAUSTED
I am new to Google Vision API and I would like to conduct shortcut detection app. 10 images and I would like to run the quickstart.py file for the vision. However, when I do this with only 3 images, it succeeds. With more than 3 images, I am getting the error below. I know that I need to change something in my setup, but I don't 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 anyone know what I need to do?
Any help would be much appreciated
Cheers, Andi
source to share
I faced the same problem and fixed it with the following steps:
- Make sure you have the Google Cloud SDK installed: https://cloud.google.com/vision/docs/reference/libraries
- Setting up a service account in the Google Cloud backend: https://developers.google.com/identity/protocols/OAuth2ServiceAccount#creatinganaccount
- Create a service account key and upload it as a JSON file to a local folder. You need to leave the key private.
- Export the path to the key file as an environment variable:
gcloud auth activate-service-account --key-file path/to/your/keyfile/here
- Exit the console.
- Make sure your environment variable is set correctly with
printenv
- Try py-script again ...
Good luck ...
Edit: in addition to the above steps 1.-3. you can just do vision_client = vision.Client.from_service_account_json('/path/to/your/keyfile.json')
in script. Then there is no need for an env variable.
source to share