π Geometric Computer Vision Library for Spatial AI
Python artificial-intelligencecomputer-visiondeep-learninghacktoberfestimage-processingmachine-learningneural-networkpythonpytorchroboticsspatial-ai
hotfix for deprecation augmentatio functionals (#1094)
Edgar Riba043acda4c996
diff --git a/Makefile b/Makefileindex 8ee2a1860..6cc611f18 100644--- a/Makefile+++ b/Makefile@@ -30,10 +30,10 @@ test-slow: FORCEpytest -v --device all --dtype all -m "(jit or grad or nn)"lint: FORCE- pytest -v --numprocesses auto --cache-clear --flake8 kornia/ examples/ test/ -m flake8+ pytest -v --cache-clear --flake8 kornia/ examples/ test/ -m flake8mypy: FORCE- pytest -v --numprocesses auto --cache-clear --mypy kornia/ -m mypy+ pytest -v --cache-clear --mypy kornia/ -m mypyautopep8: FORCEautopep8 --in-place --aggressive --recursive kornia/ test/ examples/@@ -42,7 +42,7 @@ yapf: FORCEyapf --in-place --parallel --recursive kornia/ test/ examples/doctest:- pytest -v --numprocesses auto --doctest-modules kornia/+ pytest -v --doctest-modules kornia/docstyle: FORCEpydocstyle kornia/diff --git a/test/augmentation/test_augmentation.py b/test/augmentation/test_augmentation.pyindex 133c82eb3..399b5d460 100644--- a/test/augmentation/test_augmentation.py+++ b/test/augmentation/test_augmentation.py@@ -996,33 +996,6 @@ class TestRandomHorizontalFlip:== input[..., input_coordinates[0, 1, :], input_coordinates[0, 0, :]]).all()- @pytest.mark.skip(reason="turn off all jit for a while")- def test_jit(self, device, dtype):- @torch.jit.script- def op_script(data: torch.Tensor) -> Union[torch.Tensor, Tuple[torch.Tensor, torch.Tensor]]:-- return kornia.apply_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-- # Build jit trace- op_trace = torch.jit.trace(op_script, (input,))-- # Create new inputs- input = torch.tensor([[0.0, 0.0, 0.0], [5.0, 5.0, 0.0], [0.0, 0.0, 0.0]], device=device, dtype=dtype) # 3 x 3-- input = input.repeat(2, 1, 1) # 2 x 3 x 3-- expected = torch.tensor(- [[[0.0, 0.0, 0.0], [0.0, 5.0, 5.0], [0.0, 0.0, 0.0]]], device=device, dtype=dtype- ) # 3 x 3-- expected = expected.repeat(2, 1, 1)-- actual = op_trace(input)-- assert_allclose(actual, expected, atol=1e-4, rtol=1e-4)-def test_gradcheck(self, device, dtype):input = torch.rand((3, 3), device=device, dtype=dtype) # 3 x 3input = utils.tensor_to_gradcheck_var(input) # to var@@ -1184,37 +1157,6 @@ class TestRandomVerticalFlip:== input[..., input_coordinates[0, 1, :], input_coordinates[0, 0, :]]).all()- @pytest.mark.skip(reason="turn off all jit for a while")- def test_jit(self, device, dtype):- @torch.jit.script- def op_script(data: torch.Tensor) -> Union[torch.Tensor, Tuple[torch.Tensor, torch.Tensor]]:- return kornia.apply_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-- # Build jit trace- op_trace = torch.jit.trace(op_script, (input,))-- # Create new inputs- input = torch.tensor([[0.0, 0.0, 0.0], [5.0, 5.0, 0.0], [0.0, 0.0, 0.0]], device=device, dtype=dtype) # 3 x 3-- input = input.repeat(2, 1, 1) # 2 x 3 x 3-- expected = torch.tensor(- [[[0.0, 0.0, 0.0], [5.0, 5.0, 0.0], [0.0, 0.0, 0.0]]], device=device, dtype=dtype- ) # 3 x 3-- expected = expected.repeat(2, 1, 1)-- actual = op_trace(input)-- assert_allclose(actual, expected, atol=1e-4, rtol=1e-4)-- def test_gradcheck(self, device, dtype):- input = torch.rand((3, 3), device=device, dtype=dtype) # 3 x 3- input = utils.tensor_to_gradcheck_var(input) # to var- assert gradcheck(RandomVerticalFlip(p=1.0), (input,), raise_exception=True)-class TestColorJitter:@@ -2064,36 +2006,6 @@ class TestRandomRotation:assert_allclose(mat, expected_transform, rtol=1e-4, atol=1e-4)assert_allclose(mat_2, expected_transform_2, rtol=1e-4, atol=1e-4)- @pytest.mark.skip(reason="turn off all jit for a while")- def test_jit(self, device, dtype):-- torch.manual_seed(0) # for random reproductibility-- @torch.jit.script- def op_script(data: torch.Tensor) -> Union[torch.Tensor, Tuple[torch.Tensor, torch.Tensor]]:- flags = dict(interpolation=torch.tensor(1), align_corners=torch.tensor(True))- return kornia.apply_rotation(data, params={"degrees": torch.tensor(45.0)}, flags=flags)-- input = 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]],- device=device,- dtype=dtype,- ) # 4 x 4-- # Build jit trace- op_trace = torch.jit.trace(op_script, (input,))-- # Create new inputs- input = torch.tensor([[0.0, 0.0, 0.0], [5.0, 5.0, 0.0], [0.0, 0.0, 0.0]], device=device, dtype=dtype) # 3 x 3-- expected = torch.tensor(- [[[0.0000, 0.2584, 0.0000], [2.9552, 5.0000, 0.2584], [1.6841, 0.4373, 0.0000]]], device=device, dtype=dtype- )-- actual = op_trace(input)-- assert_allclose(actual, expected, rtol=1e-6, atol=1e-4)-def test_gradcheck(self, device, dtype):torch.manual_seed(0) # for random reproductibilitydiff --git a/test/augmentation/test_augmentation_3d.py b/test/augmentation/test_augmentation_3d.pyindex c9065fda9..fb739b4bb 100644--- a/test/augmentation/test_augmentation_3d.py+++ b/test/augmentation/test_augmentation_3d.py@@ -131,31 +131,6 @@ class TestRandomHorizontalFlip3D:assert (f1(input)[0] == input).all()assert (f1(input)[1] == expected_transform).all()- @pytest.mark.skip(reason="turn off all jit for a while")- def test_jit(self, device):- @torch.jit.script- def op_script(data: torch.Tensor) -> Union[torch.Tensor, Tuple[torch.Tensor, torch.Tensor]]:-- return kornia.apply_hflip3d(data)-- input = torch.tensor([[[0.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 1.0, 1.0]]]) # 1 x 3 x 3-- # Build jit trace- op_trace = torch.jit.trace(op_script, (input,))-- # Create new inputs- input = torch.tensor([[0.0, 0.0, 0.0], [5.0, 5.0, 0.0], [0.0, 0.0, 0.0]]) # 3 x 3-- input = input.repeat(2, 1, 1) # 2 x 3 x 3-- expected = torch.tensor([[[0.0, 0.0, 0.0], [0.0, 5.0, 5.0], [0.0, 0.0, 0.0]]]) # 3 x 3-- expected = expected.repeat(2, 1, 1)-- actual = op_trace(input)-- assert_allclose(actual, expected)-def test_gradcheck(self, device):input = torch.rand((1, 3, 3)).to(device) # 3 x 3input = utils.tensor_to_gradcheck_var(input) # to var@@ -283,30 +258,6 @@ class TestRandomVerticalFlip3D:assert_allclose(f1(input)[0], input)assert_allclose(f1(input)[1], expected_transform)- @pytest.mark.skip(reason="turn off all jit for a while")- def test_jit(self, device):- @torch.jit.script- def op_script(data: torch.Tensor) -> Union[torch.Tensor, Tuple[torch.Tensor, torch.Tensor]]:- return kornia.apply_vflip3d(data)-- input = torch.tensor([[[0.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 1.0, 1.0]]]) # 4 x 4-- # Build jit trace- op_trace = torch.jit.trace(op_script, (input,))-- # Create new inputs- input = torch.tensor([[[0.0, 0.0, 0.0], [5.0, 5.0, 0.0], [0.0, 0.0, 0.0]]]) # 1 x 4 x 4-- input = input.repeat(2, 1, 1) # 2 x 4 x 4-- expected = torch.tensor([[[[0.0, 0.0, 0.0], [5.0, 5.0, 0.0], [0.0, 0.0, 0.0]]]]) # 1 x 4 x 4-- expected = expected.repeat(2, 1, 1)-- actual = op_trace(input)-- assert_allclose(actual, expected)-def test_gradcheck(self, device):input = torch.rand((1, 3, 3)).to(device) # 4 x 4input = utils.tensor_to_gradcheck_var(input) # to var@@ -454,30 +405,6 @@ class TestRandomDepthicalFlip3D:assert_allclose(f1(input)[0], input)assert_allclose(f1(input)[1], expected_transform)- @pytest.mark.skip(reason="turn off all jit for a while")- def test_jit(self, device):- @torch.jit.script- def op_script(data: torch.Tensor) -> Union[torch.Tensor, Tuple[torch.Tensor, torch.Tensor]]:- return kornia.apply_vflip3d(data)-- input = torch.tensor([[[0.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 1.0, 1.0]]]) # 4 x 4-- # Build jit trace- op_trace = torch.jit.trace(op_script, (input,))-- # Create new inputs- input = torch.tensor([[[0.0, 0.0, 0.0], [5.0, 5.0, 0.0], [0.0, 0.0, 0.0]]]) # 1 x 4 x 4-- input = input.repeat(2, 1, 1) # 2 x 4 x 4-- expected = torch.tensor([[[[0.0, 0.0, 0.0], [5.0, 5.0, 0.0], [0.0, 0.0, 0.0]]]]) # 1 x 4 x 4-- expected = expected.repeat(2, 1, 1)-- actual = op_trace(input)-- assert_allclose(actual, expected)-def test_gradcheck(self, device):input = torch.rand((1, 3, 3)).to(device) # 4 x 4input = utils.tensor_to_gradcheck_var(input) # to var@@ -748,42 +675,6 @@ class TestRandomRotation3D:assert_allclose(mat, expected_transform, rtol=1e-6, atol=1e-4)assert_allclose(mat_2, expected_transform_2, rtol=1e-6, atol=1e-4)- @pytest.mark.skip(reason="turn off all jit for a while")- def test_jit(self, device):-- torch.manual_seed(0) # for random reproductibility-- @torch.jit.script- def op_script(data: torch.Tensor) -> Union[torch.Tensor, Tuple[torch.Tensor, torch.Tensor]]:- flags = dict(interpolation=torch.tensor(1), align_corners=torch.tensor(True))- return kornia.apply_rotation3d(data, params={"degrees": torch.tensor(45.0)}, flags=flags)-- input = 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]],- [[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]],- ]- ) # 3 x 4 x 4-- # Build jit trace- op_trace = torch.jit.trace(op_script, (input,))-- # Create new inputs- input = torch.tensor(- [- [[0.0, 0.0, 0.0], [5.0, 5.0, 0.0], [0.0, 0.0, 0.0]],- [[0.0, 0.0, 0.0], [5.0, 5.0, 0.0], [0.0, 0.0, 0.0]],- [[0.0, 0.0, 0.0], [5.0, 5.0, 0.0], [0.0, 0.0, 0.0]],- ]- ) # 3 x 3 x 3-- expected = torch.tensor([[[0.0000, 0.2584, 0.0000], [2.9552, 5.0000, 0.2584], [1.6841, 0.4373, 0.0000]]])-- actual = op_trace(input)-- assert_allclose(actual, expected, rtol=1e-6, atol=1e-4)-def test_gradcheck(self, device):torch.manual_seed(0) # for random reproductibility