Skip to content

Commit 9518fb1

Browse files
committed
Fixed arc_level -> level as atan is applied internally
1 parent f26233a commit 9518fb1

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

test/test_transforms_tensor.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@
1414
cpu_and_gpu,
1515
assert_equal,
1616
)
17+
from PIL import Image
1718
from torchvision import transforms as T
1819
from torchvision.transforms import InterpolationMode
1920
from torchvision.transforms import functional as F
21+
from torchvision.transforms.autoaugment import _apply_op
2022

2123
NEAREST, BILINEAR, BICUBIC = InterpolationMode.NEAREST, InterpolationMode.BILINEAR, InterpolationMode.BICUBIC
2224

@@ -732,10 +734,6 @@ def test_autoaugment__op_apply_shear(interpolation, mode):
732734
# to official CIFAR10 autoaugment implementation:
733735
# https://github.com/tensorflow/models/blob/885fda091c46c59d6c7bb5c7e760935eacc229da/
734736
# research/autoaugment/augmentation_transforms.py#L273-L290
735-
import math
736-
737-
from PIL import Image
738-
739737
image_size = 32
740738

741739
def shear(pil_img, level, mode, resample):
@@ -745,8 +743,6 @@ def shear(pil_img, level, mode, resample):
745743
matrix = (1, 0, 0, level, 1, 0)
746744
return pil_img.transform((image_size, image_size), Image.AFFINE, matrix, resample=resample)
747745

748-
from torchvision.transforms.autoaugment import _apply_op
749-
750746
t_img, pil_img = _create_data(image_size, image_size)
751747

752748
resample_pil = {
@@ -757,9 +753,8 @@ def shear(pil_img, level, mode, resample):
757753
level = 0.3
758754
expected_out = shear(pil_img, level, mode=mode, resample=resample_pil)
759755

760-
arc_level = math.atan(level)
761756
# Check pil output vs expected pil
762-
out = _apply_op(pil_img, op_name=f"Shear{mode}", magnitude=arc_level, interpolation=interpolation, fill=0)
757+
out = _apply_op(pil_img, op_name=f"Shear{mode}", magnitude=level, interpolation=interpolation, fill=0)
763758
assert out == expected_out
764759

765760
if interpolation == F.InterpolationMode.BILINEAR:
@@ -771,7 +766,7 @@ def shear(pil_img, level, mode, resample):
771766
return
772767

773768
# Check tensor output vs expected pil
774-
out = _apply_op(t_img, op_name=f"Shear{mode}", magnitude=arc_level, interpolation=interpolation, fill=0)
769+
out = _apply_op(t_img, op_name=f"Shear{mode}", magnitude=level, interpolation=interpolation, fill=0)
775770
_assert_approx_equal_tensor_to_pil(out, expected_out)
776771

777772

0 commit comments

Comments
 (0)