示例#1
0
    def test_can_save_and_load(self):
        with TestDir() as test_dir:
            source_dataset = self.TestExtractor()

            converter = DatumaroConverter(save_images=True)
            converter(source_dataset, test_dir)

            project = Project.import_from(test_dir, 'datumaro')
            parsed_dataset = project.make_dataset()

            self.assertListEqual(
                sorted(source_dataset.subsets()),
                sorted(parsed_dataset.subsets()),
            )

            self.assertEqual(len(source_dataset), len(parsed_dataset))

            for subset_name in source_dataset.subsets():
                source_subset = source_dataset.get_subset(subset_name)
                parsed_subset = parsed_dataset.get_subset(subset_name)
                self.assertEqual(len(source_subset), len(parsed_subset))
                for idx, (item_a, item_b) in enumerate(
                        zip(source_subset, parsed_subset)):
                    self.assertEqual(item_a, item_b, '%s:\n%s\nvs.\n%s\n' % \
                        (idx, item_to_str(item_a), item_to_str(item_b)))

            self.assertEqual(source_dataset.categories(),
                             parsed_dataset.categories())
示例#2
0
    def test_relative_paths(self):
        class TestExtractor(Extractor):
            def __iter__(self):
                return iter([
                    DatasetItem(id='1', image=np.ones((4, 2, 3))),
                    DatasetItem(id='subdir1/1', image=np.ones((2, 6, 3))),
                    DatasetItem(id='subdir2/1', image=np.ones((5, 4, 3))),
                ])

        with TestDir() as test_dir:
            self._test_save_and_load(TestExtractor(),
                                     DatumaroConverter(save_images=True),
                                     test_dir)
示例#3
0
    def test_can_detect(self):
        with TestDir() as test_dir:
            DatumaroConverter.convert(self.test_dataset, save_dir=test_dir)

            self.assertTrue(DatumaroImporter.detect(test_dir))
示例#4
0
    def test_can_detect(self):
        with TestDir() as test_dir:
            DatumaroConverter()(self.TestExtractor(), save_dir=test_dir)

            self.assertTrue(DatumaroImporter.detect(test_dir))
示例#5
0
    def test_can_detect(self):
        with TestDir() as test_dir:
            DatumaroConverter.convert(self.test_dataset, save_dir=test_dir)

            detected_formats = Environment().detect_dataset(test_dir)
            self.assertEqual([DatumaroImporter.NAME], detected_formats)
示例#6
0
 def test_can_save_and_load(self):
     with TestDir() as test_dir:
         self._test_save_and_load(self.TestExtractor(),
                                  DatumaroConverter(save_images=True),
                                  test_dir)