【发布时间】:2019-02-26 16:16:35
【问题描述】:
import io,os
# Imports the Google Cloud client library
from google.cloud import vision
# Instantiates a client (Change the line below******)
vision_client = vision.ImageAnnotatorClient('my-key.json')
# The name of the image file to annotate (Change the line below 'image_path.jpg' ******)
file_name = os.path.join(
os.path.dirname(__file__),
'image_path.jpg')
# Loads the image into memory
with io.open(file_name, 'rb') as image_file:
content = image_file.read()
image = vision_client.image(
content=content)
# Performs label detection on the image file
labels = image.detect_labels()
print('Labels:')
for label in labels:
print(label.description)
windows 上的python 3.6.5
这个代码示例给了我标题中提到的错误,有人知道如何解决这个问题吗?
【问题讨论】:
-
也许你能告诉我我的代码示例有什么问题?
-
还有其他人吗?我只需要知道如何修复我的代码
-
就在那里...
ImageAnnotatorClient根本没有名为image的属性,这就是image = vision_client.image不起作用的原因 -
那我该如何解决呢?换什么?
标签: python google-api google-vision