Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/296.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 使用gluoncv快速获取类标签-RCNN_Python_Python 3.x_Faster Rcnn - Fatal编程技术网

Python 使用gluoncv快速获取类标签-RCNN

Python 使用gluoncv快速获取类标签-RCNN,python,python-3.x,faster-rcnn,Python,Python 3.x,Faster Rcnn,我正在尝试使用gluoncv中更快的RCNN实现来计算图像中的车辆数量,如中所示。我想得到图像的字符串标签。例如,在下图中,字符串标签为“bus”。我怎样才能得到它 下面是我的实现 import os import glob from matplotlib import pyplot as plt from gluoncv import model_zoo, data, utils vehiclesum1 = [] for filename in glob.glob('/home/xx/P

我正在尝试使用gluoncv中更快的RCNN实现来计算图像中的车辆数量,如中所示。我想得到图像的字符串标签。例如,在下图中,字符串标签为“bus”。我怎样才能得到它

下面是我的实现

import os
import glob
from matplotlib import pyplot as plt
from gluoncv import model_zoo, data, utils

vehiclesum1 = []

for filename in glob.glob('/home/xx/PythonCode/test/*.jpg'):
    x, orig_img = data.transforms.presets.rcnn.load_test(filename)    

    box_ids, scores, bboxes = net(x)
    ax = utils.viz.plot_bbox(orig_img, bboxes[0], scores[0], box_ids[0], class_names=net.classes)

    # I want to identify this label1
    vehiclesum1.append(label1.count('car') + label1.count('truck') + label1.count('motorcycle') + label1.count('bus'))
    plt.show()

像这样的怎么样

# map class ID to classes
id2string = [i:name for i, name in enumerate(net.classes)]

# filter on score.
thresh = 0.8
top_classIDs = [c for c, s in zip(box_ids[0], scores[0]) if s > thresh]

# convert IDs to class names into "label1"
label1 = [id2string[c] for c in top_classIDs]