def test_can_save_and_load_segmentation_with_unordered_labels(self): source_label_map = { 'background': (0, 0, 0), 'label_1': (10, 10, 10), 'label_0': (20, 20, 20) } source_dataset = Dataset.from_iterable([ DatasetItem(id='a', image=np.ones((1, 5, 3)), annotations=[ Mask(image=np.array([[1, 0, 0, 0, 0]]), attributes={'is_crowd': False}, label=0, id=1), Mask(image=np.array([[0, 1, 0, 0, 0]]), attributes={'is_crowd': False}, label=1, id=1), Mask(image=np.array([[0, 0, 1, 1, 1]]), attributes={'is_crowd': False}, label=2, id=2) ] ) ], categories=make_kitti_categories(source_label_map)) expected_label_map = { 'background': (0, 0, 0), 'label_0': (20, 20, 20), 'label_1': (10, 10, 10) } expected_dataset = Dataset.from_iterable([ DatasetItem(id='a', image=np.ones((1, 5, 3)), annotations=[ Mask(image=np.array([[1, 0, 0, 0, 0]]), attributes={'is_crowd': False}, label=0, id=1), Mask(image=np.array([[0, 1, 0, 0, 0]]), attributes={'is_crowd': False}, label=2, id=1), Mask(image=np.array([[0, 0, 1, 1, 1]]), attributes={'is_crowd': False}, label=1, id=2) ] ) ], categories=make_kitti_categories(expected_label_map)) with TestDir() as test_dir: self._test_save_and_load(source_dataset, partial(KittiConverter.convert, tasks=KittiTask.segmentation, label_map=source_label_map), test_dir, target_dataset=expected_dataset)
def test_can_write_and_parse_dataset_meta_file(self): src_label_map = KittiLabelMap with TestDir() as test_dir: source_dataset = Dataset.from_iterable([], categories=make_kitti_categories(src_label_map)) KittiConverter.convert(source_dataset, test_dir, save_dataset_meta=True) dst_label_map = parse_meta_file(test_dir) self.assertEqual(src_label_map, dst_label_map)
def categories(self): label_map = OrderedDict() label_map['background'] = None label_map['Label_1'] = None label_map['label_2'] = None return make_kitti_categories(label_map)
def categories(self): label_map = OrderedDict() label_map['a'] = None label_map['b'] = None return make_kitti_categories(label_map)
def categories(self): return make_kitti_categories()