如何调用google视觉遗留模型?



我想使用传统的text_detectiondocument_text_detection模型。(参见:https://cloud.google.com/vision/docs/service-announcements)我试着用features:

import io
from google.cloud import vision
vision_client = vision.ImageAnnotatorClient()

with io.open("/mnt/d/snap.png", 'rb') as image_file:
content = image_file.read()
image = vision.Image(content=content)

response = vision_client.document_text_detection(image=image)
# print(response) --> uses stable models, works fine

feature = vision.Feature(model="builtin/legacy")
response = vision_client.document_text_detection(image=image, features=feature)
# print(response) --> throws error show below

我得到以下错误:

TypeError: dict() got multiple values for keyword argument 'features'

我做错了什么?

试试这个:

import io from google.cloud import vision
vision_client = vision.ImageAnnotatorClient()
with io.open("/mnt/d/snap.png", 'rb') as image_file:
content = image_file.read()
#image = vision.Image(content=content)
response = vision_client.annotate_image({'image': {'content': content},'features': [{'type_': vision.Feature.Type.DOCUMENT_TEXT_DETECTION,'model': "builtin/legacy"}]})

相关内容

  • 没有找到相关文章

最新更新