Google Clous Vision API在object_localization调用中返回空,而label_detection检测到许多

时间:2019-05-11 18:33:39

标签: python google-cloud-platform computer-vision google-cloud-vision

我遇到过几种情况,即在Google Vision API上对object_localization的调用返回空,而具有相同图像的label_detection的单元格则返回了许多具有较高确定性的对象。

示例:

此图片来自Google街景视图

enter image description here

API可以高度确定广告牌

if (chartConfig.export && chartConfig.export.enabled) {
      newChart.exporting.menu = new am4core.ExportMenu();
      newChart.exporting.menu.verticalAlign = chartConfig.export.valign as am4core.VerticalCenter;
      newChart.exporting.menu.align = chartConfig.export.halign as am4core.Align;
}
from google.cloud import vision

path = '***'
credentials = '****'
client = vision.ImageAnnotatorClient(credentials=credentials)
image_file = io.open(path, 'rb')
content = image_file.read()
image = types.Image(content=content)

# Label detection API call
response = client.label_detection(image=image)
labels = response.label_annotations
for label in labels:
    print("%s, %.4f" % (label.description, label.score))

但是随后我尝试使用对象本地化,并且……什么都没有

Billboard, 0.9892
Advertising, 0.9786
Display advertising, 0.7132
Signage, 0.6700
Banner, 0.5565
Road, 0.5271
Asphalt, 0.5006
# Object localization API call
localized_objects = client.object_localization(image=image)
localized_objects.localized_object_annotations

当我将其与其他图像一起尝试时,我得到了部分本地化,如下图所示: enter image description here

我同时获得了标签和对象本地化注释:

标签:

[]

对象本地化注释:

Residential area, 0.9777
Road, 0.9677
Lane, 0.9456
Asphalt, 0.9204
Thoroughfare, 0.8924
Neighbourhood, 0.8511
Town, 0.8481
Transport, 0.8351
Suburb, 0.8245
Infrastructure, 0.8193
Street, 0.7811
Road surface, 0.7508
Sky, 0.7326
Overhead power line, 0.7230
Tree, 0.6869
Highway, 0.6551
Architecture, 0.6545
House, 0.6313
Compact car, 0.6117
Nonbuilding structure, 0.5980
Urban design, 0.5613
Building, 0.5337
Sidewalk, 0.5259
Public utility, 0.5242
City, 0.5135
localized_objects[0]

enter image description here

因此,看来我的API配置没有根本问题,但是我可以做些什么使其使其正常工作吗?

0 个答案:

没有答案