Home > Software engineering >  How to call google vision legacy models?
How to call google vision legacy models?

Time:05-06

I want to use the legacy text_detection and document_text_detection model. (refer: https://cloud.google.com/vision/docs/service-announcements) Im trying it this way using 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

I'm getting the following error:

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

What am I doing wrong?

CodePudding user response:

Try this:

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"}]})
  • Related