def test_inplace_save_writes_only_updated_data(self): src_mask_cat = MaskCategories.generate(3, include_background=False) expected = Dataset.from_iterable( [ DatasetItem(1, subset='a', image=np.ones((2, 1, 3)), annotations=[Mask(np.ones((2, 1)), label=2)]), DatasetItem(2, subset='a', image=np.ones((3, 2, 3))), DatasetItem(2, subset='b'), ], categories=Camvid.make_camvid_categories( OrderedDict([ ('background', (0, 0, 0)), ('a', src_mask_cat.colormap[0]), ('b', src_mask_cat.colormap[1]), ]))) with TestDir() as path: dataset = Dataset.from_iterable( [ DatasetItem(1, subset='a', image=np.ones((2, 1, 3)), annotations=[Mask(np.ones((2, 1)), label=1)]), DatasetItem(2, subset='b'), DatasetItem(3, subset='c', image=np.ones((2, 2, 3)), annotations=[Mask(np.ones((2, 2)), label=0)]), ], categories={ AnnotationType.label: LabelCategories.from_iterable(['a', 'b']), AnnotationType.mask: src_mask_cat }) dataset.export(path, 'camvid', save_images=True) dataset.put(DatasetItem(2, subset='a', image=np.ones((3, 2, 3)))) dataset.remove(3, 'c') dataset.save(save_images=True) self.assertEqual( {'a', 'aannot', 'a.txt', 'b.txt', 'label_colors.txt'}, set(os.listdir(path))) self.assertEqual({'1.jpg', '2.jpg'}, set(os.listdir(osp.join(path, 'a')))) compare_datasets(self, expected, Dataset.import_from(path, 'camvid'), require_images=True)
def test_can_write_and_parse_meta_file(self): src_label_map = Camvid.CamvidLabelMap with TestDir() as test_dir: source_dataset = Dataset.from_iterable( [], categories=Camvid.make_camvid_categories(src_label_map)) CamvidConverter.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['a'] = None label_map['b'] = None return Camvid.make_camvid_categories(label_map)
def categories(self): return Camvid.make_camvid_categories()
def categories(self): label_map = OrderedDict() label_map['background'] = (0, 0, 0) label_map['label_1'] = (1, 2, 3) label_map['label_2'] = (3, 2, 1) return Camvid.make_camvid_categories(label_map)