python – AttributeError: Module ‘google.cloud.vision’ does not have attribute ‘Image’

[ad_1]

As I know, the Image class is no longer available in the google.cloud.vision modules, so you can use the types module to create an image object that can be used with the web_detection function.

Perhaps it is better to import the vision_v1p3beta1 module instead of the vision module, because the web_detection function is only available in the beta version of the Cloud Vision API.

let me give you an example via web_detection function with an image url, i will use the types module to create an Image object from an image url, then pass this object to the web_detection function to perform web detection on the image.

from google.cloud import vision_v1p3beta1 as vision from google.cloud.vision_v1p3beta1 import types client = vision.ImageAnnotatorClient() image = types.Image() image.source.image_uri = ‘https://test.com/pic.jpg’ response = client.web_detection(image=image) web_entities = response.web_detection.web_entities for entity in web_entities: print(entity.description)

Sources

1/ https://Google.com/

2/ https://stackoverflow.com/questions/76499248/attributeerror-module-google-cloud-vision-has-no-attribute-image

The mention sources can contact us to remove/changing this article

[ad_2]

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Posts