def test_can_save_dataset_with_no_save_images(self):
        source_dataset = Dataset.from_iterable([
            DatasetItem(id='0001_c2s3_000001_00',
                        subset='test',
                        image=np.ones((2, 5, 3)),
                        attributes={
                            'camera_id': 1,
                            'person_id': 1,
                            'query': True
                        }),
            DatasetItem(id='test1',
                        subset='test',
                        image=np.ones((2, 5, 3)),
                        attributes={
                            'camera_id': 1,
                            'person_id': 2,
                            'query': False
                        }),
        ])

        with TestDir() as test_dir:
            Market1501Converter.convert(source_dataset,
                                        test_dir,
                                        save_images=False)
            parsed_dataset = Dataset.import_from(test_dir, 'market1501')

            compare_datasets(self, source_dataset, parsed_dataset)
Ejemplo n.º 2
0
    def test_can_save_and_load_image_with_arbitrary_extension(self):
        expected = Dataset.from_iterable([
            DatasetItem(id='q/1',
                        image=Image(path='q/1.JPEG', data=np.zeros((4, 3, 3))),
                        attributes={
                            'camera_id': 1,
                            'person_id': 1,
                            'query': False
                        }),
            DatasetItem(id='a/b/c/2',
                        image=Image(path='a/b/c/2.bmp',
                                    data=np.zeros((3, 4, 3))),
                        attributes={
                            'camera_id': 1,
                            'person_id': 2,
                            'query': True
                        }),
        ])

        with TestDir() as test_dir:
            Market1501Converter.convert(expected, test_dir, save_images=True)
            parsed_dataset = Dataset.import_from(test_dir, 'market1501')

            compare_datasets(self,
                             expected,
                             parsed_dataset,
                             require_images=True)
Ejemplo n.º 3
0
    def test_can_save_dataset_with_no_attributes(self):
        source_dataset = Dataset.from_iterable([
            DatasetItem(id='test1',
                subset='test', image=np.ones((2, 5, 3)),
            ),
        ])

        with TestDir() as test_dir:
            Market1501Converter.convert(source_dataset, test_dir, save_images=False)
            parsed_dataset = Dataset.import_from(test_dir, 'market1501')

            compare_datasets(self, source_dataset, parsed_dataset)
Ejemplo n.º 4
0
    def test_can_save_dataset_with_cyrillic_and_spaces_in_filename(self):
        source_dataset = Dataset.from_iterable([
            DatasetItem(id='кириллица с пробелом',
                        image=np.ones((2, 5, 3)),
                        attributes={
                            'camera_id': 1,
                            'person_id': 1,
                            'query': True
                        }),
        ])

        with TestDir() as test_dir:
            Market1501Converter.convert(source_dataset,
                                        test_dir,
                                        save_images=True)
            parsed_dataset = Dataset.import_from(test_dir, 'market1501')

            compare_datasets(self,
                             source_dataset,
                             parsed_dataset,
                             require_images=True)
Ejemplo n.º 5
0
    def test_can_save_and_load(self):
        source_dataset = Dataset.from_iterable([
            DatasetItem(id='0001_c2s3_000001_00',
                subset='query', image=np.ones((2, 5, 3)),
                attributes = {'camera_id': 1, 'person_id': '0001', 'track_id': 3,
                    'frame_id': 1, 'bbox_id': 0, 'query': True}
            ),
            DatasetItem(id='0002_c4s2_000002_00',
                subset='test', image=np.ones((2, 5, 3)),
                attributes = {'camera_id': 3, 'person_id': '0002', 'track_id': 2,
                    'frame_id': 2, 'bbox_id': 0, 'query': False}
            ),
            DatasetItem(id='0001_c1s1_000003_00',
                subset='test', image=np.ones((2, 5, 3)),
                attributes = {'camera_id': 0, 'person_id': '0001', 'track_id': 1,
                    'frame_id': 3, 'bbox_id': 0, 'query': False}
            ),
        ])

        with TestDir() as test_dir:
            Market1501Converter.convert(source_dataset, test_dir, save_images=True)
            parsed_dataset = Dataset.import_from(test_dir, 'market1501')

            compare_datasets(self, source_dataset, parsed_dataset)