【问题标题】:Google Cloud Vision API text detection google.gax.errors.RetryError: GaxErrorGoogle Cloud Vision API 文本检测 google.gax.errors.RetryError: GaxError
【发布时间】:2017-10-20 23:28:40
【问题描述】:

我是 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('...')

【问题讨论】:

    标签: python google-cloud-vision


    【解决方案1】:

    呼叫:

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

    gcloud auth application-default login
    

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

    【讨论】:

      猜你喜欢
      • 2017-09-27
      • 2019-04-24
      • 2019-02-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-11-28
      相关资源
      最近更新 更多