2017-05-21 2 views
0

Ich bin neu in Google API. Vor kurzem verwende ich die Google Vision-API, aber ich traf folgendes Problem:Google Cloud Vision API-Texterkennung google.gax.errors.RetryError: GaxError

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

Und habe ich versucht, die Lösung über „den Dienst accout erstellen“, um den Dienst json Schlüssel zu erzeugen und es in py.script aufrufen, Es wird zuerst in fast 3 ~ 4 URL funktionieren, aber es wird Fehler in der nächsten URL. Das ist mein erkennen 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))) 

Und ich die "detect.py" in einem anderen py.script aufzurufen:

detect.detect_text_uri('...') 

Antwort

0

Call:

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

oder

gcloud auth application-default login 

Dies wird confi Stellen Sie sicher, dass Ihre Umgebung die von Ihnen heruntergeladenen Dienstkontobestimmungen verwendet.

Verwandte Themen