我正在尝试遍历目录中的图像并通过 goodle_api_vision 获取它们的标签。我在 google.api_core.exceptions.ServiceUnavailable: 503 Name resolution failure 中遇到错误,不知道这里的问题是什么?这是我的代码:
import io
import os
# Imports the Google Cloud client library
from google.cloud import vision
from google.cloud.vision import types
# Instantiates a client
client = vision.ImageAnnotatorClient()
# The name of the image file to annotate
file_name = os.path.join(
os.path.dirname(__file__),
'IronMan.PNG')
# 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 …
Run Code Online (Sandbox Code Playgroud)