π Geometric Computer Vision Library for Spatial AI
Python artificial-intelligencecomputer-visiondeep-learninghacktoberfestimage-processingmachine-learningneural-networkpythonpytorchroboticsspatial-ai
[pre-commit.ci] pre-commit suggestions (#2099)
pre-commit-ci[bot]bb811176e86c
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yamlindex 94db87fe1..ac7de874d 100644--- a/.pre-commit-config.yaml+++ b/.pre-commit-config.yaml@@ -35,7 +35,7 @@ repos:- "*.bib,*.ipynb"- repo: https://github.com/PyCQA/isort- rev: 5.11.1+ rev: v5.11.3hooks:- id: isort@@ -66,7 +66,7 @@ repos:- "B101,B311"- repo: https://github.com/PyCQA/docformatter- rev: v1.5.0+ rev: v1.5.1hooks:- id: docformatterargs: [--in-place, --wrap-summaries=115, --wrap-descriptions=120]diff --git a/kornia/augmentation/container/utils.py b/kornia/augmentation/container/utils.pyindex d8b8d189f..8ef9f8a43 100644--- a/kornia/augmentation/container/utils.py+++ b/kornia/augmentation/container/utils.py@@ -555,7 +555,6 @@ class KeypointsApplyInverse(BBoxApplyInverse):@classmethoddef pad(cls, input: Tensor, padding_size: Tensor) -> Tensor:-if len(input.shape) not in (2, 3):raise AssertionError(input.shape)@@ -578,7 +577,6 @@ class KeypointsApplyInverse(BBoxApplyInverse):@classmethoddef unpad(cls, input: Tensor, padding_size: Tensor) -> Tensor:-if len(input.shape) not in (2, 3):raise AssertionError(input.shape)if len(padding_size.shape) != 2:diff --git a/kornia/augmentation/random_generator/_2d/planckian_jitter.py b/kornia/augmentation/random_generator/_2d/planckian_jitter.pyindex 1f2cbfcb2..e9388f1ce 100644--- a/kornia/augmentation/random_generator/_2d/planckian_jitter.py+++ b/kornia/augmentation/random_generator/_2d/planckian_jitter.py@@ -15,7 +15,6 @@ class PlanckianJitterGenerator(RandomGeneratorBase):self.domain = domaindef make_samplers(self, device: torch.device, dtype: torch.dtype) -> None:-idx_range = _range_bound(self.domain, 'idx_range', device=device, dtype=dtype)_joint_range_check(idx_range, 'idx_range', (0, self.domain[1]))diff --git a/kornia/constants.py b/kornia/constants.pyindex b3e32a7d4..85dc6e96c 100644--- a/kornia/constants.py+++ b/kornia/constants.py@@ -85,7 +85,6 @@ class DType(Enum, metaclass=_KORNIA_EnumMeta):@classmethoddef get(cls, value: Union[str, int, torch.dtype, Tensor, 'DType']) -> 'DType':-if isinstance(value, torch.dtype):return cls[str(value).upper()[6:]]diff --git a/kornia/enhance/normalize.py b/kornia/enhance/normalize.pyindex 7711d89f5..d5aa6e916 100644--- a/kornia/enhance/normalize.py+++ b/kornia/enhance/normalize.py@@ -157,7 +157,6 @@ class Denormalize(nn.Module):"""def __init__(self, mean: Union[torch.Tensor, float], std: Union[torch.Tensor, float]) -> None:-super().__init__()self.mean = meandiff --git a/kornia/feature/keynet.py b/kornia/feature/keynet.pyindex 516a8e04a..e92f5b4bd 100644--- a/kornia/feature/keynet.py+++ b/kornia/feature/keynet.py@@ -69,7 +69,6 @@ class _HandcraftedBlock(Module):self.spatial_gradient = SpatialGradient('sobel', 1)def forward(self, x: Tensor) -> Tensor:-sobel = self.spatial_gradient(x)dx, dy = sobel[:, :, 0, :, :], sobel[:, :, 1, :, :]diff --git a/kornia/filters/kernels.py b/kornia/filters/kernels.pyindex 0084bd87a..13d458591 100644--- a/kornia/filters/kernels.py+++ b/kornia/filters/kernels.py@@ -29,8 +29,7 @@ def gaussian(window_size: int, sigma: float) -> Tensor:def gaussian_discrete_erf(window_size: int, sigma) -> Tensor:r"""Discrete Gaussian by interpolating the error function.- Adapted from:- https://github.com/Project-MONAI/MONAI/blob/master/monai/networks/layers/convutils.py+ Adapted from: https://github.com/Project-MONAI/MONAI/blob/master/monai/networks/layers/convutils.py"""device = sigma.device if isinstance(sigma, Tensor) else Nonesigma = as_tensor(sigma, dtype=torch.float, device=device)@@ -107,8 +106,7 @@ def _modified_bessel_i(n: int, x: Tensor) -> Tensor:def gaussian_discrete(window_size, sigma) -> Tensor:r"""Discrete Gaussian kernel based on the modified Bessel functions.- Adapted from:- https://github.com/Project-MONAI/MONAI/blob/master/monai/networks/layers/convutils.py+ Adapted from: https://github.com/Project-MONAI/MONAI/blob/master/monai/networks/layers/convutils.py"""device = sigma.device if isinstance(sigma, Tensor) else Nonesigma = as_tensor(sigma, dtype=torch.float, device=device)diff --git a/kornia/nerf/nerf_model.py b/kornia/nerf/nerf_model.pyindex f21b6ebcd..756d3825f 100755--- a/kornia/nerf/nerf_model.py+++ b/kornia/nerf/nerf_model.py@@ -88,7 +88,6 @@ class NerfModel(nn.Module):self._rgb[0].bias.data = torch.tensor([0.02, 0.02, 0.02]).float()def forward(self, origins: Tensor, directions: Tensor) -> Tensor:-# Sample xyz for ray parametersbatch_size = origins.shape[0]lengths = sample_lengths(diff --git a/test/augmentation/test_augmentation.py b/test/augmentation/test_augmentation.pyindex 73b5dfb72..fa1acd743 100644--- a/test/augmentation/test_augmentation.py+++ b/test/augmentation/test_augmentation.py@@ -178,7 +178,6 @@ class CommonTests(BaseTester):assert augmentation.transform_matrix.shape == expected_transformation_shapedef _test_cardinality_implementation(self, input_shape, expected_output_shape, params):-# p==0.0augmentation = self._create_augmentation_from_params(**params, p=0.0)test_input = torch.rand(input_shape, device=self.device, dtype=self.dtype)@@ -273,7 +272,6 @@ class CommonTests(BaseTester):class TestRandomEqualizeAlternative(CommonTests):-possible_params: Dict["str", Tuple] = {}_augmentation_cls = RandomEqualize@@ -362,7 +360,6 @@ class TestRandomEqualizeAlternative(CommonTests):)def test_exception(self):-with pytest.raises(ValueError):self._create_augmentation_from_params(p=1.0)(torch.ones((1, 3, 4, 5) * 3, device=self.device, dtype=self.dtype)@@ -613,7 +610,6 @@ class TestRandomRotationAlternative(CommonTests):class TestRandomGrayscaleAlternative(CommonTests):-possible_params: Dict["str", Tuple] = {}_augmentation_cls = RandomGrayscale@@ -680,7 +676,6 @@ class TestRandomGrayscaleAlternative(CommonTests):class TestRandomHorizontalFlip:-# TODO: improve and implement more meaningful smoke tests e.g check for a consistent# return values such a Tensor variable.@pytest.mark.xfail(reason="might fail under windows OS due to printing preicision.")@@ -690,7 +685,6 @@ class TestRandomHorizontalFlip:assert str(f) == reprdef test_random_hflip(self, device, dtype):-f = RandomHorizontalFlip(p=1.0)f1 = RandomHorizontalFlip(p=0.0)@@ -720,7 +714,6 @@ class TestRandomHorizontalFlip:assert (f1.inverse(expected) == expected).all()def test_batch_random_hflip(self, device, dtype):-f = RandomHorizontalFlip(p=1.0)f1 = RandomHorizontalFlip(p=0.0)@@ -760,7 +753,6 @@ class TestRandomHorizontalFlip:assert (f.inverse(res) == input).all()def test_sequential(self, device, dtype):-f = AugmentationSequential(RandomHorizontalFlip(p=1.0), RandomHorizontalFlip(p=1.0))input = torch.tensor(@@ -779,7 +771,6 @@ class TestRandomHorizontalFlip:assert (f.inverse(out) == input).all()def test_random_hflip_coord_check(self, device, dtype):-f = RandomHorizontalFlip(p=1.0)input = torch.tensor(@@ -834,7 +825,6 @@ class TestRandomHorizontalFlip:class TestRandomVerticalFlip(BaseTester):-# TODO: improve and implement more meaningful smoke tests e.g check for a consistent# return values such a Tensor variable.@pytest.mark.xfail(reason="might fail under windows OS due to printing preicision.")@@ -844,7 +834,6 @@ class TestRandomVerticalFlip(BaseTester):assert str(f) == reprdef test_random_vflip(self, device, dtype):-f = RandomVerticalFlip(p=1.0)f1 = RandomVerticalFlip(p=0.0)@@ -873,7 +862,6 @@ class TestRandomVerticalFlip(BaseTester):self.assert_close(f1.inverse(input), input, low_tolerance=True)def test_batch_random_vflip(self, device, dtype):-f = RandomVerticalFlip(p=1.0)input = torch.tensor(@@ -909,7 +897,6 @@ class TestRandomVerticalFlip(BaseTester):assert (f.inverse(res) == input).all()def test_sequential(self, device, dtype):-f = AugmentationSequential(RandomVerticalFlip(p=1.0), RandomVerticalFlip(p=1.0))input = torch.tensor(@@ -926,7 +913,6 @@ class TestRandomVerticalFlip(BaseTester):self.assert_close(f.transform_matrix, expected_transform_1, low_tolerance=True)def test_random_vflip_coord_check(self, device, dtype):-f = RandomVerticalFlip(p=1.0)input = torch.tensor(@@ -996,7 +982,6 @@ class TestRandomVerticalFlip(BaseTester):class TestColorJiggle(BaseTester):-# TODO: improve and implement more meaningful smoke tests e.g check for a consistent# return values such a Tensor variable.@pytest.mark.xfail(reason="might fail under windows OS due to printing preicision.")@@ -1010,7 +995,6 @@ class TestColorJiggle(BaseTester):assert str(f) == reprdef test_color_jiggle(self, device, dtype):-f = ColorJiggle()input = torch.rand(3, 5, 5, device=device, dtype=dtype).unsqueeze(0) # 3 x 5 x 5@@ -1319,7 +1303,6 @@ class TestColorJiggle(BaseTester):class TestColorJitter(BaseTester):-# TODO: improve and implement more meaningful smoke tests e.g check for a consistent# return values such a Tensor variable.@pytest.mark.xfail(reason="might fail under windows OS due to printing preicision.")@@ -1656,7 +1639,6 @@ class TestRandomBrightness(BaseTester):assert str(f.__repr__) == reprdef test_random_brighness_identity(self, device, dtype):-f = RandomBrightness()input = torch.rand(3, 5, 5, device=device, dtype=dtype).unsqueeze(0) # 3 x 5 x 5@@ -1758,7 +1740,6 @@ class TestRandomContrast(BaseTester):assert str(f) == reprdef test_random_contrast_identity(self, device, dtype):-f = RandomContrast()input = torch.rand(3, 5, 5, device=device, dtype=dtype).unsqueeze(0) # 3 x 5 x 5@@ -1860,7 +1841,6 @@ class TestRandomHue(BaseTester):assert str(f) == reprdef test_random_hue_identity(self, device, dtype):-f = RandomHue(hue=(0.0, 0.0))input = torch.rand(3, 5, 5, device=device, dtype=dtype).unsqueeze(0) # 3 x 5 x 5@@ -1970,7 +1950,6 @@ class TestRandomSaturation(BaseTester):assert str(f) == reprdef test_random_saturation_identity(self, device, dtype):-f = RandomSaturation(saturation=(1.0, 1.0))input = torch.rand(3, 5, 5, device=device, dtype=dtype).unsqueeze(0) # 3 x 5 x 5@@ -2134,7 +2113,6 @@ class TestRectangleRandomErasing(BaseTester):class TestRandomGamma(BaseTester):-# return values such a Tensor variable.@pytest.mark.xfail(reason="might fail under windows OS due to printing preicision.")def test_smoke(self):@@ -2260,7 +2238,6 @@ class TestRandomGamma(BaseTester):class TestRandomGrayscale(BaseTester):-# TODO: improve and implement more meaningful smoke tests e.g check for a consistent# return values such a Tensor variable.@pytest.mark.xfail(reason="might fail under windows OS due to printing preicision.")@@ -2270,7 +2247,6 @@ class TestRandomGrayscale(BaseTester):assert str(f) == reprdef test_random_grayscale(self, device, dtype):-f = RandomGrayscale()input = torch.rand(3, 5, 5, device=device, dtype=dtype) # 3 x 5 x 5@@ -2588,7 +2564,6 @@ class TestCenterCrop(BaseTester):class TestRandomRotation(BaseTester):-torch.manual_seed(0) # for random reproductibility# TODO: improve and implement more meaningful smoke tests e.g check for a consistent@@ -2640,7 +2615,6 @@ class TestRandomRotation(BaseTester):self.assert_close(f.transform_matrix, expected_transform, low_tolerance=True)def test_batch_random_rotation(self, device, dtype):-torch.manual_seed(0) # for random reproductibilityf = RandomRotation(degrees=45.0, p=1.0)@@ -2696,7 +2670,6 @@ class TestRandomRotation(BaseTester):assert (res[0] == res[1]).all()def test_sequential(self, device, dtype):-torch.manual_seed(0) # for random reproductibilityf = AugmentationSequential(RandomRotation(torch.tensor([-45.0, 90]), p=1.0), RandomRotation(10.4, p=1.0))@@ -2733,7 +2706,6 @@ class TestRandomRotation(BaseTester):self.assert_close(f.transform_matrix, expected_transform, low_tolerance=True)def test_gradcheck(self, device, dtype):-torch.manual_seed(0) # for random reproductibilityinput = torch.rand((3, 3), device=device, dtype=dtype) # 3 x 3@@ -3326,7 +3298,6 @@ class TestRandomEqualize(BaseTester):assert (res[0] == res[1]).all()def test_gradcheck(self, device, dtype):-torch.manual_seed(0) # for random reproductibilityinput = torch.rand((3, 3, 3), device=device, dtype=dtype) # 3 x 3 x 3@@ -3362,7 +3333,6 @@ class TestRandomEqualize(BaseTester):class TestGaussianBlur:-# TODO: improve and implement more meaningful smoke tests e.g check for a consistent# return values such a Tensor variable.@pytest.mark.xfail(reason="might fail under windows OS due to printing preicision.")@@ -3502,7 +3472,6 @@ class TestNormalize(BaseTester):self.assert_close(f1.transform_matrix, identity)def test_gradcheck(self, device, dtype):-torch.manual_seed(0) # for random reproductibilityinput = torch.rand((3, 3, 3), device=device, dtype=dtype) # 3 x 3 x 3@@ -3571,7 +3540,6 @@ class TestDenormalize(BaseTester):self.assert_close(f1.transform_matrix, identity)def test_gradcheck(self, device, dtype):-torch.manual_seed(0) # for random reproductibilityinput = torch.rand((3, 3, 3), device=device, dtype=dtype) # 3 x 3 x 3diff --git a/test/augmentation/test_augmentation_3d.py b/test/augmentation/test_augmentation_3d.pyindex e0ae748eb..59656801c 100644--- a/test/augmentation/test_augmentation_3d.py+++ b/test/augmentation/test_augmentation_3d.py@@ -20,7 +20,6 @@ from kornia.testing import assert_closeclass TestRandomHorizontalFlip3D:-# TODO: improve and implement more meaningful smoke tests e.g check for a consistent# return values such a torch.Tensor variable.@pytest.mark.xfail(reason="might fail under windows OS due to printing preicision.")@@ -30,7 +29,6 @@ class TestRandomHorizontalFlip3D:assert str(f) == reprdef test_random_hflip(self, device):-f = RandomHorizontalFlip3D(p=1.0)f1 = RandomHorizontalFlip3D(p=0.0)@@ -69,7 +67,6 @@ class TestRandomHorizontalFlip3D:assert (f1.transform_matrix == identity).all()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@@ -103,7 +100,6 @@ class TestRandomHorizontalFlip3D:assert (res[0] == res[1]).all()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 3 x 3@@ -127,7 +123,6 @@ class TestRandomHorizontalFlip3D:class TestRandomVerticalFlip3D:-# TODO: improve and implement more meaningful smoke tests e.g check for a consistent# return values such a torch.Tensor variable.@pytest.mark.xfail(reason="might fail under windows OS due to printing preicision.")@@ -137,7 +132,6 @@ class TestRandomVerticalFlip3D:assert str(f) == reprdef test_random_vflip(self, device, dtype):-f = RandomVerticalFlip3D(p=1.0)f1 = RandomVerticalFlip3D(p=0.0)@@ -185,7 +179,6 @@ class TestRandomVerticalFlip3D:assert_close(f1.transform_matrix, identity)def test_batch_random_vflip(self, device):-f = RandomVerticalFlip3D(p=1.0)f1 = RandomVerticalFlip3D(p=0.0)@@ -222,7 +215,6 @@ class TestRandomVerticalFlip3D:assert (res[0] == res[1]).all()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@@ -245,7 +237,6 @@ class TestRandomVerticalFlip3D:class TestRandomDepthicalFlip3D:-# TODO: improve and implement more meaningful smoke tests e.g check for a consistent# return values such a torch.Tensor variable.@pytest.mark.xfail(reason="might fail under windows OS due to printing preicision.")@@ -255,7 +246,6 @@ class TestRandomDepthicalFlip3D:assert str(f) == reprdef test_random_dflip(self, device, dtype):-f = RandomDepthicalFlip3D(p=1.0)f1 = RandomDepthicalFlip3D(p=0.0)@@ -303,7 +293,6 @@ class TestRandomDepthicalFlip3D:assert_close(f1.transform_matrix, identity)def test_batch_random_dflip(self, device):-f = RandomDepthicalFlip3D(p=1.0)f1 = RandomDepthicalFlip3D(p=0.0)@@ -351,7 +340,6 @@ class TestRandomDepthicalFlip3D:assert (res[0] == res[1]).all()def test_sequential(self, device):-f = AugmentationSequential(RandomDepthicalFlip3D(p=1.0), RandomDepthicalFlip3D(p=1.0))input = torch.tensor(@@ -383,7 +371,6 @@ class TestRandomDepthicalFlip3D:class TestRandomRotation3D:-torch.manual_seed(0) # for random reproductibility# TODO: improve and implement more meaningful smoke tests e.g check for a consistent@@ -462,7 +449,6 @@ class TestRandomRotation3D:assert_close(f.transform_matrix, expected_transform, rtol=1e-6, atol=1e-4)def test_batch_random_rotation(self, device, dtype):-torch.manual_seed(24) # for random reproductibilityf = RandomRotation3D(degrees=45.0)@@ -562,7 +548,6 @@ class TestRandomRotation3D:assert (res[0] == res[1]).all()def test_sequential(self, device, dtype):-torch.manual_seed(24) # for random reproductibilityf = AugmentationSequential(RandomRotation3D(torch.tensor([-45.0, 90])), RandomRotation3D(10.4))@@ -623,7 +608,6 @@ class TestRandomRotation3D:assert_close(f.transform_matrix, expected_transform, rtol=1e-6, atol=1e-4)def test_gradcheck(self, device):-torch.manual_seed(0) # for random reproductibilityinput = torch.rand((3, 3, 3)).to(device) # 3 x 3 x 3diff --git a/test/augmentation/test_backward.py b/test/augmentation/test_backward.pyindex 243c20108..23b3192f9 100644--- a/test/augmentation/test_backward.py+++ b/test/augmentation/test_backward.py@@ -22,7 +22,6 @@ class TestColorJiggleBackward:@pytest.mark.parametrize("hue", [0.1, torch.tensor(0.1), torch.tensor([-0.1, 0.1])])@pytest.mark.parametrize("same_on_batch", [True, False])def test_param(self, brightness, contrast, saturation, hue, same_on_batch, device, dtype):-_brightness = (brightnessif isinstance(brightness, (int, float))@@ -78,7 +77,6 @@ class TestColorJitterBackward:@pytest.mark.parametrize("hue", [0.1, torch.tensor(0.1), torch.tensor([-0.1, 0.1])])@pytest.mark.parametrize("same_on_batch", [True, False])def test_param(self, brightness, contrast, saturation, hue, same_on_batch, device, dtype):-_brightness = (brightnessif isinstance(brightness, (int, float))@@ -140,7 +138,6 @@ class TestRandomAffineBackward:@pytest.mark.parametrize("align_corners", [True, False])@pytest.mark.parametrize("same_on_batch", [True, False])def test_param(self, degrees, translate, scale, shear, resample, align_corners, same_on_batch, device, dtype):-_degrees = (degreesif isinstance(degrees, (int, float, list, tuple))@@ -243,7 +240,6 @@ class TestRandomRotationBackward:@pytest.mark.parametrize("align_corners", [True, False])@pytest.mark.parametrize("same_on_batch", [True, False])def test_param(self, degrees, resample, align_corners, same_on_batch, device, dtype):-_degrees = (degreesif isinstance(degrees, (int, float, list, tuple))@@ -283,7 +279,6 @@ class TestRandomPerspectiveBackward:@pytest.mark.parametrize("align_corners", [True, False])@pytest.mark.parametrize("same_on_batch", [True, False])def test_param(self, distortion_scale, resample, align_corners, same_on_batch, device, dtype):-_distortion_scale = (distortion_scaleif isinstance(distortion_scale, (float, int))@@ -330,7 +325,6 @@ class TestRandomMotionBlurBackward:@pytest.mark.parametrize("resample", ['bilinear']) # TODO: Ignore nearest for now.@pytest.mark.parametrize("same_on_batch", [True, False])def test_param(self, angle, direction, border_type, resample, same_on_batch, device, dtype):-_angle = (angleif isinstance(angle, (float, int, list, tuple))@@ -382,7 +376,6 @@ class TestRandomSharpnessBackward:@pytest.mark.parametrize("sharpness", [0.5, [0, 0.5], torch.tensor([0, 0.5])])@pytest.mark.parametrize("same_on_batch", [True, False])def test_param(self, sharpness, same_on_batch, device, dtype):-_sharpness = (sharpnessif isinstance(sharpness, (float, int, list, tuple))@@ -416,7 +409,6 @@ class TestRandomResizedCropBackward:@pytest.mark.parametrize("align_corners", [True, False])@pytest.mark.parametrize("same_on_batch", [True, False])def test_param(self, scale, ratio, resample, align_corners, same_on_batch, device, dtype):-_scale = (scale if isinstance(scale, (list, tuple)) else nn.Parameter(scale.clone().to(device=device, dtype=dtype)))@@ -456,7 +448,6 @@ class TestRandomErasingBackward:@pytest.mark.parametrize("value", [0.0])@pytest.mark.parametrize("same_on_batch", [True, False])def test_param(self, scale, ratio, value, same_on_batch, device, dtype):-_scale = (scale if isinstance(scale, (list, tuple)) else nn.Parameter(scale.clone().to(device=device, dtype=dtype)))diff --git a/test/augmentation/test_backward_3d.py b/test/augmentation/test_backward_3d.pyindex 5233dabe2..561e8e6af 100644--- a/test/augmentation/test_backward_3d.py+++ b/test/augmentation/test_backward_3d.py@@ -46,7 +46,6 @@ class TestRandomAffine3DBackward:@pytest.mark.parametrize("align_corners", [True, False])@pytest.mark.parametrize("same_on_batch", [True, False])def test_param(self, degrees, translate, scale, shear, resample, align_corners, same_on_batch, device, dtype):-_degrees = (degreesif isinstance(degrees, (int, float, list, tuple))@@ -158,7 +157,6 @@ class TestRandomRotation3DBackward:@pytest.mark.parametrize("align_corners", [True, False])@pytest.mark.parametrize("same_on_batch", [True, False])def test_param(self, degrees, resample, align_corners, same_on_batch, device, dtype):-_degrees = (degreesif isinstance(degrees, (int, float, list, tuple))@@ -198,7 +196,6 @@ class TestRandomPerspective3DBackward:@pytest.mark.parametrize("align_corners", [True, False])@pytest.mark.parametrize("same_on_batch", [True, False])def test_param(self, distortion_scale, resample, align_corners, same_on_batch, device, dtype):-_distortion_scale = (distortion_scaleif isinstance(distortion_scale, (float, int))@@ -246,7 +243,6 @@ class TestRandomMotionBlur3DBackward:@pytest.mark.parametrize("resample", ['bilinear']) # TODO: Ignore nearest for now.@pytest.mark.parametrize("same_on_batch", [True, False])def test_param(self, angle, direction, border_type, resample, same_on_batch, device, dtype):-_angle = (angleif isinstance(angle, (float, int, list, tuple))diff --git a/test/augmentation/test_motionblur.py b/test/augmentation/test_motionblur.pyindex 364993a7d..aac02f753 100644--- a/test/augmentation/test_motionblur.py+++ b/test/augmentation/test_motionblur.py@@ -9,7 +9,6 @@ from kornia.testing import assert_close, tensor_to_gradcheck_var# TODO: add kornia.testing.BaseTesterclass TestRandomMotionBlur:-# TODO: improve and implement more meaningful smoke tests e.g check for a consistent# return values such a torch.Tensor variable.@pytest.mark.xfail(reason="might fail under windows OS due to printing preicision.")@@ -43,7 +42,6 @@ class TestRandomMotionBlur:@pytest.mark.parametrize("input_shape", [(1, 1, 5, 5), (2, 1, 5, 5)])def test_against_functional(self, input_shape):-input = torch.randn(*input_shape)f = RandomMotionBlur(kernel_size=(3, 5), angle=(10, 30), direction=0.5, p=1.0)@@ -113,7 +111,6 @@ class TestRandomMotionBlur3D:@pytest.mark.parametrize("input_shape", [(1, 1, 5, 6, 7), (2, 1, 5, 6, 7)])def test_against_functional(self, input_shape):-input = torch.randn(*input_shape)f = RandomMotionBlur3D(kernel_size=(3, 5), angle=(10, 30), direction=0.5, p=1.0)diff --git a/test/augmentation/test_perspective_rand.py b/test/augmentation/test_perspective_rand.pyindex 48dff0ba9..b9ae609f2 100644--- a/test/augmentation/test_perspective_rand.py+++ b/test/augmentation/test_perspective_rand.py@@ -8,7 +8,6 @@ from kornia.testing import assert_closeclass TestRandomPerspective:-torch.manual_seed(0) # for random reproductibilitydef test_smoke_no_transform_float(self, device):@@ -141,7 +140,6 @@ class TestRandomPerspective:class TestRandomAffine:-torch.manual_seed(0) # for random reproductibilitydef test_smoke_no_transform(self, device):diff --git a/test/enhance/test_core.py b/test/enhance/test_core.pyindex 96598ca52..32e447d50 100644--- a/test/enhance/test_core.py+++ b/test/enhance/test_core.py@@ -16,7 +16,6 @@ def random_shape(dim, min_elem=1, max_elem=10):class TestAddWeighted:-fcn = kornia.enhance.add_weighteddef get_input(self, device, dtype, size, max_elem=10):diff --git a/test/enhance/test_histogram.py b/test/enhance/test_histogram.pyindex fb3244b44..f34249cd3 100644--- a/test/enhance/test_histogram.py+++ b/test/enhance/test_histogram.py@@ -90,7 +90,6 @@ class TestImageHistogram2d:class TestHistogram2d:-fcn = kornia.enhance.histogram2ddef test_shape(self, device, dtype):@@ -144,7 +143,6 @@ class TestHistogram2d:class TestHistogram:-fcn = kornia.enhance.histogramdef test_shape(self, device, dtype):diff --git a/test/enhance/test_normalize.py b/test/enhance/test_normalize.pyindex fa7d4d026..14510cda3 100644--- a/test/enhance/test_normalize.py+++ b/test/enhance/test_normalize.py@@ -15,7 +15,6 @@ class TestNormalize(BaseTester):assert str(kornia.enhance.Normalize(mean, std)) == reprdef test_normalize(self, device, dtype):-# prepare input datadata = torch.ones(1, 2, 2, device=device, dtype=dtype)mean = torch.tensor([0.5], device=device, dtype=dtype)@@ -28,7 +27,6 @@ class TestNormalize(BaseTester):self.assert_close(f(data), expected)def test_broadcast_normalize(self, device, dtype):-# prepare input datadata = torch.ones(2, 3, 1, 1, device=device, dtype=dtype)data += 2@@ -43,7 +41,6 @@ class TestNormalize(BaseTester):self.assert_close(f(data), expected)def test_float_input(self, device, dtype):-data = torch.ones(2, 3, 1, 1, device=device, dtype=dtype)data += 2@@ -57,7 +54,6 @@ class TestNormalize(BaseTester):self.assert_close(f(data), expected)def test_batch_normalize(self, device, dtype):-# prepare input datadata = torch.ones(2, 3, 1, 1, device=device, dtype=dtype)data += 2@@ -153,7 +149,6 @@ class TestDenormalize(BaseTester):assert str(kornia.enhance.Denormalize(mean, std)) == reprdef test_denormalize(self, device, dtype):-# prepare input datadata = torch.ones(1, 2, 2, device=device, dtype=dtype)mean = torch.tensor([0.5])@@ -166,7 +161,6 @@ class TestDenormalize(BaseTester):self.assert_close(f(data), expected)def test_broadcast_denormalize(self, device, dtype):-# prepare input datadata = torch.ones(2, 3, 1, 1, device=device, dtype=dtype)data += 2@@ -181,7 +175,6 @@ class TestDenormalize(BaseTester):self.assert_close(f(data), expected)def test_float_input(self, device, dtype):-data = torch.ones(2, 3, 1, 1, device=device, dtype=dtype)data += 2@@ -195,7 +188,6 @@ class TestDenormalize(BaseTester):self.assert_close(f(data), expected)def test_batch_denormalize(self, device, dtype):-# prepare input datadata = torch.ones(2, 3, 1, 1, device=device, dtype=dtype)data += 2@@ -222,7 +214,6 @@ class TestDenormalize(BaseTester):self.assert_close(op(*inputs), op_script(*inputs))def test_gradcheck(self, device, dtype):-# prepare input datadata = torch.ones(2, 3, 1, 1, device=device, dtype=dtype)data += 2@@ -236,7 +227,6 @@ class TestDenormalize(BaseTester):assert gradcheck(kornia.enhance.Denormalize(mean, std), (data,), raise_exception=True, fast_mode=True)def test_single_value(self, device, dtype):-# prepare input datamean = torch.tensor(2, device=device, dtype=dtype)std = torch.tensor(3, device=device, dtype=dtype)diff --git a/test/enhance/test_zca.py b/test/enhance/test_zca.pyindex 0a626108e..f1ff21bb7 100644--- a/test/enhance/test_zca.py+++ b/test/enhance/test_zca.py@@ -10,7 +10,6 @@ from kornia.testing import BaseTesterclass TestZCA(BaseTester):@pytest.mark.parametrize("unbiased", [True, False])def test_zca_unbiased(self, unbiased, device, dtype):-data = torch.tensor([[0, 1], [1, 0], [-1, 0], [0, -1]], device=device, dtype=dtype)if unbiased:@@ -92,7 +91,6 @@ class TestZCA(BaseTester):assert gradcheck(zca_T_inv, (data,), raise_exception=True)def test_grad_zca_with_fit(self, device, dtype):-data = torch.tensor([[2, 0], [0, 1], [-2, 0], [0, -1]], device=device, dtype=dtype)data = utils.tensor_to_gradcheck_var(data)@@ -104,7 +102,6 @@ class TestZCA(BaseTester):assert gradcheck(zca_fit, (data,), raise_exception=True)def test_grad_detach_zca(self, device, dtype):-data = torch.tensor([[1, 0], [0, 1], [-2, 0], [0, -1]], device=device, dtype=dtype)data = utils.tensor_to_gradcheck_var(data)@@ -115,7 +112,6 @@ class TestZCA(BaseTester):assert gradcheck(zca, (data,), raise_exception=True)def test_not_fitted(self, device, dtype):-with pytest.raises(RuntimeError):data = torch.rand(10, 2, device=device, dtype=dtype)@@ -123,7 +119,6 @@ class TestZCA(BaseTester):zca(data)def test_not_fitted_inv(self, device, dtype):-with pytest.raises(RuntimeError):data = torch.rand(10, 2, device=device, dtype=dtype)@@ -131,7 +126,6 @@ class TestZCA(BaseTester):zca.inverse_transform(data)def test_jit(self, device, dtype):-data = torch.rand(10, 3, 1, 2, device=device, dtype=dtype)zca = kornia.enhance.ZCAWhitening().fit(data)zca_jit = kornia.enhance.ZCAWhitening().fit(data)@@ -140,7 +134,6 @@ class TestZCA(BaseTester):@pytest.mark.parametrize("unbiased", [True, False])def test_zca_whiten_func_unbiased(self, unbiased, device, dtype):-data = torch.tensor([[0, 1], [1, 0], [-1, 0], [0, -1]], device=device, dtype=dtype)if unbiased:diff --git a/test/geometry/calibration/test_pnp.py b/test/geometry/calibration/test_pnp.pyindex aa633e7f0..b5f1c41f8 100644--- a/test/geometry/calibration/test_pnp.py+++ b/test/geometry/calibration/test_pnp.py@@ -90,7 +90,6 @@ class TestSolvePnpDlt:@pytest.mark.parametrize("num_points", (6, 20))def test_smoke(self, num_points, device, dtype):-intrinsics, _, world_points, img_points = self._get_test_data(num_points, device, dtype)batch_size = world_points.shape[0]@@ -99,7 +98,6 @@ class TestSolvePnpDlt:@pytest.mark.parametrize("num_points", (6,))def test_gradcheck(self, num_points, device, dtype):-intrinsics, _, world_points, img_points = self._get_test_data(num_points, device, dtype)world_points = tensor_to_gradcheck_var(world_points)@@ -112,7 +110,6 @@ class TestSolvePnpDlt:@pytest.mark.parametrize("num_points", (6, 20))def test_pred_world_to_cam(self, num_points, device, dtype):-intrinsics, gt_world_to_cam, world_points, img_points = self._get_test_data(num_points, device, dtype)pred_world_to_cam = kornia.geometry.solve_pnp_dlt(world_points, img_points, intrinsics)@@ -120,7 +117,6 @@ class TestSolvePnpDlt:@pytest.mark.parametrize("num_points", (6, 20))def test_project(self, num_points, device, dtype):-intrinsics, _, world_points, img_points = self._get_test_data(num_points, device, dtype)pred_world_to_cam = kornia.geometry.solve_pnp_dlt(world_points, img_points, intrinsics)@@ -137,7 +133,6 @@ class TestSolvePnpDlt:class TestNormalization:@pytest.mark.parametrize("dimension", (2, 3, 5))def test_smoke(self, dimension, device, dtype):-batch_size = 10num_points = 100points = torch.rand((batch_size, num_points, dimension), device=device, dtype=dtype)@@ -148,7 +143,6 @@ class TestNormalization:@pytest.mark.parametrize("dimension", (2, 3, 5))def test_gradcheck(self, dimension, device, dtype):-batch_size = 3num_points = 5points = torch.rand((batch_size, num_points, dimension), device=device, dtype=dtype)diff --git a/test/geometry/epipolar/test_essential.py b/test/geometry/epipolar/test_essential.pyindex ecb4e92e4..f4a1dc7d4 100644--- a/test/geometry/epipolar/test_essential.py+++ b/test/geometry/epipolar/test_essential.py@@ -42,7 +42,6 @@ class TestEssentialFromFundamental:assert E_mat.shape == (1, 2, 3, 3)def test_from_fundamental(self, device, dtype):-scene = utils.generate_two_view_random_scene(device, dtype)F_mat = scene['F']@@ -144,7 +143,6 @@ class TestEssentalFromRt:@pytest.mark.xfail(reason="TODO: fix #685")def test_from_fundamental_Rt(self, device, dtype):-scene = utils.generate_two_view_random_scene(device, dtype)E_from_Rt = epi.essential_from_Rt(scene['R1'], scene['t1'], scene['R2'], scene['t2'])@@ -308,7 +306,6 @@ class TestMotionFromEssentialChooseSolution:assert_close(X, Xm[1:-1, :])def test_two_view(self, device, dtype):-scene = utils.generate_two_view_random_scene(device, dtype)E_mat = epi.essential_from_Rt(scene['R1'], scene['t1'], scene['R2'], scene['t2'])diff --git a/test/geometry/epipolar/test_fundamental.py b/test/geometry/epipolar/test_fundamental.pyindex e0dbe7c6b..0594f000d 100644--- a/test/geometry/epipolar/test_fundamental.py+++ b/test/geometry/epipolar/test_fundamental.py@@ -164,7 +164,6 @@ class TestFindFundamental:@pytest.mark.xfail(reason="TODO: fix #685")def test_synthetic_sampson(self, device, dtype):-scene: Dict[str, torch.Tensor] = utils.generate_two_view_random_scene(device, dtype)x1 = scene['x1']diff --git a/test/geometry/test_bbox.py b/test/geometry/test_bbox.pyindex 0f933ef28..5bf41928a 100644--- a/test/geometry/test_bbox.py+++ b/test/geometry/test_bbox.py@@ -16,7 +16,6 @@ from kornia.geometry.bbox import (class TestBbox2D:def test_smoke(self, device, dtype):-# Sample two points of the rectanglepoints = torch.rand(1, 4, device=device, dtype=dtype)@@ -66,7 +65,6 @@ class TestBbox2D:class TestTransformBoxes2D:def test_transform_boxes(self, device, dtype):-boxes = torch.tensor([[139.2640, 103.0150, 397.3120, 410.5225]], device=device, dtype=dtype)expected = torch.tensor([[114.6880, 103.0150, 372.7360, 410.5225]], device=device, dtype=dtype)@@ -77,7 +75,6 @@ class TestTransformBoxes2D:assert_allclose(out, expected, atol=1e-4, rtol=1e-4)def test_transform_multiple_boxes(self, device, dtype):-boxes = torch.tensor([[139.2640, 103.0150, 397.3120, 410.5225],@@ -123,7 +120,6 @@ class TestTransformBoxes2D:assert_allclose(out, expected, atol=1e-4, rtol=1e-4)def test_transform_boxes_wh(self, device, dtype):-boxes = torch.tensor([[139.2640, 103.0150, 258.0480, 307.5075],@@ -152,7 +148,6 @@ class TestTransformBoxes2D:assert_allclose(out, expected, atol=1e-4, rtol=1e-4)def test_gradcheck(self, device, dtype):-boxes = torch.tensor([[139.2640, 103.0150, 258.0480, 307.5075],diff --git a/test/geometry/transform/test_flip.py b/test/geometry/transform/test_flip.pyindex 3ab1e53c9..8aeb2c9f9 100644--- a/test/geometry/transform/test_flip.py+++ b/test/geometry/transform/test_flip.py@@ -14,7 +14,6 @@ class TestVflip:assert str(f) == reprdef test_vflip(self, device, dtype):-f = kornia.geometry.transform.Vflip()input = torch.tensor([[0.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 1.0, 1.0]], device=device, dtype=dtype) # 3 x 3@@ -25,7 +24,6 @@ class TestVflip:assert (f(input) == expected).all()def test_batch_vflip(self, device, dtype):-input = torch.tensor([[0.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 1.0, 1.0]], device=device, dtype=dtype) # 3 x 3input = input.repeat(2, 1, 1) # 2 x 3 x 3@@ -43,7 +41,6 @@ class TestVflip:def test_jit(self, device, dtype):@torch.jit.scriptdef op_script(data: torch.Tensor) -> torch.Tensor:-return kornia.geometry.transform.vflip(data)input = torch.tensor([[0.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 1.0, 1.0]], device=device, dtype=dtype) # 3 x 3@@ -67,7 +64,6 @@ class TestVflip:assert_close(actual, expected)def test_gradcheck(self, device, dtype):-input = torch.tensor([[0.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 1.0, 1.0]], device=device, dtype=dtype) # 3 x 3input = utils.tensor_to_gradcheck_var(input) # to var@@ -82,7 +78,6 @@ class TestHflip:assert str(f) == reprdef test_hflip(self, device, dtype):-f = kornia.geometry.transform.Hflip()input = torch.tensor([[0.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 1.0, 1.0]], device=device, dtype=dtype) # 3 x 3@@ -93,7 +88,6 @@ class TestHflip:assert (f(input) == expected).all()def test_batch_hflip(self, device, dtype):-input = torch.tensor([[0.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 1.0, 1.0]], device=device, dtype=dtype) # 1 x 3 x 3@@ -113,7 +107,6 @@ class TestHflip:def test_jit(self, device, dtype):@torch.jit.scriptdef op_script(data: torch.Tensor) -> torch.Tensor:-return kornia.geometry.transform.hflip(data)input = torch.tensor([[0.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 1.0, 1.0]], device=device, dtype=dtype) # 3 x 3@@ -137,7 +130,6 @@ class TestHflip:assert_close(actual, expected)def test_gradcheck(self, device, dtype):-input = torch.tensor([[0.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 1.0, 1.0]], device=device, dtype=dtype) # 3 x 3input = utils.tensor_to_gradcheck_var(input) # to var@@ -152,7 +144,6 @@ class TestRot180:assert str(f) == reprdef test_rot180(self, device, dtype):-f = kornia.geometry.transform.Rot180()input = torch.tensor([[0.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 1.0, 1.0]], device=device, dtype=dtype) # 3 x 3@@ -163,7 +154,6 @@ class TestRot180:assert (f(input) == expected).all()def test_batch_rot180(self, device, dtype):-input = torch.tensor([[0.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 1.0, 1.0]], device=device, dtype=dtype) # 3 x 3input = input.repeat(2, 1, 1) # 2 x 3 x 3@@ -181,7 +171,6 @@ class TestRot180:def test_jit(self, device, dtype):@torch.jit.scriptdef op_script(data: torch.Tensor) -> torch.Tensor:-return kornia.geometry.transform.rot180(data)input = torch.tensor([[0.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 1.0, 1.0]], device=device, dtype=dtype) # 3 x 3@@ -205,7 +194,6 @@ class TestRot180:assert_close(actual, expected)def test_gradcheck(self, device, dtype):-input = torch.tensor([[0.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 1.0, 1.0]], device=device, dtype=dtype) # 3 x 3input = utils.tensor_to_gradcheck_var(input) # to vardiff --git a/test/integration/test_focal.py b/test/integration/test_focal.pyindex 9f7e509a7..f52680109 100644--- a/test/integration/test_focal.py+++ b/test/integration/test_focal.py@@ -33,7 +33,6 @@ class TestIntegrationFocalLoss:torch.nn.init.xavier_uniform_(m.weight)def test_conv2d_relu(self, device):-# we generate base sampletarget = torch.LongTensor(1, 6, 5).fill_(0).to(device)for i in range(1, self.num_classes):diff --git a/test/integration/test_warp.py b/test/integration/test_warp.pyindex 4fa8df57b..6685242c2 100644--- a/test/integration/test_warp.py+++ b/test/integration/test_warp.py@@ -22,7 +22,6 @@ class TestWarping:num_iterations = 100def test_smoke(self, device):-img_src_t: torch.Tensor = torch.rand(1, 3, 120, 120).to(device)img_dst_t: torch.Tensor = torch.rand(1, 3, 120, 120).to(device)