Commit de45a333 authored by narugo1992's avatar narugo1992
Browse files

dev(narugo): finish alignment of pillow center crop

parent ecc6a7b2
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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.")

+11 −0
Original line number Diff line number Diff line
@@ -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