0
votes

I'm new in Google API. Recently, I use the Google Vision API but I met the following problem:

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'.)>)

And I tried the solution about "Create the service accout" to generate the service json key and invoke it in py.script, it will work first in almost 3~4 url, but it will error in next url. This is my detect code:

import argparse
import io
from google.cloud import vision
vision_client = vision.Client.from_service_account_json('/Users/bruce0621/Downloads/esun-bank-adc1897dba67.json')
...
def detect_text_uri(uri):
    """Detects text in the file located in Google Cloud Storage or on the Web.
    """
    vision_client = vision.Client()
    image = vision_client.image(source_uri=uri)

    texts = image.detect_text()
    print('Texts:')

    for text in texts:
        print('\n"{}"'.format(text.description))

        vertices = (['({},{})'.format(bound.x_coordinate, bound.y_coordinate)
                    for bound in text.bounds.vertices])

        print('bounds: {}'.format(','.join(vertices)))

And I invoke the "detect.py" in another py.script:

detect.detect_text_uri('...')
1

1 Answers

0
votes

Call:

export GOOGLE_APPLICATION_CREDENTIALS=/path/to/your/credentials.json

or

gcloud auth application-default login

This will configure your environment to use the service account credential you downloaded.