Loading imgutils/preprocess/pillow.py +1 −1 Original line number Diff line number Diff line Loading @@ -142,7 +142,7 @@ class PillowCenterCrop: elif isinstance(size, (tuple, list)) and len(size) == 1: self.size = (size[0], size[0]) elif isinstance(size, (tuple, list)) and len(size) == 2: self.size = size self.size = (size[0], size[1]) else: raise ValueError("Please provide only two dimensions (h, w) for size.") Loading test/preprocess/test_pillow.py +11 −0 Original line number Diff line number Diff line Loading @@ -374,3 +374,14 @@ class TestPreprocessPillow: pcentercrop = PillowCenterCrop(size=size) tcentercrop = CenterCrop(size=size) assert image_diff(pcentercrop(image), tcentercrop(image), throw_exception=False) < 1e-3 @pytest.mark.parametrize(['size', 'repr_text'], [ (224, 'PillowCenterCrop(size=(224, 224))'), (384, 'PillowCenterCrop(size=(384, 384))'), ((224,), 'PillowCenterCrop(size=(224, 224))'), ([384], 'PillowCenterCrop(size=(384, 384))'), ((224, 384), 'PillowCenterCrop(size=(224, 384))'), ([224, 284], 'PillowCenterCrop(size=(224, 284))'), ]) def test_center_crop_repr(self, size, repr_text): assert repr(PillowCenterCrop(size=size)) == repr_text Loading
imgutils/preprocess/pillow.py +1 −1 Original line number Diff line number Diff line Loading @@ -142,7 +142,7 @@ class PillowCenterCrop: elif isinstance(size, (tuple, list)) and len(size) == 1: self.size = (size[0], size[0]) elif isinstance(size, (tuple, list)) and len(size) == 2: self.size = size self.size = (size[0], size[1]) else: raise ValueError("Please provide only two dimensions (h, w) for size.") Loading
test/preprocess/test_pillow.py +11 −0 Original line number Diff line number Diff line Loading @@ -374,3 +374,14 @@ class TestPreprocessPillow: pcentercrop = PillowCenterCrop(size=size) tcentercrop = CenterCrop(size=size) assert image_diff(pcentercrop(image), tcentercrop(image), throw_exception=False) < 1e-3 @pytest.mark.parametrize(['size', 'repr_text'], [ (224, 'PillowCenterCrop(size=(224, 224))'), (384, 'PillowCenterCrop(size=(384, 384))'), ((224,), 'PillowCenterCrop(size=(224, 224))'), ([384], 'PillowCenterCrop(size=(384, 384))'), ((224, 384), 'PillowCenterCrop(size=(224, 384))'), ([224, 284], 'PillowCenterCrop(size=(224, 284))'), ]) def test_center_crop_repr(self, size, repr_text): assert repr(PillowCenterCrop(size=size)) == repr_text