所以我尝试使用Google的visionapi,它可以识别标签、面部表情和文本检测……等等
但不幸的是,我无法修复导致我们落后的错误。在
源代码
import io
import os
# Imports the Google Cloud client library
from google.cloud import vision
from google.cloud.vision import types
from google.cloud import storage
def getCredentials():
storage_client = storage.Client.from_service_account_json(
'eyeHear-cad56858f9be.json')
return storage_client
# buckets = list(storage_client.list_buckets())
# print(buckets)
def instantiateClient():
# Instantiates a client
client = vision.ImageAnnotatorClient(
credentials=getCredentials())
# The name of the image file to annotate
file_name = os.path.join(
os.path.dirname(__file__),
'images/demo-image.jpg')
# Loads the image into memory
with io.open(file_name, 'rb') as image_file:
content = image_file.read()
image = types.Image(content=content)
# Performs label detection on the image file
response = client.label_detection(image=image)
# labels = response.label_annotations
# print('Labels:')
# for label in labels:
# print(label.description)
它说“Client”对象没有属性“before-request”
这就是我被困的地方,我不知道该怎么办。在
错误
^{pr2}$
奇怪,我让它跑起来了。我必须在调用中直接声明凭据的路径操作系统环境. 也许可以尝试一下,而不是使用from storage方法?在
输出为:
^{pr2}$输入是
然后重命名为牧羊犬.jpg在
相关问题 更多 >
编程相关推荐