Код: Выделить всё
def detect_labels(path):
client = vision.ImageAnnotatorClient()
#with urllib.request.urlopen(path) as image_file:
# content = image_file.read()
#image = vision.Image(content=content)
req = Request(
url=path,
headers={'User-Agent': 'Mozilla/5.0'}
)
image = urlopen(req).read()
response = client.label_detection(image=image)
labels = response.label_annotations
print("Labels:")
for label in labels:
print(label.description)
if response.error.message:
raise Exception(
"{}\nFor more info on error messages, check: "
"https://cloud.google.com/apis/design/errors".format(response.error.message)
)
TypeError: get() ожидал dict или сообщение protobuf, получено
Как устранить эту ошибку? Я использую Python 3.11
Подробнее здесь: https://stackoverflow.com/questions/783 ... lass-bytes