【发布时间】: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