π Geometric Computer Vision Library for Spatial AI
Python artificial-intelligencecomputer-visiondeep-learninghacktoberfestimage-processingmachine-learningneural-networkpythonpytorchroboticsspatial-ai
fix catch type for torch.svd error (#1431)
Dmytro Mishkin5b436039f64c
diff --git a/kornia/geometry/homography.py b/kornia/geometry/homography.pyindex b7b25ac01..fee972b59 100644--- a/kornia/geometry/homography.py+++ b/kornia/geometry/homography.py@@ -144,7 +144,7 @@ def find_homography_dlt(try:_, _, V = torch.svd(A)- except ValueError:+ except RuntimeError:warnings.warn('SVD did not converge', RuntimeWarning)return torch.empty((points1_norm.size(0), 3, 3), device=device, dtype=dtype)diff --git a/test/geometry/test_homography.py b/test/geometry/test_homography.pyindex 9281b7615..12e61f46e 100644--- a/test/geometry/test_homography.py+++ b/test/geometry/test_homography.py@@ -83,6 +83,14 @@ class TestFindHomographyDLT:H = find_homography_dlt(points1, points2, weights)assert H.shape == (1, 3, 3)+ def test_nocrash(self, device, dtype):+ points1 = torch.rand(1, 4, 2, device=device, dtype=dtype)+ points2 = torch.rand(1, 4, 2, device=device, dtype=dtype)+ weights = torch.ones(1, 4, device=device, dtype=dtype)+ points1[0, 0, 0] = float('nan')+ H = find_homography_dlt(points1, points2, weights)+ assert H.shape == (1, 3, 3)+@pytest.mark.parametrize("batch_size, num_points", [(1, 4), (2, 5), (3, 6)])def test_shape(self, batch_size, num_points, device, dtype):B, N = batch_size, num_points