π Geometric Computer Vision Library for Spatial AI
Python artificial-intelligencecomputer-visiondeep-learninghacktoberfestimage-processingmachine-learningneural-networkpythonpytorchroboticsspatial-ai
Remove Re-definition found for builtin input function - Update tests (#2255)
Oleksiy Hoyev3968c42b806d
diff --git a/test/augmentation/test_augmentation_3d.py b/test/augmentation/test_augmentation_3d.pyindex c221c8a8d..65b017e26 100644--- a/test/augmentation/test_augmentation_3d.py+++ b/test/augmentation/test_augmentation_3d.py@@ -32,7 +32,7 @@ class TestRandomHorizontalFlip3D:f = RandomHorizontalFlip3D(p=1.0, keepdim=True)f1 = RandomHorizontalFlip3D(p=0.0, keepdim=True)- input = torch.tensor(+ input_tensor = torch.tensor([[[[0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 1.0, 2.0]],@@ -60,16 +60,16 @@ class TestRandomHorizontalFlip3D:[[[1.0, 0.0, 0.0, 0.0], [0.0, 1.0, 0.0, 0.0], [0.0, 0.0, 1.0, 0.0], [0.0, 0.0, 0.0, 1.0]]], device=device) # 1 x 4 x 4- assert_close(f(input), expected)+ assert_close(f(input_tensor), expected)assert_close(f.transform_matrix, expected_transform)- assert_close(f1(input), input)+ assert_close(f1(input_tensor), input_tensor)assert_close(f1.transform_matrix, identity)def test_batch_random_hflip(self, device):f = RandomHorizontalFlip3D(p=1.0)- input = torch.tensor([[[[[0.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 1.0, 1.0]]]]]) # 1 x 1 x 1 x 3 x 3- input = input.to(device)+ input_tensor = torch.tensor([[[[[0.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 1.0, 1.0]]]]]) # 1 x 1 x 1 x 3 x 3+ input_tensor = input_tensor.to(device)expected = torch.tensor([[[[[0.0, 0.0, 0.0], [0.0, 0.0, 0.0], [1.0, 1.0, 0.0]]]]]) # 1 x 1 x 1 x 3 x 3expected = expected.to(device)@@ -84,25 +84,25 @@ class TestRandomHorizontalFlip3D:) # 1 x 4 x 4identity = identity.to(device)- input = input.repeat(5, 3, 1, 1, 1) # 5 x 3 x 3 x 3 x 3+ input_tensor = input_tensor.repeat(5, 3, 1, 1, 1) # 5 x 3 x 3 x 3 x 3expected = expected.repeat(5, 3, 1, 1, 1) # 5 x 3 x 3 x 3 x 3expected_transform = expected_transform.repeat(5, 1, 1) # 5 x 4 x 4identity = identity.repeat(5, 1, 1) # 5 x 4 x 4- assert_close(f(input), expected)+ assert_close(f(input_tensor), expected)assert_close(f.transform_matrix, expected_transform)def test_same_on_batch(self, device):f = RandomHorizontalFlip3D(p=0.5, same_on_batch=True)- input = torch.eye(3, device=device).unsqueeze(dim=0).unsqueeze(dim=0).repeat(2, 1, 1, 1, 1)- res = f(input)+ input_tensor = torch.eye(3, device=device).unsqueeze(dim=0).unsqueeze(dim=0).repeat(2, 1, 1, 1, 1)+ res = f(input_tensor)assert_close(res[0], res[1])def test_sequential(self, device):f = AugmentationSequential(RandomHorizontalFlip3D(p=1.0), RandomHorizontalFlip3D(p=1.0))- input = torch.tensor([[[[[0.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 1.0, 1.0]]]]]) # 1 x 1 x 1 x 3 x 3- input = input.to(device)+ input_tensor = torch.tensor([[[[[0.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 1.0, 1.0]]]]]) # 1 x 1 x 1 x 3 x 3+ input_tensor = input_tensor.to(device)expected_transform = torch.tensor([[[-1.0, 0.0, 0.0, 2.0], [0.0, 1.0, 0.0, 0.0], [0.0, 0.0, 1.0, 0.0], [0.0, 0.0, 0.0, 1.0]]]@@ -112,13 +112,13 @@ class TestRandomHorizontalFlip3D:expected_transform_1 = expected_transform @ expected_transformexpected_transform_1 = expected_transform_1.to(device)- assert_close(f(input), input)+ assert_close(f(input_tensor), input_tensor)assert_close(f.transform_matrix, expected_transform_1)def test_gradcheck(self, device):- input = torch.rand((1, 3, 3)).to(device) # 3 x 3- input = utils.tensor_to_gradcheck_var(input) # to var- assert gradcheck(RandomHorizontalFlip3D(p=1.0), (input,), raise_exception=True, fast_mode=True)+ input_tensor = torch.rand((1, 3, 3)).to(device) # 3 x 3+ input_tensor = utils.tensor_to_gradcheck_var(input_tensor) # to var+ assert gradcheck(RandomHorizontalFlip3D(p=1.0), (input_tensor,), raise_exception=True, fast_mode=True)class TestRandomVerticalFlip3D:@@ -134,7 +134,7 @@ class TestRandomVerticalFlip3D:f = RandomVerticalFlip3D(p=1.0)f1 = RandomVerticalFlip3D(p=0.0)- input = torch.tensor(+ input_tensor = torch.tensor([[[@@ -172,17 +172,17 @@ class TestRandomVerticalFlip3D:dtype=dtype,) # 1 x 4 x 4- assert_close(f(input), expected)+ assert_close(f(input_tensor), expected)assert_close(f.transform_matrix, expected_transform)- assert_close(f1(input), input)+ assert_close(f1(input_tensor), input_tensor)assert_close(f1.transform_matrix, identity)def test_batch_random_vflip(self, device):f = RandomVerticalFlip3D(p=1.0)f1 = RandomVerticalFlip3D(p=0.0)- input = torch.tensor([[[[[0.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 1.0, 1.0]]]]]) # 1 x 1 x 1 x 3 x 3- input = input.to(device)+ input_tensor = torch.tensor([[[[[0.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 1.0, 1.0]]]]]) # 1 x 1 x 1 x 3 x 3+ input_tensor = input_tensor.to(device)expected = torch.tensor([[[[[0.0, 1.0, 1.0], [0.0, 0.0, 0.0], [0.0, 0.0, 0.0]]]]]) # 1 x 1 x 1 x 3 x 3expected = expected.to(device)@@ -197,27 +197,27 @@ class TestRandomVerticalFlip3D:) # 1 x 4 x 4identity = identity.to(device)- input = input.repeat(5, 3, 1, 1, 1) # 5 x 3 x 3 x 3 x 3+ input_tensor = input_tensor.repeat(5, 3, 1, 1, 1) # 5 x 3 x 3 x 3 x 3expected = expected.repeat(5, 3, 1, 1, 1) # 5 x 3 x 3 x 3 x 3expected_transform = expected_transform.repeat(5, 1, 1) # 5 x 4 x 4identity = identity.repeat(5, 1, 1) # 5 x 4 x 4- assert_close(f(input), expected)+ assert_close(f(input_tensor), expected)assert_close(f.transform_matrix, expected_transform)- assert_close(f1(input), input)+ assert_close(f1(input_tensor), input_tensor)assert_close(f1.transform_matrix, identity)def test_same_on_batch(self, device):f = RandomVerticalFlip3D(p=0.5, same_on_batch=True)- input = torch.eye(3).unsqueeze(dim=0).unsqueeze(dim=0).repeat(2, 1, 1, 1, 1)- res = f(input)+ input_tensor = torch.eye(3).unsqueeze(dim=0).unsqueeze(dim=0).repeat(2, 1, 1, 1, 1)+ res = f(input_tensor)assert_close(res[0], res[1])def test_sequential(self, device):f = AugmentationSequential(RandomVerticalFlip3D(p=1.0), RandomVerticalFlip3D(p=1.0))- input = torch.tensor([[[[[0.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 1.0, 1.0]]]]]) # 1 x 1 x 1 x 4 x 4- input = input.to(device)+ input_tensor = torch.tensor([[[[[0.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 1.0, 1.0]]]]]) # 1 x 1 x 1 x 4 x 4+ input_tensor = input_tensor.to(device)expected_transform = torch.tensor([[[1.0, 0.0, 0.0, 0.0], [0.0, -1.0, 0.0, 2.0], [0.0, 0.0, 1.0, 0.0], [0.0, 0.0, 0.0, 1.0]]]@@ -226,13 +226,13 @@ class TestRandomVerticalFlip3D:expected_transform_1 = expected_transform @ expected_transform- assert_close(f(input), input)+ assert_close(f(input_tensor), input_tensor)assert_close(f.transform_matrix, expected_transform_1)def test_gradcheck(self, device):- input = torch.rand((1, 3, 3)).to(device) # 4 x 4- input = utils.tensor_to_gradcheck_var(input) # to var- assert gradcheck(RandomVerticalFlip3D(p=1.0), (input,), raise_exception=True, fast_mode=True)+ input_tensor = torch.rand((1, 3, 3)).to(device) # 4 x 4+ input_tensor = utils.tensor_to_gradcheck_var(input_tensor) # to var+ assert gradcheck(RandomVerticalFlip3D(p=1.0), (input_tensor,), raise_exception=True, fast_mode=True)class TestRandomDepthicalFlip3D:@@ -248,7 +248,7 @@ class TestRandomDepthicalFlip3D:f = RandomDepthicalFlip3D(p=1.0)f1 = RandomDepthicalFlip3D(p=0.0)- input = torch.tensor(+ input_tensor = torch.tensor([[[@@ -286,23 +286,23 @@ class TestRandomDepthicalFlip3D:dtype=dtype,) # 4 x 4- assert_close(f(input), expected)+ assert_close(f(input_tensor), expected)assert_close(f.transform_matrix, expected_transform)- assert_close(f1(input), input)+ assert_close(f1(input_tensor), input_tensor)assert_close(f1.transform_matrix, identity)def test_batch_random_dflip(self, device):f = RandomDepthicalFlip3D(p=1.0)f1 = RandomDepthicalFlip3D(p=0.0)- input = torch.tensor(+ input_tensor = torch.tensor([[[0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 1.0]],[[0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 2.0]],]) # 2 x 3 x 4- input = input.to(device)+ input_tensor = input_tensor.to(device)expected = torch.tensor([@@ -322,26 +322,26 @@ class TestRandomDepthicalFlip3D:) # 1 x 4 x 4identity = identity.to(device)- input = input.repeat(5, 3, 1, 1, 1) # 5 x 3 x 3 x 3 x 3+ input_tensor = input_tensor.repeat(5, 3, 1, 1, 1) # 5 x 3 x 3 x 3 x 3expected = expected.repeat(5, 3, 1, 1, 1) # 5 x 3 x 3 x 3 x 3expected_transform = expected_transform.repeat(5, 1, 1) # 5 x 4 x 4identity = identity.repeat(5, 1, 1) # 5 x 4 x 4- assert_close(f(input), expected)+ assert_close(f(input_tensor), expected)assert_close(f.transform_matrix, expected_transform)- assert_close(f1(input), input)+ assert_close(f1(input_tensor), input_tensor)assert_close(f1.transform_matrix, identity)def test_same_on_batch(self, device):f = RandomDepthicalFlip3D(p=0.5, same_on_batch=True)- input = torch.eye(3).unsqueeze(dim=0).unsqueeze(dim=0).repeat(2, 1, 2, 1, 1)- res = f(input)+ input_tensor = torch.eye(3).unsqueeze(dim=0).unsqueeze(dim=0).repeat(2, 1, 2, 1, 1)+ res = f(input_tensor)assert_close(res[0], res[1])def test_sequential(self, device):f = AugmentationSequential(RandomDepthicalFlip3D(p=1.0), RandomDepthicalFlip3D(p=1.0))- input = torch.tensor(+ input_tensor = torch.tensor([[[@@ -351,7 +351,7 @@ class TestRandomDepthicalFlip3D:]]) # 2 x 3 x 4- input = input.to(device)+ input_tensor = input_tensor.to(device)expected_transform = torch.tensor([[[1.0, 0.0, 0.0, 0.0], [0.0, 1.0, 0.0, 0.0], [0.0, 0.0, -1.0, 1.0], [0.0, 0.0, 0.0, 1.0]]]@@ -360,13 +360,13 @@ class TestRandomDepthicalFlip3D:expected_transform_1 = expected_transform @ expected_transform- assert_close(f(input), input)+ assert_close(f(input_tensor), input_tensor)assert_close(f.transform_matrix, expected_transform_1)def test_gradcheck(self, device):- input = torch.rand((1, 3, 3)).to(device) # 4 x 4- input = utils.tensor_to_gradcheck_var(input) # to var- assert gradcheck(RandomDepthicalFlip3D(p=1.0), (input,), raise_exception=True, fast_mode=True)+ input_tensor = torch.rand((1, 3, 3)).to(device) # 4 x 4+ input_tensor = utils.tensor_to_gradcheck_var(input_tensor) # to var+ assert gradcheck(RandomDepthicalFlip3D(p=1.0), (input_tensor,), raise_exception=True, fast_mode=True)class TestRandomRotation3D:@@ -391,7 +391,7 @@ class TestRandomRotation3D:f = RandomRotation3D(degrees=45.0)- input = torch.tensor(+ input_tensor = torch.tensor([[[1.0, 0.0, 0.0, 2.0], [0.0, 0.0, 0.0, 0.0], [0.0, 1.0, 2.0, 0.0], [0.0, 0.0, 1.0, 2.0]],[[1.0, 0.0, 0.0, 2.0], [0.0, 0.0, 0.0, 0.0], [0.0, 1.0, 2.0, 0.0], [0.0, 0.0, 1.0, 2.0]],@@ -443,7 +443,7 @@ class TestRandomRotation3D:dtype=dtype,)- out = f(input)+ out = f(input_tensor)assert_close(out, expected, rtol=1e-6, atol=1e-4)assert_close(f.transform_matrix, expected_transform, rtol=1e-6, atol=1e-4)@@ -452,7 +452,7 @@ class TestRandomRotation3D:f = RandomRotation3D(degrees=45.0)- input = torch.tensor(+ input_tensor = torch.tensor([[[[1.0, 0.0, 0.0, 2.0], [0.0, 0.0, 0.0, 0.0], [0.0, 1.0, 2.0, 0.0], [0.0, 0.0, 1.0, 2.0]],@@ -534,23 +534,23 @@ class TestRandomRotation3D:dtype=dtype,)- input = input.repeat(2, 1, 1, 1, 1) # 5 x 4 x 4 x 3+ input_tensor = input_tensor.repeat(2, 1, 1, 1, 1) # 5 x 4 x 4 x 3- out = f(input)+ out = f(input_tensor)assert_close(out, expected, rtol=1e-6, atol=1e-4)assert_close(f.transform_matrix, expected_transform, rtol=1e-6, atol=1e-4)def test_same_on_batch(self, device, dtype):f = RandomRotation3D(degrees=40, same_on_batch=True)- input = torch.eye(6, device=device, dtype=dtype).unsqueeze(dim=0).unsqueeze(dim=0).repeat(2, 3, 6, 1, 1)- res = f(input)+ input_tensor = torch.eye(6, device=device, dtype=dtype).unsqueeze(dim=0).unsqueeze(dim=0).repeat(2, 3, 6, 1, 1)+ res = f(input_tensor)assert_close(res[0], res[1])def test_sequential(self, device, dtype):torch.manual_seed(24) # for random reproductibilityf = AugmentationSequential(RandomRotation3D(torch.tensor([-45.0, 90])), RandomRotation3D(10.4))- input = torch.tensor(+ input_tensor = torch.tensor([[[1.0, 0.0, 0.0, 2.0], [0.0, 0.0, 0.0, 0.0], [0.0, 1.0, 2.0, 0.0], [0.0, 0.0, 1.0, 2.0]],[[1.0, 0.0, 0.0, 2.0], [0.0, 0.0, 0.0, 0.0], [0.0, 1.0, 2.0, 0.0], [0.0, 0.0, 1.0, 2.0]],@@ -602,16 +602,18 @@ class TestRandomRotation3D:dtype=dtype,)- out = f(input)+ out = f(input_tensor)assert_close(out, expected, rtol=1e-6, atol=1e-4)assert_close(f.transform_matrix, expected_transform, rtol=1e-6, atol=1e-4)def test_gradcheck(self, device):torch.manual_seed(0) # for random reproductibility- input = torch.rand((3, 3, 3)).to(device) # 3 x 3 x 3- input = utils.tensor_to_gradcheck_var(input) # to var- assert gradcheck(RandomRotation3D(degrees=(15.0, 15.0), p=1.0), (input,), raise_exception=True, fast_mode=True)+ input_tensor = torch.rand((3, 3, 3)).to(device) # 3 x 3 x 3+ input_tensor = utils.tensor_to_gradcheck_var(input_tensor) # to var+ assert gradcheck(+ RandomRotation3D(degrees=(15.0, 15.0), p=1.0), (input_tensor,), raise_exception=True, fast_mode=True+ )class TestRandomCrop3D:@@ -630,7 +632,7 @@ class TestRandomCrop3D:@pytest.mark.parametrize("batch_size", [1, 2])def test_no_padding(self, batch_size, device, dtype):torch.manual_seed(42)- inp = torch.tensor(+ input_tensor = torch.tensor([[[@@ -648,7 +650,7 @@ class TestRandomCrop3D:dtype=dtype,).repeat(batch_size, 1, 5, 1, 1)f = RandomCrop3D(size=(2, 3, 4), padding=None, align_corners=True, p=1.0)- out = f(inp)+ out = f(input_tensor)if batch_size == 1:expected = torch.tensor([[[[[11, 12, 13, 14], [16, 17, 18, 19], [21, 22, 23, 24]]]]], device=device, dtype=dtype@@ -693,23 +695,23 @@ class TestRandomCrop3D:def test_same_on_batch(self, device, dtype):f = RandomCrop3D(size=(2, 3, 4), padding=None, align_corners=True, p=1.0, same_on_batch=True)- input = (+ input_tensor = (torch.eye(6, device=device, dtype=dtype).unsqueeze(dim=0).unsqueeze(dim=0).unsqueeze(dim=0).repeat(2, 3, 5, 1, 1))- res = f(input)+ res = f(input_tensor)assert_close(res[0], res[1])@pytest.mark.parametrize("padding", [1, (1, 1, 1), (1, 1, 1, 1, 1, 1)])def test_padding_batch(self, padding, device, dtype):torch.manual_seed(42)batch_size = 2- inp = torch.tensor([[[[0.0, 1.0, 2.0], [3.0, 4.0, 5.0], [6.0, 7.0, 8.0]]]], device=device, dtype=dtype).repeat(- batch_size, 1, 3, 1, 1- )+ input_tensor = torch.tensor(+ [[[[0.0, 1.0, 2.0], [3.0, 4.0, 5.0], [6.0, 7.0, 8.0]]]], device=device, dtype=dtype+ ).repeat(batch_size, 1, 3, 1, 1)expected = torch.tensor([[@@ -729,13 +731,13 @@ class TestRandomCrop3D:dtype=dtype,)f = RandomCrop3D(size=(2, 3, 4), fill=10.0, padding=padding, align_corners=True, p=1.0)- out = f(inp)+ out = f(input_tensor)assert_close(out, expected, atol=1e-4, rtol=1e-4)def test_pad_if_needed(self, device, dtype):torch.manual_seed(42)- inp = torch.tensor([[[0.0, 1.0, 2.0]]], device=device, dtype=dtype)+ input_tensor = torch.tensor([[[0.0, 1.0, 2.0]]], device=device, dtype=dtype)expected = torch.tensor([[@@ -749,15 +751,15 @@ class TestRandomCrop3D:dtype=dtype,)rc = RandomCrop3D(size=(2, 3, 4), pad_if_needed=True, fill=9, align_corners=True, p=1.0)- out = rc(inp)+ out = rc(input_tensor)assert_close(out, expected, atol=1e-4, rtol=1e-4)def test_gradcheck(self, device, dtype):torch.manual_seed(0) # for random reproductibility- inp = torch.rand((3, 3, 3), device=device, dtype=dtype) # 3 x 3- inp = utils.tensor_to_gradcheck_var(inp) # to var- assert gradcheck(RandomCrop3D(size=(3, 3, 3), p=1.0), (inp,), raise_exception=True, fast_mode=True)+ input_tensor = torch.rand((3, 3, 3), device=device, dtype=dtype) # 3 x 3+ input_tensor = utils.tensor_to_gradcheck_var(input_tensor) # to var+ assert gradcheck(RandomCrop3D(size=(3, 3, 3), p=1.0), (input_tensor,), raise_exception=True, fast_mode=True)@pytest.mark.skip("Need to fix Union type")def test_jit(self, device, dtype):@@ -808,9 +810,9 @@ class TestCenterCrop3D:assert out.shape == (1, 2, 3, 4, 5)def test_gradcheck(self, device, dtype):- input = torch.rand(1, 2, 3, 4, 5, device=device, dtype=dtype)- input = utils.tensor_to_gradcheck_var(input) # to var- assert gradcheck(CenterCrop3D(3), (input,), raise_exception=True, fast_mode=True)+ input_tensor = torch.rand(1, 2, 3, 4, 5, device=device, dtype=dtype)+ input_tensor = utils.tensor_to_gradcheck_var(input_tensor) # to var+ assert gradcheck(CenterCrop3D(3), (input_tensor,), raise_exception=True, fast_mode=True)class TestRandomEqualize3D:@@ -864,9 +866,9 @@ class TestRandomEqualize3D:def test_same_on_batch(self, device, dtype):f = RandomEqualize3D(p=0.5, same_on_batch=True)- input = torch.eye(4, device=device, dtype=dtype)- input = input.unsqueeze(dim=0).unsqueeze(dim=0).repeat(2, 1, 2, 1, 1)- res = f(input)+ input_tensor = torch.eye(4, device=device, dtype=dtype)+ input_tensor = input_tensor.unsqueeze(dim=0).unsqueeze(dim=0).repeat(2, 1, 2, 1, 1)+ res = f(input_tensor)assert_close(res[0], res[1])def test_gradcheck(self, device, dtype):diff --git a/test/enhance/test_equalization.py b/test/enhance/test_equalization.pyindex e094d501d..8c0b35729 100644--- a/test/enhance/test_equalization.py+++ b/test/enhance/test_equalization.py@@ -75,8 +75,8 @@ class TestEqualization(BaseTester):inputs = torch.rand(bs, channels, height, width, device=device, dtype=dtype)inputs = tensor_to_gradcheck_var(inputs)- def grad_rot(input, a, b, c):- rot = rotate(input, torch.tensor(30.0, dtype=input.dtype, device=device))+ def grad_rot(inpt, a, b, c):+ rot = rotate(inpt, torch.tensor(30.0, dtype=inpt.dtype, device=device))return enhance.equalize_clahe(rot, a, b, c)assert gradcheck(grad_rot, (inputs, 40.0, (2, 2), True), nondet_tol=1e-4, raise_exception=True, fast_mode=True)diff --git a/test/enhance/test_histogram.py b/test/enhance/test_histogram.pyindex 431fe21ff..e8e1816cc 100644--- a/test/enhance/test_histogram.py+++ b/test/enhance/test_histogram.py@@ -13,31 +13,31 @@ class TestImageHistogram2d:@pytest.mark.parametrize("kernel", ["triangular", "gaussian", "uniform", "epanechnikov"])def test_shape(self, device, dtype, kernel):- input = torch.ones(32, 32, device=device, dtype=dtype)- hist, pdf = TestImageHistogram2d.fcn(input, 0.0, 1.0, 256, kernel=kernel)+ sample = torch.ones(32, 32, device=device, dtype=dtype)+ hist, pdf = TestImageHistogram2d.fcn(sample, 0.0, 1.0, 256, kernel=kernel)assert hist.shape == (256,) and pdf.shape == (256,)@pytest.mark.parametrize("kernel", ["triangular", "gaussian", "uniform", "epanechnikov"])def test_shape_channels(self, device, dtype, kernel):- input = torch.ones(3, 32, 32, device=device, dtype=dtype)- hist, pdf = TestImageHistogram2d.fcn(input, 0.0, 1.0, 256, kernel=kernel)+ sample = torch.ones(3, 32, 32, device=device, dtype=dtype)+ hist, pdf = TestImageHistogram2d.fcn(sample, 0.0, 1.0, 256, kernel=kernel)assert hist.shape == (3, 256) and pdf.shape == (3, 256)@pytest.mark.parametrize("kernel", ["triangular", "gaussian", "uniform", "epanechnikov"])def test_shape_batch(self, device, dtype, kernel):- input = torch.ones(8, 3, 32, 32, device=device, dtype=dtype)- hist, pdf = TestImageHistogram2d.fcn(input, 0.0, 1.0, 256, kernel=kernel)+ sample = torch.ones(8, 3, 32, 32, device=device, dtype=dtype)+ hist, pdf = TestImageHistogram2d.fcn(sample, 0.0, 1.0, 256, kernel=kernel)assert hist.shape == (8, 3, 256) and pdf.shape == (8, 3, 256)@pytest.mark.parametrize("kernel", ["triangular", "gaussian", "uniform", "epanechnikov"])def test_gradcheck(self, device, dtype, kernel):- input = torch.ones(32, 32, device=device, dtype=dtype)- input = utils.tensor_to_gradcheck_var(input) # to var+ sample = torch.ones(32, 32, device=device, dtype=dtype)+ sample = utils.tensor_to_gradcheck_var(sample) # to varcenters = torch.linspace(0, 255, 8, device=device, dtype=dtype)centers = utils.tensor_to_gradcheck_var(centers)assert gradcheck(TestImageHistogram2d.fcn,- (input, 0.0, 255.0, 256, None, centers, True, kernel),+ (sample, 0.0, 255.0, 256, None, centers, True, kernel),raise_exception=True,fast_mode=True,)@@ -47,43 +47,43 @@ class TestImageHistogram2d:)@pytest.mark.parametrize("kernel", ["triangular", "gaussian", "uniform", "epanechnikov"])def test_jit(self, device, dtype, kernel):- input = torch.linspace(0, 255, 10, device=device, dtype=dtype)- input_x, _ = torch.meshgrid(input, input)- inputs = (input_x, 0.0, 255.0, 10, None, None, False, kernel)+ sample = torch.linspace(0, 255, 10, device=device, dtype=dtype)+ sample_x, _ = torch.meshgrid(sample, sample)+ samples = (sample_x, 0.0, 255.0, 10, None, None, False, kernel)op = TestImageHistogram2d.fcnop_script = torch.jit.script(op)- out, out_script = op(*inputs), op_script(*inputs)+ out, out_script = op(*samples), op_script(*samples)assert_close(out[0], out_script[0])assert_close(out[1], out_script[1])@pytest.mark.parametrize("kernel", ["triangular", "gaussian", "uniform", "epanechnikov"])@pytest.mark.parametrize("size", [(1, 1), (3, 1, 1), (8, 3, 1, 1)])def test_uniform_hist(self, device, dtype, kernel, size):- input = torch.linspace(0, 255, 10, device=device, dtype=dtype)- input_x, _ = torch.meshgrid(input, input)- input_x = input_x.repeat(*size)+ sample = torch.linspace(0, 255, 10, device=device, dtype=dtype)+ sample_x, _ = torch.meshgrid(sample, sample)+ sample_x = sample_x.repeat(*size)if kernel == "gaussian":bandwidth = 2 * 0.4**2else:bandwidth = None- hist, _ = TestImageHistogram2d.fcn(input_x, 0.0, 255.0, 10, bandwidth=bandwidth, centers=input, kernel=kernel)+ hist, _ = TestImageHistogram2d.fcn(sample_x, 0.0, 255.0, 10, bandwidth=bandwidth, centers=sample, kernel=kernel)ans = 10 * torch.ones_like(hist)assert_close(ans, hist)@pytest.mark.parametrize("kernel", ["triangular", "gaussian", "uniform", "epanechnikov"])@pytest.mark.parametrize("size", [(1, 1), (3, 1, 1), (8, 3, 1, 1)])def test_uniform_dist(self, device, dtype, kernel, size):- input = torch.linspace(0, 255, 10, device=device, dtype=dtype)- input_x, _ = torch.meshgrid(input, input)- input_x = input_x.repeat(*size)+ sample = torch.linspace(0, 255, 10, device=device, dtype=dtype)+ sample_x, _ = torch.meshgrid(sample, sample)+ sample_x = sample_x.repeat(*size)if kernel == "gaussian":bandwidth = 2 * 0.4**2else:bandwidth = Nonehist, pdf = TestImageHistogram2d.fcn(- input_x, 0.0, 255.0, 10, bandwidth=bandwidth, centers=input, kernel=kernel, return_pdf=True+ sample_x, 0.0, 255.0, 10, bandwidth=bandwidth, centers=sample, kernel=kernel, return_pdf=True)ans = 0.1 * torch.ones_like(hist)assert_close(ans, pdf)@@ -120,24 +120,24 @@ class TestHistogram2d:assert gradcheck(TestHistogram2d.fcn, (inp1, inp2, bins, bandwidth), raise_exception=True, fast_mode=True)def test_jit(self, device, dtype):- input1 = torch.linspace(0, 255, 10, device=device, dtype=dtype).unsqueeze(0)- input2 = torch.linspace(0, 255, 10, device=device, dtype=dtype).unsqueeze(0)+ sample1 = torch.linspace(0, 255, 10, device=device, dtype=dtype).unsqueeze(0)+ sample2 = torch.linspace(0, 255, 10, device=device, dtype=dtype).unsqueeze(0)bins = torch.linspace(0, 255, 10, device=device, dtype=dtype)bandwidth = torch.tensor(2 * 0.4**2, device=device, dtype=dtype)- inputs = (input1, input2, bins, bandwidth)+ samples = (sample1, sample2, bins, bandwidth)op = TestHistogram2d.fcnop_script = torch.jit.script(op)- assert_close(op(*inputs), op_script(*inputs))+ assert_close(op(*samples), op_script(*samples))def test_uniform_dist(self, device, dtype):- input1 = torch.linspace(0, 255, 10, device=device, dtype=dtype).unsqueeze(0)- input2 = torch.linspace(0, 255, 10, device=device, dtype=dtype).unsqueeze(0)+ sample1 = torch.linspace(0, 255, 10, device=device, dtype=dtype).unsqueeze(0)+ sample2 = torch.linspace(0, 255, 10, device=device, dtype=dtype).unsqueeze(0)bins = torch.linspace(0, 255, 10, device=device, dtype=dtype)bandwidth = torch.tensor(2 * 0.4**2, device=device, dtype=dtype)- pdf = TestHistogram2d.fcn(input1, input2, bins, bandwidth)+ pdf = TestHistogram2d.fcn(sample1, sample2, bins, bandwidth)ans = 0.1 * kornia.eye_like(10, pdf)assert_close(ans, pdf)diff --git a/test/feature/test_loftr.py b/test/feature/test_loftr.pyindex dc9951912..a29434f85 100644--- a/test/feature/test_loftr.py+++ b/test/feature/test_loftr.py@@ -46,9 +46,9 @@ class TestLoFTR:patches = torch.rand(1, 1, 32, 32, device=device)mask = torch.rand(1, 32, 32, device=device)loftr = LoFTR().to(patches.device, patches.dtype)- input = {"image0": patches, "image1": patches, "mask0": mask, "mask1": mask}+ sample = {"image0": patches, "image1": patches, "mask0": mask, "mask1": mask}with torch.no_grad():- out = loftr(input)+ out = loftr(sample)assert out is not Nonedef test_gradcheck(self, device):@@ -68,10 +68,10 @@ class TestLoFTR:B, C, H, W = 1, 1, 32, 32patches = torch.rand(B, C, H, W, device=device, dtype=dtype)patches2x = resize(patches, (48, 48))- input = {"image0": patches, "image1": patches2x}+ sample = {"image0": patches, "image1": patches2x}model = LoFTR().to(patches.device, patches.dtype).eval()model_jit = torch.jit.script(model)- out = model(input)- out_jit = model_jit(input)+ out = model(sample)+ out_jit = model_jit(sample)for k, v in out.items():assert_close(v, out_jit[k])diff --git a/test/filters/test_filters.py b/test/filters/test_filters.pyindex 2c1f843ad..017f33cf6 100644--- a/test/filters/test_filters.py+++ b/test/filters/test_filters.py@@ -13,10 +13,10 @@ class TestFilter2D(BaseTester):def test_smoke(self, border_type, normalized, padding, device, dtype):kernel = torch.rand(1, 3, 3, device=device, dtype=dtype)_, height, width = kernel.shape- input = torch.ones(1, 1, 7, 8, device=device, dtype=dtype)- b, c, h, w = input.shape+ sample = torch.ones(1, 1, 7, 8, device=device, dtype=dtype)+ b, c, h, w = sample.shape- actual = filter2d(input, kernel, border_type, normalized, padding)+ actual = filter2d(sample, kernel, border_type, normalized, padding)assert isinstance(actual, torch.Tensor)assert actual.shape in {(b, c, h, w), (b, c, h - height + 1, w - width + 1)}@@ -26,9 +26,9 @@ class TestFilter2D(BaseTester):B: int = batch_sizekernel = torch.rand(1, 3, 3, device=device, dtype=dtype)_, height, width = kernel.shape- input = torch.ones(B, 3, 7, 8, device=device, dtype=dtype)- b, c, h, w = input.shape- out = filter2d(input, kernel, padding=padding)+ sample = torch.ones(B, 3, 7, 8, device=device, dtype=dtype)+ b, c, h, w = sample.shape+ out = filter2d(sample, kernel, padding=padding)if padding == 'same':assert out.shape == (b, c, h, w)else:@@ -64,7 +64,7 @@ class TestFilter2D(BaseTester):@pytest.mark.parametrize("padding", ["same", "valid"])def test_mean_filter(self, padding, device, dtype):kernel = torch.ones(1, 3, 3, device=device, dtype=dtype)- input = torch.tensor(+ sample = torch.tensor([[[@@ -80,7 +80,7 @@ class TestFilter2D(BaseTester):dtype=dtype,)- actual = filter2d(input, kernel, padding=padding)+ actual = filter2d(sample, kernel, padding=padding)if padding == 'same':expected_same = torch.tensor(@@ -110,7 +110,7 @@ class TestFilter2D(BaseTester):@pytest.mark.parametrize("padding", ["same", "valid"])def test_mean_filter_2batch_2ch(self, padding, device, dtype):kernel = torch.ones(1, 3, 3, device=device, dtype=dtype)- input = torch.tensor(+ sample = torch.tensor([[[@@ -126,7 +126,7 @@ class TestFilter2D(BaseTester):dtype=dtype,).expand(2, 2, -1, -1)- actual = filter2d(input, kernel, padding=padding)+ actual = filter2d(sample, kernel, padding=padding)if padding == 'same':expected_same = torch.tensor(@@ -155,7 +155,7 @@ class TestFilter2D(BaseTester):@pytest.mark.parametrize("padding", ["same", "valid"])def test_normalized_mean_filter(self, padding, device, dtype):kernel = torch.ones(1, 3, 3, device=device, dtype=dtype)- input = torch.tensor(+ sample = torch.tensor([[[@@ -172,7 +172,7 @@ class TestFilter2D(BaseTester):).expand(2, 2, -1, -1)nv: float = 5.0 / 9 # normalization value- actual = filter2d(input, kernel, normalized=True, padding=padding)+ actual = filter2d(sample, kernel, normalized=True, padding=padding)if padding == 'same':expected_same = torch.tensor(@@ -202,7 +202,7 @@ class TestFilter2D(BaseTester):@pytest.mark.parametrize("padding", ["same", "valid"])def test_even_sized_filter(self, padding, device, dtype):kernel = torch.ones(1, 2, 2, device=device, dtype=dtype)- input = torch.tensor(+ sample = torch.tensor([[[@@ -218,7 +218,7 @@ class TestFilter2D(BaseTester):dtype=dtype,)- actual = filter2d(input, kernel, padding=padding)+ actual = filter2d(sample, kernel, padding=padding)if padding == 'same':expected_same = torch.tensor(@@ -250,7 +250,7 @@ class TestFilter2D(BaseTester):@pytest.mark.parametrize("padding", ["same", "valid"])def test_mix_sized_filter_padding_same(self, padding, device, dtype):kernel = torch.ones(1, 5, 6, device=device, dtype=dtype)- input_ = torch.tensor(+ sample_ = torch.tensor([[[@@ -282,7 +282,7 @@ class TestFilter2D(BaseTester):dtype=dtype,)- actual = filter2d(input_, kernel, padding='same', border_type='constant')+ actual = filter2d(sample_, kernel, padding='same', border_type='constant')self.assert_close(actual, expected_same)@pytest.mark.parametrize("padding", ["same", "valid"])@@ -307,12 +307,12 @@ class TestFilter2D(BaseTester):def test_gradcheck(self, device):kernel = torch.rand(1, 3, 3, device=device)- input = torch.ones(1, 1, 7, 8, device=device)+ sample = torch.ones(1, 1, 7, 8, device=device)# evaluate function gradient- input = tensor_to_gradcheck_var(input) # to var+ sample = tensor_to_gradcheck_var(sample) # to varkernel = tensor_to_gradcheck_var(kernel) # to var- self.gradcheck(filter2d, (input, kernel), nondet_tol=1e-8)+ self.gradcheck(filter2d, (sample, kernel), nondet_tol=1e-8)@pytest.mark.skip(reason='filter2d do not have a module')def test_module(self):@@ -377,7 +377,7 @@ class TestFilter3D(BaseTester):def test_mean_filter(self, device, dtype):kernel = torch.ones(1, 3, 3, 3, device=device, dtype=dtype)- input = torch.tensor(+ sample = torch.tensor([[[@@ -441,12 +441,12 @@ class TestFilter3D(BaseTester):dtype=dtype,)- actual = filter3d(input, kernel)+ actual = filter3d(sample, kernel)self.assert_close(actual, expected)def test_mean_filter_2batch_2ch(self, device, dtype):kernel = torch.ones(1, 3, 3, 3, device=device, dtype=dtype)- input = torch.tensor(+ sample = torch.tensor([[[@@ -477,7 +477,7 @@ class TestFilter3D(BaseTester):device=device,dtype=dtype,)- input = input.expand(2, 2, -1, -1, -1)+ sample = sample.expand(2, 2, -1, -1, -1)expected = torch.tensor([@@ -512,12 +512,12 @@ class TestFilter3D(BaseTester):)expected = expected.expand(2, 2, -1, -1, -1)- actual = filter3d(input, kernel)+ actual = filter3d(sample, kernel)self.assert_close(actual, expected)def test_normalized_mean_filter(self, device, dtype):kernel = torch.ones(1, 3, 3, 3, device=device, dtype=dtype)- input = torch.tensor(+ sample = torch.tensor([[[@@ -548,7 +548,7 @@ class TestFilter3D(BaseTester):device=device,dtype=dtype,)- input = input.expand(2, 2, -1, -1, -1)+ sample = sample.expand(2, 2, -1, -1, -1)nv = 5.0 / 27 # normalization valueexpected = torch.tensor(@@ -584,13 +584,13 @@ class TestFilter3D(BaseTester):)expected = expected.expand(2, 2, -1, -1, -1)- actual = filter3d(input, kernel, normalized=True)+ actual = filter3d(sample, kernel, normalized=True)self.assert_close(actual, expected)def test_even_sized_filter(self, device, dtype):kernel = torch.ones(1, 2, 2, 2, device=device, dtype=dtype)- input = torch.tensor(+ sample = torch.tensor([[[@@ -654,7 +654,7 @@ class TestFilter3D(BaseTester):dtype=dtype,)- actual = filter3d(input, kernel)+ actual = filter3d(sample, kernel)self.assert_close(actual, expected)def test_noncontiguous(self, device, dtype):@@ -667,12 +667,12 @@ class TestFilter3D(BaseTester):def test_gradcheck(self, device):kernel = torch.rand(1, 3, 3, 3, device=device)- input = torch.ones(1, 1, 6, 7, 8, device=device)+ sample = torch.ones(1, 1, 6, 7, 8, device=device)# evaluate function gradient- input = tensor_to_gradcheck_var(input) # to var+ sample = tensor_to_gradcheck_var(sample) # to varkernel = tensor_to_gradcheck_var(kernel) # to var- self.gradcheck(filter3d, (input, kernel), nondet_tol=1e-8)+ self.gradcheck(filter3d, (sample, kernel), nondet_tol=1e-8)@pytest.mark.skip(reason='filter3d do not have a module')def test_module(self):diff --git a/test/filters/test_gaussian.py b/test/filters/test_gaussian.pyindex 8b2d03e12..22531abdb 100644--- a/test/filters/test_gaussian.py+++ b/test/filters/test_gaussian.py@@ -140,10 +140,10 @@ def test_get_gaussian_discrete_kernel1d_tensor(window_size, sigma, device, dtype@pytest.mark.parametrize("ksize_y", [3, 7])@pytest.mark.parametrize("sigma", [(1.5, 1.5), (2.1, 2.1)])def test_gaussian_blur2d_float(ksize_x, ksize_y, sigma, device, dtype):- input = torch.rand(1, 3, 16, 16, device=device, dtype=dtype)+ sample = torch.rand(1, 3, 16, 16, device=device, dtype=dtype)- actual = gaussian_blur2d(input, (ksize_x, ksize_y), sigma, "replicate", separable=False)- actual_sep = gaussian_blur2d(input, (ksize_x, ksize_y), sigma, "replicate", separable=True)+ actual = gaussian_blur2d(sample, (ksize_x, ksize_y), sigma, "replicate", separable=False)+ actual_sep = gaussian_blur2d(sample, (ksize_x, ksize_y), sigma, "replicate", separable=True)assert_close(actual, actual_sep)@@ -154,9 +154,9 @@ def test_gaussian_blur2d_float(ksize_x, ksize_y, sigma, device, dtype):def test_gaussian_blur2d_tensor(ksize_x, ksize_y, sigma, device, dtype):sigma = torch.tensor(sigma, device=device, dtype=dtype)bs = sigma.shape[0]- input = torch.rand(bs, 3, 16, 16, device=device, dtype=dtype)- actual = gaussian_blur2d(input, (ksize_x, ksize_y), sigma, "replicate", separable=False)- actual_sep = gaussian_blur2d(input, (ksize_x, ksize_y), sigma, "replicate", separable=True)+ sample = torch.rand(bs, 3, 16, 16, device=device, dtype=dtype)+ actual = gaussian_blur2d(sample, (ksize_x, ksize_y), sigma, "replicate", separable=False)+ actual_sep = gaussian_blur2d(sample, (ksize_x, ksize_y), sigma, "replicate", separable=True)assert_close(actual, actual_sep)@@ -186,8 +186,8 @@ class TestGaussianBlur2d(BaseTester):@pytest.mark.parametrize("kernel_size", [3, (5, 5), (5, 7)])def test_cardinality(self, shape, kernel_size, device, dtype):sigma = (1.5, 2.1)- input = torch.rand(shape, device=device, dtype=dtype)- actual = gaussian_blur2d(input, kernel_size, sigma, "replicate")+ sample = torch.rand(shape, device=device, dtype=dtype)+ actual = gaussian_blur2d(sample, kernel_size, sigma, "replicate")assert actual.shape == shapedef test_exception(self):@@ -203,11 +203,11 @@ class TestGaussianBlur2d(BaseTester):def test_noncontiguous(self, device, dtype):batch_size = 3- input = torch.rand(3, 5, 5, device=device, dtype=dtype).expand(batch_size, -1, -1, -1)+ sample = torch.rand(3, 5, 5, device=device, dtype=dtype).expand(batch_size, -1, -1, -1)kernel_size = (3, 3)sigma = (1.5, 2.1)- actual = gaussian_blur2d(input, kernel_size, sigma, "replicate")+ actual = gaussian_blur2d(sample, kernel_size, sigma, "replicate")assert actual.is_contiguous()def test_gradcheck(self, device):@@ -217,9 +217,9 @@ class TestGaussianBlur2d(BaseTester):sigma = (1.5, 2.1)# evaluate function gradient- input = torch.rand(batch_shape, device=device)- input = tensor_to_gradcheck_var(input) # to var- self.gradcheck(gaussian_blur2d, (input, kernel_size, sigma, "replicate"))+ sample = torch.rand(batch_shape, device=device)+ sample = tensor_to_gradcheck_var(sample) # to var+ self.gradcheck(gaussian_blur2d, (sample, kernel_size, sigma, "replicate"))@pytest.mark.parametrize("kernel_size", [3, (5, 5), (5, 7)])@pytest.mark.parametrize("sigma", [(1.5, 2.1), (0.5, 0.5)])diff --git a/test/filters/test_laplacian.py b/test/filters/test_laplacian.pyindex bab358203..47059ceec 100644--- a/test/filters/test_laplacian.py+++ b/test/filters/test_laplacian.py@@ -61,8 +61,8 @@ class TestLaplacian(BaseTester):@pytest.mark.parametrize("shape", [(1, 4, 8, 15), (2, 3, 11, 7)])@pytest.mark.parametrize("kernel_size", [5, (11, 7), 3])def test_cardinality(self, shape, kernel_size, device, dtype):- input = torch.rand(shape, device=device, dtype=dtype)- actual = laplacian(input, kernel_size)+ sample = torch.rand(shape, device=device, dtype=dtype)+ actual = laplacian(sample, kernel_size)assert actual.shape == shape@pytest.mark.skip(reason='Nothing to test.')@@ -71,10 +71,10 @@ class TestLaplacian(BaseTester):def test_noncontiguous(self, device, dtype):batch_size = 3- input = torch.rand(3, 5, 5, device=device, dtype=dtype).expand(batch_size, -1, -1, -1)+ sample = torch.rand(3, 5, 5, device=device, dtype=dtype).expand(batch_size, -1, -1, -1)kernel_size = 3- actual = laplacian(input, kernel_size)+ actual = laplacian(sample, kernel_size)assert actual.is_contiguous()def test_gradcheck(self, device):@@ -83,9 +83,9 @@ class TestLaplacian(BaseTester):kernel_size = 3# evaluate function gradient- input = torch.rand(batch_shape, device=device)- input = tensor_to_gradcheck_var(input)- self.gradcheck(laplacian, (input, kernel_size))+ sample = torch.rand(batch_shape, device=device)+ sample = tensor_to_gradcheck_var(sample)+ self.gradcheck(laplacian, (sample, kernel_size))def test_module(self, device, dtype):params = [3]diff --git a/test/filters/test_motion.py b/test/filters/test_motion.pyindex ccdf16474..883bab3a7 100644--- a/test/filters/test_motion.py+++ b/test/filters/test_motion.py@@ -37,9 +37,9 @@ class TestMotionBlur(BaseTester):angle = 200.0direction = 0.3- input = torch.rand(shape, device=device, dtype=dtype)+ sample = torch.rand(shape, device=device, dtype=dtype)motion = MotionBlur(ksize, angle, direction)- assert motion(input).shape == shape+ assert motion(sample).shape == shape@pytest.mark.skip(reason='nothing to test')def test_exception(self):@@ -80,9 +80,9 @@ class TestMotionBlur(BaseTester):angle = 34.0direction = -0.2- input = torch.rand(batch_shape, device=device)- input = tensor_to_gradcheck_var(input)- self.gradcheck(motion_blur, (input, ksize, angle, direction, "replicate"), nondet_tol=1e-8)+ sample = torch.rand(batch_shape, device=device)+ sample = tensor_to_gradcheck_var(sample)+ self.gradcheck(motion_blur, (sample, ksize, angle, direction, "replicate"), nondet_tol=1e-8)def test_module(self, device, dtype):params = [3, 20.0, 0.5]@@ -128,9 +128,9 @@ class TestMotionBlur3D(BaseTester):angle = (200.0, 15.0, 120.0)direction = 0.3- input = torch.rand(shape, device=device, dtype=dtype)+ sample = torch.rand(shape, device=device, dtype=dtype)motion = MotionBlur3D(ksize, angle, direction)- assert motion(input).shape == shape+ assert motion(sample).shape == shape@pytest.mark.skip(reason='nothing to test')def test_exception(self):@@ -171,9 +171,9 @@ class TestMotionBlur3D(BaseTester):angle = (0.0, 360.0, 150.0)direction = -0.2- input = torch.rand(batch_shape, device=device)- input = tensor_to_gradcheck_var(input)- self.gradcheck(motion_blur3d, (input, ksize, angle, direction, "replicate"), nondet_tol=1e-8)+ sample = torch.rand(batch_shape, device=device)+ sample = tensor_to_gradcheck_var(sample)+ self.gradcheck(motion_blur3d, (sample, ksize, angle, direction, "replicate"), nondet_tol=1e-8)def test_module(self, device, dtype):params = [3, (0.0, 360.0, 150.0), 0.5]diff --git a/test/filters/test_unsharp_mask.py b/test/filters/test_unsharp_mask.pyindex 37ba0a09a..85a86d356 100644--- a/test/filters/test_unsharp_mask.py+++ b/test/filters/test_unsharp_mask.py@@ -34,11 +34,11 @@ class Testunsharp(BaseTester):def test_noncontiguous(self, device, dtype):batch_size = 3- input = torch.rand(3, 5, 5, device=device, dtype=dtype).expand(batch_size, -1, -1, -1)+ inpt = torch.rand(3, 5, 5, device=device, dtype=dtype).expand(batch_size, -1, -1, -1)kernel_size = (3, 3)sigma = (1.5, 2.1)- actual = unsharp_mask(input, kernel_size, sigma, "replicate")+ actual = unsharp_mask(inpt, kernel_size, sigma, "replicate")assert actual.is_contiguous()def test_gradcheck(self, device):diff --git a/test/geometry/subpix/test_spatial_softargmax.py b/test/geometry/subpix/test_spatial_softargmax.pyindex 5cf69b54e..a44f85237 100644--- a/test/geometry/subpix/test_spatial_softargmax.py+++ b/test/geometry/subpix/test_spatial_softargmax.py@@ -63,55 +63,55 @@ class TestCenterKernel3d:class TestSpatialSoftArgmax2d:def test_smoke(self, device, dtype):- input = torch.zeros(1, 1, 2, 3, device=device, dtype=dtype)+ sample = torch.zeros(1, 1, 2, 3, device=device, dtype=dtype)m = kornia.geometry.subpix.SpatialSoftArgmax2d()- assert m(input).shape == (1, 1, 2)+ assert m(sample).shape == (1, 1, 2)def test_smoke_batch(self, device, dtype):- input = torch.zeros(2, 1, 2, 3, device=device, dtype=dtype)+ sample = torch.zeros(2, 1, 2, 3, device=device, dtype=dtype)m = kornia.geometry.subpix.SpatialSoftArgmax2d()- assert m(input).shape == (2, 1, 2)+ assert m(sample).shape == (2, 1, 2)def test_top_left_normalized(self, device, dtype):- input = torch.zeros(1, 1, 2, 3, device=device, dtype=dtype)- input[..., 0, 0] = 1e16+ sample = torch.zeros(1, 1, 2, 3, device=device, dtype=dtype)+ sample[..., 0, 0] = 1e16- coord = kornia.geometry.subpix.spatial_soft_argmax2d(input, normalized_coordinates=True)+ coord = kornia.geometry.subpix.spatial_soft_argmax2d(sample, normalized_coordinates=True)assert_close(coord[..., 0].item(), -1.0, atol=1e-4, rtol=1e-4)assert_close(coord[..., 1].item(), -1.0, atol=1e-4, rtol=1e-4)def test_top_left(self, device, dtype):- input = torch.zeros(1, 1, 2, 3, device=device, dtype=dtype)- input[..., 0, 0] = 1e16+ sample = torch.zeros(1, 1, 2, 3, device=device, dtype=dtype)+ sample[..., 0, 0] = 1e16- coord = kornia.geometry.subpix.spatial_soft_argmax2d(input, normalized_coordinates=False)+ coord = kornia.geometry.subpix.spatial_soft_argmax2d(sample, normalized_coordinates=False)assert_close(coord[..., 0].item(), 0.0, atol=1e-4, rtol=1e-4)assert_close(coord[..., 1].item(), 0.0, atol=1e-4, rtol=1e-4)def test_bottom_right_normalized(self, device, dtype):- input = torch.zeros(1, 1, 2, 3, device=device, dtype=dtype)- input[..., -1, -1] = 1e16+ sample = torch.zeros(1, 1, 2, 3, device=device, dtype=dtype)+ sample[..., -1, -1] = 1e16- coord = kornia.geometry.subpix.spatial_soft_argmax2d(input, normalized_coordinates=True)+ coord = kornia.geometry.subpix.spatial_soft_argmax2d(sample, normalized_coordinates=True)assert_close(coord[..., 0].item(), 1.0, atol=1e-4, rtol=1e-4)assert_close(coord[..., 1].item(), 1.0, atol=1e-4, rtol=1e-4)def test_bottom_right(self, device, dtype):- input = torch.zeros(1, 1, 2, 3, device=device, dtype=dtype)- input[..., -1, -1] = 1e16+ sample = torch.zeros(1, 1, 2, 3, device=device, dtype=dtype)+ sample[..., -1, -1] = 1e16- coord = kornia.geometry.subpix.spatial_soft_argmax2d(input, normalized_coordinates=False)+ coord = kornia.geometry.subpix.spatial_soft_argmax2d(sample, normalized_coordinates=False)assert_close(coord[..., 0].item(), 2.0, atol=1e-4, rtol=1e-4)assert_close(coord[..., 1].item(), 1.0, atol=1e-4, rtol=1e-4)def test_batch2_n2(self, device, dtype):- input = torch.zeros(2, 2, 2, 3, device=device, dtype=dtype)- input[0, 0, 0, 0] = 1e16 # top-left- input[0, 1, 0, -1] = 1e16 # top-right- input[1, 0, -1, 0] = 1e16 # bottom-left- input[1, 1, -1, -1] = 1e16 # bottom-right+ sample = torch.zeros(2, 2, 2, 3, device=device, dtype=dtype)+ sample[0, 0, 0, 0] = 1e16 # top-left+ sample[0, 1, 0, -1] = 1e16 # top-right+ sample[1, 0, -1, 0] = 1e16 # bottom-left+ sample[1, 1, -1, -1] = 1e16 # bottom-right- coord = kornia.geometry.subpix.spatial_soft_argmax2d(input)+ coord = kornia.geometry.subpix.spatial_soft_argmax2d(sample)assert_close(coord[0, 0, 0].item(), -1.0, atol=1e-4, rtol=1e-4) # top-leftassert_close(coord[0, 0, 1].item(), -1.0, atol=1e-4, rtol=1e-4)assert_close(coord[0, 1, 0].item(), 1.0, atol=1e-4, rtol=1e-4) # top-right@@ -122,16 +122,16 @@ class TestSpatialSoftArgmax2d:assert_close(coord[1, 1, 1].item(), 1.0, atol=1e-4, rtol=1e-4)def test_gradcheck(self, device, dtype):- input = torch.rand(2, 3, 3, 2, device=device, dtype=dtype)- input = utils.tensor_to_gradcheck_var(input) # to var- assert gradcheck(kornia.geometry.subpix.spatial_soft_argmax2d, (input), raise_exception=True, fast_mode=True)+ sample = torch.rand(2, 3, 3, 2, device=device, dtype=dtype)+ sample = utils.tensor_to_gradcheck_var(sample) # to var+ assert gradcheck(kornia.geometry.subpix.spatial_soft_argmax2d, (sample), raise_exception=True, fast_mode=True)def test_end_to_end(self, device, dtype):- input = torch.full((1, 2, 7, 7), 1.0, requires_grad=True, device=device, dtype=dtype)+ sample = torch.full((1, 2, 7, 7), 1.0, requires_grad=True, device=device, dtype=dtype)target = torch.as_tensor([[[0.0, 0.0], [1.0, 1.0]]], device=device, dtype=dtype)std = torch.tensor([1.0, 1.0], device=device, dtype=dtype)- hm = kornia.geometry.subpix.spatial_softmax2d(input)+ hm = kornia.geometry.subpix.spatial_softmax2d(sample)assert_close(hm.sum(-1).sum(-1), torch.tensor([[1.0, 1.0]], device=device, dtype=dtype), atol=1e-4, rtol=1e-4)pred = kornia.geometry.subpix.spatial_expectation2d(hm)@@ -143,7 +143,7 @@ class TestSpatialSoftArgmax2d:expected_loss1 = torch.as_tensor([[0.0, 1.0]], device=device, dtype=dtype)assert_close(loss1, expected_loss1, atol=1e-4, rtol=1e-4)- target_hm = kornia.geometry.subpix.render_gaussian2d(target, std, input.shape[-2:]).contiguous()+ target_hm = kornia.geometry.subpix.render_gaussian2d(target, std, sample.shape[-2:]).contiguous()loss2 = kornia.losses.js_div_loss_2d(hm, target_hm, reduction='none')expected_loss2 = torch.as_tensor([[0.0087, 0.0818]], device=device, dtype=dtype)@@ -162,38 +162,38 @@ class TestSpatialSoftArgmax2d:class TestConvSoftArgmax2d:def test_smoke(self, device, dtype):- input = torch.zeros(1, 1, 3, 3, device=device, dtype=dtype)+ sample = torch.zeros(1, 1, 3, 3, device=device, dtype=dtype)m = kornia.geometry.subpix.ConvSoftArgmax2d((3, 3))- assert m(input).shape == (1, 1, 2, 3, 3)+ assert m(sample).shape == (1, 1, 2, 3, 3)def test_smoke_batch(self, device, dtype):- input = torch.zeros(2, 5, 3, 3, device=device, dtype=dtype)+ sample = torch.zeros(2, 5, 3, 3, device=device, dtype=dtype)m = kornia.geometry.subpix.ConvSoftArgmax2d()- assert m(input).shape == (2, 5, 2, 3, 3)+ assert m(sample).shape == (2, 5, 2, 3, 3)def test_smoke_with_val(self, device, dtype):- input = torch.zeros(1, 1, 3, 3, device=device, dtype=dtype)+ sample = torch.zeros(1, 1, 3, 3, device=device, dtype=dtype)m = kornia.geometry.subpix.ConvSoftArgmax2d((3, 3), output_value=True)- coords, val = m(input)+ coords, val = m(sample)assert coords.shape == (1, 1, 2, 3, 3)assert val.shape == (1, 1, 3, 3)def test_smoke_batch_with_val(self, device, dtype):- input = torch.zeros(2, 5, 3, 3, device=device, dtype=dtype)+ sample = torch.zeros(2, 5, 3, 3, device=device, dtype=dtype)m = kornia.geometry.subpix.ConvSoftArgmax2d((3, 3), output_value=True)- coords, val = m(input)+ coords, val = m(sample)assert coords.shape == (2, 5, 2, 3, 3)assert val.shape == (2, 5, 3, 3)def test_gradcheck(self, device, dtype):- input = torch.rand(2, 3, 5, 5, device=device, dtype=dtype)- input = utils.tensor_to_gradcheck_var(input) # to var+ sample = torch.rand(2, 3, 5, 5, device=device, dtype=dtype)+ sample = utils.tensor_to_gradcheck_var(sample) # to varassert gradcheck(- kornia.geometry.subpix.conv_soft_argmax2d, (input), nondet_tol=1e-8, raise_exception=True, fast_mode=True+ kornia.geometry.subpix.conv_soft_argmax2d, (sample), nondet_tol=1e-8, raise_exception=True, fast_mode=True)def test_cold_diag(self, device, dtype):- input = torch.tensor(+ sample = torch.tensor([[[@@ -215,12 +215,12 @@ class TestConvSoftArgmax2d:expected_coord = torch.tensor([[[[[1.0, 3.0], [1.0, 3.0]], [[1.0, 1.0], [3.0, 3.0]]]]], device=device, dtype=dtype)- coords, val = softargmax(input)+ coords, val = softargmax(sample)assert_close(val, expected_val, atol=1e-4, rtol=1e-4)assert_close(coords, expected_coord, atol=1e-4, rtol=1e-4)def test_hot_diag(self, device, dtype):- input = torch.tensor(+ sample = torch.tensor([[[@@ -242,12 +242,12 @@ class TestConvSoftArgmax2d:expected_coord = torch.tensor([[[[[1.0, 3.0], [1.0, 3.0]], [[1.0, 1.0], [3.0, 3.0]]]]], device=device, dtype=dtype)- coords, val = softargmax(input)+ coords, val = softargmax(sample)assert_close(val, expected_val, atol=1e-4, rtol=1e-4)assert_close(coords, expected_coord, atol=1e-4, rtol=1e-4)def test_cold_diag_norm(self, device, dtype):- input = torch.tensor(+ sample = torch.tensor([[[@@ -269,12 +269,12 @@ class TestConvSoftArgmax2d:expected_coord = torch.tensor([[[[[-0.5, 0.5], [-0.5, 0.5]], [[-0.5, -0.5], [0.5, 0.5]]]]], device=device, dtype=dtype)- coords, val = softargmax(input)+ coords, val = softargmax(sample)assert_close(val, expected_val, atol=1e-4, rtol=1e-4)assert_close(coords, expected_coord, atol=1e-4, rtol=1e-4)def test_hot_diag_norm(self, device, dtype):- input = torch.tensor(+ sample = torch.tensor([[[@@ -296,33 +296,33 @@ class TestConvSoftArgmax2d:expected_coord = torch.tensor([[[[[-0.5, 0.5], [-0.5, 0.5]], [[-0.5, -0.5], [0.5, 0.5]]]]], device=device, dtype=dtype)- coords, val = softargmax(input)+ coords, val = softargmax(sample)assert_close(val, expected_val, atol=1e-4, rtol=1e-4)assert_close(coords, expected_coord, atol=1e-4, rtol=1e-4)class TestConvSoftArgmax3d:def test_smoke(self, device, dtype):- input = torch.zeros(1, 1, 3, 3, 3, device=device, dtype=dtype)+ sample = torch.zeros(1, 1, 3, 3, 3, device=device, dtype=dtype)m = kornia.geometry.subpix.ConvSoftArgmax3d((3, 3, 3), output_value=False)- assert m(input).shape == (1, 1, 3, 3, 3, 3)+ assert m(sample).shape == (1, 1, 3, 3, 3, 3)def test_smoke_with_val(self, device, dtype):- input = torch.zeros(1, 1, 3, 3, 3, device=device, dtype=dtype)+ sample = torch.zeros(1, 1, 3, 3, 3, device=device, dtype=dtype)m = kornia.geometry.subpix.ConvSoftArgmax3d((3, 3, 3), output_value=True)- coords, val = m(input)+ coords, val = m(sample)assert coords.shape == (1, 1, 3, 3, 3, 3)assert val.shape == (1, 1, 3, 3, 3)def test_gradcheck(self, device, dtype):- input = torch.rand(1, 2, 3, 5, 5, device=device, dtype=dtype)- input = utils.tensor_to_gradcheck_var(input) # to var+ sample = torch.rand(1, 2, 3, 5, 5, device=device, dtype=dtype)+ sample = utils.tensor_to_gradcheck_var(sample) # to varassert gradcheck(- kornia.geometry.subpix.conv_soft_argmax3d, (input), nondet_tol=1e-8, raise_exception=True, fast_mode=True+ kornia.geometry.subpix.conv_soft_argmax3d, (sample), nondet_tol=1e-8, raise_exception=True, fast_mode=True)def test_cold_diag(self, device, dtype):- input = torch.tensor(+ sample = torch.tensor([[[@@ -348,12 +348,12 @@ class TestConvSoftArgmax3d:device=device,dtype=dtype,)- coords, val = softargmax(input)+ coords, val = softargmax(sample)assert_close(val, expected_val, atol=1e-4, rtol=1e-4)assert_close(coords, expected_coord, atol=1e-4, rtol=1e-4)def test_hot_diag(self, device, dtype):- input = torch.tensor(+ sample = torch.tensor([[[@@ -379,12 +379,12 @@ class TestConvSoftArgmax3d:device=device,dtype=dtype,)- coords, val = softargmax(input)+ coords, val = softargmax(sample)assert_close(val, expected_val, atol=1e-4, rtol=1e-4)assert_close(coords, expected_coord, atol=1e-4, rtol=1e-4)def test_cold_diag_norm(self, device, dtype):- input = torch.tensor(+ sample = torch.tensor([[[@@ -410,12 +410,12 @@ class TestConvSoftArgmax3d:device=device,dtype=dtype,)- coords, val = softargmax(input)+ coords, val = softargmax(sample)assert_close(val, expected_val, atol=1e-4, rtol=1e-4)assert_close(coords, expected_coord, atol=1e-4, rtol=1e-4)def test_hot_diag_norm(self, device, dtype):- input = torch.tensor(+ sample = torch.tensor([[[@@ -441,26 +441,26 @@ class TestConvSoftArgmax3d:device=device,dtype=dtype,)- coords, val = softargmax(input)+ coords, val = softargmax(sample)assert_close(val, expected_val, atol=1e-4, rtol=1e-4)assert_close(coords, expected_coord, atol=1e-4, rtol=1e-4)class TestConvQuadInterp3d:def test_smoke(self, device, dtype):- input = torch.randn(2, 3, 3, 4, 4, device=device, dtype=dtype)+ sample = torch.randn(2, 3, 3, 4, 4, device=device, dtype=dtype)nms = kornia.geometry.ConvQuadInterp3d(1)- coord, val = nms(input)+ coord, val = nms(sample)assert coord.shape == (2, 3, 3, 3, 4, 4)assert val.shape == (2, 3, 3, 4, 4)def test_gradcheck(self, device, dtype):- input = torch.rand(1, 1, 3, 5, 5, device=device, dtype=dtype)- input[0, 0, 1, 2, 2] += 20.0- input = utils.tensor_to_gradcheck_var(input) # to var+ sample = torch.rand(1, 1, 3, 5, 5, device=device, dtype=dtype)+ sample[0, 0, 1, 2, 2] += 20.0+ sample = utils.tensor_to_gradcheck_var(sample) # to varassert gradcheck(kornia.geometry.ConvQuadInterp3d(strict_maxima_bonus=0),- (input),+ (sample),raise_exception=True,atol=1e-3,rtol=1e-3,@@ -468,7 +468,7 @@ class TestConvQuadInterp3d:)def test_diag(self, device, dtype):- input = torch.tensor(+ sample = torch.tensor([[[@@ -497,7 +497,7 @@ class TestConvQuadInterp3d:device=device,dtype=dtype,)- input = kornia.filters.gaussian_blur2d(input, (5, 5), (0.5, 0.5)).unsqueeze(0)+ sample = kornia.filters.gaussian_blur2d(sample, (5, 5), (0.5, 0.5)).unsqueeze(0)softargmax = kornia.geometry.ConvQuadInterp3d(10)expected_val = torch.tensor([@@ -609,6 +609,6 @@ class TestConvQuadInterp3d:device=device,dtype=dtype,)- coords, val = softargmax(input)+ coords, val = softargmax(sample)assert_close(val, expected_val, atol=1e-4, rtol=1e-4)assert_close(coords, expected_coord, atol=1e-4, rtol=1e-4)diff --git a/test/geometry/transform/test_imgwarp.py b/test/geometry/transform/test_imgwarp.pyindex 5ca1e95d2..0acd1a65b 100644--- a/test/geometry/transform/test_imgwarp.py+++ b/test/geometry/transform/test_imgwarp.py@@ -455,12 +455,12 @@ class TestWarpPerspective:class TestRemap:def test_smoke(self, device, dtype):height, width = 3, 4- input = torch.ones(1, 1, height, width, device=device, dtype=dtype)+ input_org = torch.ones(1, 1, height, width, device=device, dtype=dtype)grid = kornia.utils.create_meshgrid(height, width, normalized_coordinates=False, device=device, dtype=dtype)input_warped = kornia.geometry.remap(- input, grid[..., 0], grid[..., 1], normalized_coordinates=False, align_corners=True+ input_org, grid[..., 0], grid[..., 1], normalized_coordinates=False, align_corners=True)- assert_close(input, input_warped, rtol=1e-4, atol=1e-4)+ assert_close(input_org, input_warped, rtol=1e-4, atol=1e-4)def test_different_size(self, device, dtype):height, width = 3, 4diff --git a/test/geometry/transform/test_imgwarp3d.py b/test/geometry/transform/test_imgwarp3d.pyindex 5ddd52e84..77563668f 100644--- a/test/geometry/transform/test_imgwarp3d.py+++ b/test/geometry/transform/test_imgwarp3d.py@@ -11,9 +11,9 @@ from kornia.utils.helpers import _torch_inverse_castclass TestWarpAffine3d:def test_smoke(self, device, dtype):- input = torch.rand(1, 3, 3, 4, 5, device=device, dtype=dtype)+ sample = torch.rand(1, 3, 3, 4, 5, device=device, dtype=dtype)P = torch.rand(1, 3, 4, device=device, dtype=dtype)- output = proj.warp_affine3d(input, P, (3, 4, 5))+ output = proj.warp_affine3d(sample, P, (3, 4, 5))assert output.shape == (1, 3, 3, 4, 5)@pytest.mark.parametrize("batch_size", [1, 3])@@ -21,28 +21,28 @@ class TestWarpAffine3d:@pytest.mark.parametrize("out_shape", [(3, 3, 3), (4, 5, 6)])def test_batch(self, batch_size, num_channels, out_shape, device, dtype):B, C = batch_size, num_channels- input = torch.rand(B, C, 3, 4, 5, device=device, dtype=dtype)+ sample = torch.rand(B, C, 3, 4, 5, device=device, dtype=dtype)P = torch.rand(B, 3, 4, device=device, dtype=dtype)- output = proj.warp_affine3d(input, P, out_shape)+ output = proj.warp_affine3d(sample, P, out_shape)assert list(output.shape) == [B, C] + list(out_shape)def test_gradcheck(self, device):# generate input data- input = torch.rand(1, 3, 3, 4, 5, device=device, dtype=torch.float64, requires_grad=True)+ sample = torch.rand(1, 3, 3, 4, 5, device=device, dtype=torch.float64, requires_grad=True)P = torch.rand(1, 3, 4, device=device, dtype=torch.float64)- assert gradcheck(proj.warp_affine3d, (input, P, (3, 3, 3)), raise_exception=True, fast_mode=True)+ assert gradcheck(proj.warp_affine3d, (sample, P, (3, 3, 3)), raise_exception=True, fast_mode=True)def test_forth_back(self, device, dtype):out_shape = (3, 4, 5)- input = torch.rand(2, 5, 3, 4, 5, device=device, dtype=dtype)+ sample = torch.rand(2, 5, 3, 4, 5, device=device, dtype=dtype)P = torch.rand(2, 3, 4, device=device, dtype=dtype)P = kornia.geometry.convert_affinematrix_to_homography3d(P)P_hat = (_torch_inverse_cast(P) @ P)[:, :3]- output = proj.warp_affine3d(input, P_hat, out_shape, flags='nearest')- assert_close(output, input, rtol=1e-4, atol=1e-4)+ output = proj.warp_affine3d(sample, P_hat, out_shape, flags='nearest')+ assert_close(output, sample, rtol=1e-4, atol=1e-4)def test_rotate_x(self, device, dtype):- input = torch.tensor(+ sample = torch.tensor([[[@@ -70,18 +70,18 @@ class TestWarpAffine3d:dtype=dtype,)- _, _, D, H, W = input.shape+ _, _, D, H, W = sample.shapecenter = torch.tensor([[(W - 1) / 2, (H - 1) / 2, (D - 1) / 2]], device=device, dtype=dtype)angles = torch.tensor([[90.0, 0.0, 0.0]], device=device, dtype=dtype)scales: torch.Tensor = torch.ones_like(angles, device=device, dtype=dtype)P = proj.get_projective_transform(center, angles, scales)- output = proj.warp_affine3d(input, P, (3, 3, 3))+ output = proj.warp_affine3d(sample, P, (3, 3, 3))assert_close(output, expected, rtol=1e-4, atol=1e-4)def test_rotate_y(self, device, dtype):- input = torch.tensor(+ sample = torch.tensor([[[@@ -109,18 +109,18 @@ class TestWarpAffine3d:dtype=dtype,)- _, _, D, H, W = input.shape+ _, _, D, H, W = sample.shapecenter = torch.tensor([[(W - 1) / 2, (H - 1) / 2, (D - 1) / 2]], device=device, dtype=dtype)angles = torch.tensor([[0.0, 90.0, 0.0]], device=device, dtype=dtype)scales: torch.Tensor = torch.ones_like(angles, device=device, dtype=dtype)P = proj.get_projective_transform(center, angles, scales)- output = proj.warp_affine3d(input, P, (3, 3, 3))+ output = proj.warp_affine3d(sample, P, (3, 3, 3))assert_close(output, expected, rtol=1e-4, atol=1e-4)def test_rotate_z(self, device, dtype):- input = torch.tensor(+ sample = torch.tensor([[[@@ -148,19 +148,19 @@ class TestWarpAffine3d:dtype=dtype,)- _, _, D, H, W = input.shape+ _, _, D, H, W = sample.shapecenter = torch.tensor([[(W - 1) / 2, (H - 1) / 2, (D - 1) / 2]], device=device, dtype=dtype)angles = torch.tensor([[0.0, 0.0, 90.0]], device=device, dtype=dtype)scales: torch.Tensor = torch.ones_like(angles, device=device, dtype=dtype)P = proj.get_projective_transform(center, angles, scales)- output = proj.warp_affine3d(input, P, (3, 3, 3))+ output = proj.warp_affine3d(sample, P, (3, 3, 3))assert_close(output, expected, rtol=1e-4, atol=1e-4)def test_rotate_y_large(self, device, dtype):"""Rotates 90deg anti-clockwise."""- input = torch.tensor(+ sample = torch.tensor([[[@@ -198,14 +198,14 @@ class TestWarpAffine3d:dtype=dtype,)- _, _, D, H, W = input.shape+ _, _, D, H, W = sample.shapecenter = torch.tensor([[(W - 1) / 2, (H - 1) / 2, (D - 1) / 2]], device=device, dtype=dtype)angles = torch.tensor([[0.0, 90.0, 0.0]], device=device, dtype=dtype)scales: torch.Tensor = torch.ones_like(angles, device=device, dtype=dtype)P = proj.get_projective_transform(center, angles, scales)- output = proj.warp_affine3d(input, P, (3, 3, 3))+ output = proj.warp_affine3d(sample, P, (3, 3, 3))assert_close(output, expected, rtol=1e-4, atol=1e-4)diff --git a/test/geometry/transform/test_pyramid.py b/test/geometry/transform/test_pyramid.pyindex 83712b256..c88089bbb 100644--- a/test/geometry/transform/test_pyramid.py+++ b/test/geometry/transform/test_pyramid.py@@ -118,8 +118,8 @@ class TestScalePyramid:class TestBuildPyramid:def test_smoke(self, device, dtype):- input = torch.ones(1, 2, 4, 5, device=device, dtype=dtype)- pyramid = kornia.geometry.transform.build_pyramid(input, max_level=1)+ sample = torch.ones(1, 2, 4, 5, device=device, dtype=dtype)+ pyramid = kornia.geometry.transform.build_pyramid(sample, max_level=1)assert len(pyramid) == 1assert pyramid[0].shape == (1, 2, 4, 5)@@ -128,8 +128,8 @@ class TestBuildPyramid:@pytest.mark.parametrize("max_level", (2, 3, 4))def test_num_levels(self, batch_size, channels, max_level, device, dtype):height, width = 16, 20- input = torch.rand(batch_size, channels, height, width, device=device, dtype=dtype)- pyramid = kornia.geometry.transform.build_pyramid(input, max_level)+ sample = torch.rand(batch_size, channels, height, width, device=device, dtype=dtype)+ pyramid = kornia.geometry.transform.build_pyramid(sample, max_level)assert len(pyramid) == max_levelfor i in range(1, max_level):img = pyramid[i]@@ -149,8 +149,8 @@ class TestBuildPyramid:class TestBuildLaplacianPyramid:def test_smoke(self, device, dtype):- input = torch.ones(1, 2, 4, 5, device=device, dtype=dtype)- pyramid = kornia.geometry.transform.build_laplacian_pyramid(input, max_level=1)+ sample = torch.ones(1, 2, 4, 5, device=device, dtype=dtype)+ pyramid = kornia.geometry.transform.build_laplacian_pyramid(sample, max_level=1)assert len(pyramid) == 1assert pyramid[0].shape == (1, 2, 4, 5)@@ -159,8 +159,8 @@ class TestBuildLaplacianPyramid:@pytest.mark.parametrize("max_level", (2, 3, 4))def test_num_levels(self, batch_size, channels, max_level, device, dtype):height, width = 16, 32- input = torch.rand(batch_size, channels, height, width, device=device, dtype=dtype)- pyramid = kornia.geometry.transform.build_laplacian_pyramid(input, max_level)+ sample = torch.rand(batch_size, channels, height, width, device=device, dtype=dtype)+ pyramid = kornia.geometry.transform.build_laplacian_pyramid(sample, max_level)assert len(pyramid) == max_levelfor i in range(1, max_level):img = pyramid[i]diff --git a/test/grad_estimator/test_ste.py b/test/grad_estimator/test_ste.pyindex 897657310..8437380d6 100644--- a/test/grad_estimator/test_ste.py+++ b/test/grad_estimator/test_ste.py@@ -12,26 +12,26 @@ class TestSTE:StraightThroughEstimator(K.Normalize(0.5, 0.5))def test_function(self, device, dtype):- input = torch.randn(4, requires_grad=True, device=device, dtype=dtype)- output = torch.sign(input)+ inpt = torch.randn(4, requires_grad=True, device=device, dtype=dtype)+ output = torch.sign(inpt)loss = output.mean()loss.backward()- assert_close(input.grad, torch.tensor([0.0, 0.0, 0.0, 0.0], device=device, dtype=dtype))+ assert_close(inpt.grad, torch.tensor([0.0, 0.0, 0.0, 0.0], device=device, dtype=dtype))- out_est = STEFunction.apply(input, output, F.hardtanh)+ out_est = STEFunction.apply(inpt, output, F.hardtanh)loss = out_est.mean()loss.backward()- assert_close(input.grad, torch.tensor([0.2500, 0.2500, 0.2500, 0.2500], device=device, dtype=dtype))+ assert_close(inpt.grad, torch.tensor([0.2500, 0.2500, 0.2500, 0.2500], device=device, dtype=dtype))- out_est = STEFunction.apply(input, output, None)+ out_est = STEFunction.apply(inpt, output, None)loss = out_est.mean()loss.backward()- assert_close(input.grad, torch.tensor([0.5000, 0.5000, 0.5000, 0.5000], device=device, dtype=dtype))+ assert_close(inpt.grad, torch.tensor([0.5000, 0.5000, 0.5000, 0.5000], device=device, dtype=dtype))def test_module(self, device, dtype):- input = torch.randn(1, 1, 4, 4, requires_grad=True, device=device, dtype=dtype)+ inpt = torch.randn(1, 1, 4, 4, requires_grad=True, device=device, dtype=dtype)estimator = StraightThroughEstimator(K.RandomPosterize(3, p=1.0), grad_fn=F.hardtanh)- out = estimator(input)+ out = estimator(inpt)loss = out.mean()loss.backward()o = torch.tensor(@@ -48,7 +48,7 @@ class TestSTE:device=device,dtype=dtype,)- assert_close(input.grad, o)+ assert_close(inpt.grad, o)@pytest.mark.skip("Function.apply is not supported in Torchscript rightnow.")def test_jit(self, device, dtype):diff --git a/test/morphology/test_bottom_hat.py b/test/morphology/test_bottom_hat.pyindex 7950963cd..169716759 100644--- a/test/morphology/test_bottom_hat.py+++ b/test/morphology/test_bottom_hat.py@@ -46,14 +46,14 @@ class TestBottomHat:)def test_exception(self, device, dtype):- input = torch.ones(1, 1, 3, 4, device=device, dtype=dtype)+ sample = torch.ones(1, 1, 3, 4, device=device, dtype=dtype)kernel = torch.ones(3, 3, device=device, dtype=dtype)with pytest.raises(TypeError):assert bottom_hat([0.0], kernel)with pytest.raises(TypeError):- assert bottom_hat(input, [0.0])+ assert bottom_hat(sample, [0.0])with pytest.raises(ValueError):test = torch.ones(2, 3, 4, device=device, dtype=dtype)@@ -61,23 +61,23 @@ class TestBottomHat:with pytest.raises(ValueError):test = torch.ones(2, 3, 4, device=device, dtype=dtype)- assert bottom_hat(input, test)+ assert bottom_hat(sample, test)@pytest.mark.graddef test_gradcheck(self, device, dtype):- input = torch.rand(2, 3, 4, 4, requires_grad=True, device=device, dtype=torch.float64)+ sample = torch.rand(2, 3, 4, 4, requires_grad=True, device=device, dtype=torch.float64)kernel = torch.rand(3, 3, requires_grad=True, device=device, dtype=torch.float64)- assert gradcheck(bottom_hat, (input, kernel), raise_exception=True, fast_mode=True)+ assert gradcheck(bottom_hat, (sample, kernel), raise_exception=True, fast_mode=True)@pytest.mark.jitdef test_jit(self, device, dtype):op = bottom_hatop_script = torch.jit.script(op)- input = torch.rand(1, 2, 7, 7, device=device, dtype=dtype)+ sample = torch.rand(1, 2, 7, 7, device=device, dtype=dtype)kernel = torch.ones(3, 3, device=device, dtype=dtype)- actual = op_script(input, kernel)- expected = op(input, kernel)+ actual = op_script(sample, kernel)+ expected = op(sample, kernel)assert_close(actual, expected)diff --git a/test/morphology/test_top_hat.py b/test/morphology/test_top_hat.pyindex 5e4ccf22c..5b796cc4b 100644--- a/test/morphology/test_top_hat.py+++ b/test/morphology/test_top_hat.py@@ -46,14 +46,14 @@ class TestTopHat:)def test_exception(self, device, dtype):- input = torch.ones(1, 1, 3, 4, device=device, dtype=dtype)+ sample = torch.ones(1, 1, 3, 4, device=device, dtype=dtype)kernel = torch.ones(3, 3, device=device, dtype=dtype)with pytest.raises(TypeError):assert top_hat([0.0], kernel)with pytest.raises(TypeError):- assert top_hat(input, [0.0])+ assert top_hat(sample, [0.0])with pytest.raises(ValueError):test = torch.ones(2, 3, 4, device=device, dtype=dtype)@@ -61,23 +61,23 @@ class TestTopHat:with pytest.raises(ValueError):test = torch.ones(2, 3, 4, device=device, dtype=dtype)- assert top_hat(input, test)+ assert top_hat(sample, test)@pytest.mark.graddef test_gradcheck(self, device, dtype):- input = torch.rand(2, 3, 4, 4, requires_grad=True, device=device, dtype=torch.float64)+ sample = torch.rand(2, 3, 4, 4, requires_grad=True, device=device, dtype=torch.float64)kernel = torch.rand(3, 3, requires_grad=True, device=device, dtype=torch.float64)- assert gradcheck(top_hat, (input, kernel), raise_exception=True, fast_mode=True)+ assert gradcheck(top_hat, (sample, kernel), raise_exception=True, fast_mode=True)@pytest.mark.jitdef test_jit(self, device, dtype):op = top_hatop_script = torch.jit.script(op)- input = torch.rand(1, 2, 7, 7, device=device, dtype=dtype)+ sample = torch.rand(1, 2, 7, 7, device=device, dtype=dtype)kernel = torch.ones(3, 3, device=device, dtype=dtype)- actual = op_script(input, kernel)- expected = op(input, kernel)+ actual = op_script(sample, kernel)+ expected = op(sample, kernel)assert_close(actual, expected)