如何获得 google 云视觉中预测标签的百分比

how to get the percentage for the predicted labels in google cloud vision

我已经成功地从 google vision API 得到了每个标签的描述,但是我仍然需要得到每个标签的预测百分比,谁能帮助我

我这样做是为了获取标签的描述

filename = photos.save(request.files['photo'])
file_url = photos.url(filename)
response = client.label_detection(image=image)
labels = response.label_annotations
for label in labels:
    print(label.description)

产出

Hair
Forehead
Chin
White-collar worker
Eyebrow
Hairstyle
Cheek

i'd like to get result like this :

Hair 80%
Forehead 10%
Chin 50%
White-collar worker 0%
Eyebrow 5%
Hairstyle 1%
Cheek 20%

试试这个,

for label in labels:
    desc, score = label.description, int(label.score * 100)
    print(f"{desc} {score}%")