π Geometric Computer Vision Library for Spatial AI
Python artificial-intelligencecomputer-visiondeep-learninghacktoberfestimage-processingmachine-learningneural-networkpythonpytorchroboticsspatial-ai
fix gradcheck in random_perspective
edgarriba15f8fb7c8154
diff --git a/kornia/augmentation/functional.py b/kornia/augmentation/functional.pyindex a6d2cf908..058d64b8e 100644--- a/kornia/augmentation/functional.py+++ b/kornia/augmentation/functional.py@@ -302,7 +302,7 @@ def apply_grayscale(input: torch.Tensor, params: Dict[str, torch.Tensor], returngrayscale: torch.Tensor = input.clone()- to_gray = params['batch_prob'].to(device, dtype)+ to_gray = params['batch_prob'].to(device)grayscale[to_gray] = rgb_to_grayscale(input[to_gray])if return_transform:diff --git a/kornia/augmentation/param_gen.py b/kornia/augmentation/param_gen.pyindex 2f9f76e62..c37f4239a 100644--- a/kornia/augmentation/param_gen.py+++ b/kornia/augmentation/param_gen.py@@ -98,7 +98,7 @@ def _random_color_jitter_gen(batch_size: int, brightness: FloatUnionType = 0.,}-def _random_prob_gen(batch_size: int, p: float = .5) -> Dict[str, torch.Tensor]:+def _random_prob_gen(batch_size: int, p: float = 0.5) -> Dict[str, torch.Tensor]:r"""Generator random probabilities for a batch of inputs.Args:diff --git a/test/augmentation/test_perspective.py b/test/augmentation/test_perspective.pyindex 4b3926685..4f3c731f7 100644--- a/test/augmentation/test_perspective.py+++ b/test/augmentation/test_perspective.py@@ -92,8 +92,7 @@ class TestRandomPerspective:assert out_perspective[0].shape == x_data.shapeassert out_perspective[1].shape == (1, 3, 3)- @pytest.mark.skip("Disabled since it crashes by now")def test_gradcheck(self, device):input = torch.rand(1, 2, 5, 7).to(device)input = utils.tensor_to_gradcheck_var(input) # to var- assert gradcheck(F.random_perspective, (input, 0.), raise_exception=True)+ assert gradcheck(F.random_perspective, (input, 0., 1.), raise_exception=True)