我没有使用Google Cloud
Vision的经验,但是在查看了他们的文档和示例后,我的感觉是,有关图像数据的base64编码的链接文档页面适用于您自己创建和发送HTTP请求的情况,无需使用
vision.ImageAnnotatorClient。后者似乎是自动对图像数据进行编码,因此在您的示例中应用了双重编码。因此,我认为您应该从代码中删除编码步骤:
from google.cloud import visionimport base64client = vision.ImageAnnotatorClient()image_path ='8720911950_91828a2aeb_b.jpg'with open(image_path, 'rb') as image: content = image.read() response = client.annotate_image({'image': {'content': content}, 'features': [{'type': vision.enums.Feature.Type.LABEL_DETECTION}],}) print(response)


