コード例 #1
0
    def test__process_sample__without_transformations(self):
        nb_frames = 3
        frame_size = (20, 20)

        img_paths = GeneratorUtils.pick_at_intervals(
            GeneratorUtils.get_sample_images(self.fake_sample), nb_frames)
        expected = [
            GeneratorUtils.process_img(img_path, frame_size)
            for img_path in img_paths
        ]

        actual = process_sample(self.fake_sample, nb_frames, frame_size)

        npt.assert_equal(desired=expected, actual=actual)
コード例 #2
0
    def test__process_sample__with_transformations(self):
        nb_frames = 3
        frame_size = (20, 20)
        transformations = [A.HorizontalFlip(p=1)]

        img_paths = GeneratorUtils.pick_at_intervals(
            GeneratorUtils.get_sample_images(self.fake_sample), nb_frames)
        img_arrays = [
            GeneratorUtils.process_img(img_path, frame_size)
            for img_path in img_paths
        ]
        expected = GeneratorUtils.augment(img_arrays, transformations)

        actual = process_sample(self.fake_sample,
                                nb_frames,
                                frame_size,
                                transformations=transformations)

        npt.assert_equal(desired=expected, actual=actual)
コード例 #3
0
    def test__pandas_prediction_generator__yields_correct_output(self):
        batch_size = self.nb_samples
        nb_frames = 3
        frame_size = (50, 50)
        gen = PandasPredictionGenerator(self.source,
                                        self.data_path,
                                        batch_size=batch_size,
                                        nb_frames=3,
                                        frame_size=frame_size)

        expected = []
        for i in range(1, batch_size + 1):
            sample = pandasgeneratorutils.process_sample(self.data_path /
                                                         f'{i}',
                                                         nb_frames=nb_frames,
                                                         frame_size=frame_size)
            expected.append(sample)
        expected = np.stack(expected)

        actual = gen.__getitem__(0)

        npt.assert_equal(actual, expected)
コード例 #4
0
 def process_sample(self, sample: Path):
     return pandasgeneratorutils.process_sample(sample, self.nb_frames,
                                                self.frame_size, self.dtype,
                                                self.transformations)
コード例 #5
0
 def process_sample(self, sample):
     return pandasgeneratorutils.process_sample(sample, self.nb_frames,
                                                self.frame_size)