diff --git a/mmpretrain/datasets/transforms/auto_augment.py b/mmpretrain/datasets/transforms/auto_augment.py index 03b057b850a..4705d5ec04e 100644 --- a/mmpretrain/datasets/transforms/auto_augment.py +++ b/mmpretrain/datasets/transforms/auto_augment.py @@ -1169,7 +1169,7 @@ def transform(self, results): img = results['img'] pil_img = Image.fromarray(img) - pil_img.filter(ImageFilter.GaussianBlur(radius=radius)) + pil_img = pil_img.filter(ImageFilter.GaussianBlur(radius=radius)) results['img'] = np.array(pil_img, dtype=img.dtype) return results diff --git a/tests/test_datasets/test_transforms/test_auto_augment.py b/tests/test_datasets/test_transforms/test_auto_augment.py index fa0761016f4..d9f65c3d993 100644 --- a/tests/test_datasets/test_transforms/test_auto_augment.py +++ b/tests/test_datasets/test_transforms/test_auto_augment.py @@ -1285,9 +1285,10 @@ def test_initialize(self): def test_transform(self): transform_func = 'PIL.ImageFilter.GaussianBlur' + from PIL.ImageFilter import GaussianBlur # test params inputs - with patch(transform_func, autospec=True) as mock: + with patch(transform_func, wraps=GaussianBlur) as mock: cfg = { **self.DEFAULT_ARGS, 'radius': 0.5, @@ -1297,7 +1298,7 @@ def test_transform(self): mock.assert_called_once_with(radius=0.5) # test prob - with patch(transform_func, autospec=True) as mock: + with patch(transform_func, wraps=GaussianBlur) as mock: cfg = { **self.DEFAULT_ARGS, 'radius': 0.5, @@ -1307,7 +1308,7 @@ def test_transform(self): mock.assert_not_called() # test magnitude_range - with patch(transform_func, autospec=True) as mock: + with patch(transform_func, wraps=GaussianBlur) as mock: cfg = { **self.DEFAULT_ARGS, 'magnitude_range': (0.1, 2),