def _filter_image_with_no_gt(self):
"""
filter images that have no ground-truth labels.
use case: when you wish to work only on a subset of pascal classes, you have 2 options:
1. use only the sub-dataset that contains the subset of classes
2. use all images, and images with no ground-truth will count as true-negative images
:return:
self object with filtered information
"""
# filter images that do not have any of the specified classes
self.labels = [f[np.logical_and(f[:, 0] >= 0, f[:, 0] <= self.num_classes-1), :] for f in self.labels]
# find indices of images with ground-truth labels
gt_indices = [idx for idx, f in enumerate(self.labels) if not f.size == 0]
self.labels = [self.labels[idx] for idx in gt_indices]
self.image_set_index = [self.image_set_index[idx] for idx in gt_indices]
old_num_images = self.num_images
self.num_images = len(self.labels)
print ('filtering images with no gt-labels. can abort filtering using *true_negative* flag')
print ('... remaining {0}/{1} images. '.format(self.num_images, old_num_images))
评论列表
文章目录