def _label_statistics(image_paths):
'''
Calculates label statistics (number of picked pixels for each class)
Parameters
----------
image_paths : list
List of absolute paths for picked images
Returns
-------
array: numpy array
Number of selected pixels per class
'''
ds = KittiDataset()
def _rgb_2_label(rgb):
return ds.color2label[tuple(rgb)].trainId
total_counts = np.zeros(ds.num_classes())
for img in image_paths:
rgb = skimage.data.load(img)
labels = np.apply_along_axis(_rgb_2_label, 2, rgb)
indices, counts = np.unique(labels, return_counts=True)
if indices[-1] >= ds.num_classes():
indices = indices[0:-1]
counts = counts[0:-1]
total_counts[indices] += counts
return total_counts
评论列表
文章目录