Skip to content

Commit

Permalink
[Fix] Fix the issue open-mmlab#1711 "GaussianBlur doesn't work" (open…
Browse files Browse the repository at this point in the history
…-mmlab#1722)

* Fix issue 1711. GaussianBlur.

* Fix UT

---------

Co-authored-by: mzr1996 <[email protected]>
  • Loading branch information
liyunlong10 and mzr1996 authored Jul 25, 2023
1 parent 60d780f commit 2b8d8ee
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion mmpretrain/datasets/transforms/auto_augment.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 4 additions & 3 deletions tests/test_datasets/test_transforms/test_auto_augment.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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),
Expand Down

0 comments on commit 2b8d8ee

Please sign in to comment.