Google Cloud Vision API 文本检测 google.gax.errors.RetryError: G



我是Google API的新手。最近,我使用Google Vision API,但我遇到了以下问题:

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

我尝试了有关"创建服务帐户"的解决方案来生成服务 json 密钥并在 py.script 中调用它,它将首先在大约 3~4 个 URL 中工作,但在下一个 URL 中会出错。这是我的检测代码:

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

我在另一个 py.script 中调用了"detect.py":

detect.detect_text_uri('...')

调用:

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

gcloud auth application-default login

这会将环境配置为使用下载的服务帐户凭据。

最新更新