我在 Windows 上,使用Python 3.8.6rc1,protobuf version 3.13.0和google-cloud-vision version 2.0.0.
我的代码是:
from google.protobuf.json_format import MessageToDict
from google.cloud import vision
client = vision.ImageAnnotatorClient()
response = client.annotate_image({
'image': {'source': {'image_uri': 'https://images.unsplash.com/photo-1508138221679-760a23a2285b?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=800&q=60'}},
})
MessageToDict(response)
Run Code Online (Sandbox Code Playgroud)
它失败了MessageToDict(response),我有一个attribute error: "DESCRIPTOR". 似乎response不是有效的 protobuf 对象。有人能帮我吗?谢谢