π Geometric Computer Vision Library for Spatial AI
Python artificial-intelligencecomputer-visiondeep-learninghacktoberfestimage-processingmachine-learningneural-networkpythonpytorchroboticsspatial-ai
Sift test fix (#341)
Dmytro Mishkin63317a73b22c
diff --git a/test/feature/test_affine_shape_estimator.py b/test/feature/test_affine_shape_estimator.pyindex aac46e050..b904c4ac5 100644--- a/test/feature/test_affine_shape_estimator.py+++ b/test/feature/test_affine_shape_estimator.py@@ -15,10 +15,10 @@ class TestPatchAffineShapeEstimator:assert ang.shape == torch.Size([1, 1, 3])def test_shape_batch(self):- inp = torch.rand(10, 1, 32, 32)+ inp = torch.rand(2, 1, 32, 32)ori = PatchAffineShapeEstimator(32)ang = ori(inp)- assert ang.shape == torch.Size([10, 1, 3])+ assert ang.shape == torch.Size([2, 1, 3])def test_print(self):sift = PatchAffineShapeEstimator(32)@@ -70,10 +70,10 @@ class TestLAFAffineShapeEstimator:assert_allclose(new_laf, expected, atol=1e-4, rtol=1e-4)def test_gradcheck(self):- batch_size, channels, height, width = 1, 1, 100, 100+ batch_size, channels, height, width = 1, 1, 40, 40patches = torch.rand(batch_size, channels, height, width)patches = utils.tensor_to_gradcheck_var(patches) # to var- laf = torch.tensor([[[[20., 0., 56.], [0., 20., 56.]]]])+ laf = torch.tensor([[[[5., 0., 26.], [0., 5., 26.]]]])laf = utils.tensor_to_gradcheck_var(laf) # to varassert gradcheck(LAFAffineShapeEstimator(11), (laf, patches),raise_exception=True, rtol=1e-3, atol=1e-3)diff --git a/test/feature/test_local_features_orientation.py b/test/feature/test_local_features_orientation.pyindex 1a25eef0c..959a4da00 100644--- a/test/feature/test_local_features_orientation.py+++ b/test/feature/test_local_features_orientation.py@@ -34,7 +34,7 @@ class TestPassLAF:assert_allclose(out, laf)def test_gradcheck(self):- batch_size, channels, height, width = 1, 1, 41, 41+ batch_size, channels, height, width = 1, 1, 21, 21patches = torch.rand(batch_size, channels, height, width)patches = utils.tensor_to_gradcheck_var(patches) # to varlaf = torch.rand(batch_size, 4, 2, 3)diff --git a/test/feature/test_siftdesc.py b/test/feature/test_siftdesc.pyindex f19fabb63..b44a341e9 100644--- a/test/feature/test_siftdesc.py+++ b/test/feature/test_siftdesc.py@@ -32,16 +32,16 @@ class TestSIFTDescriptor:assert out.shape == (1, 128)def test_batch_shape(self):- inp = torch.ones(13, 1, 41, 41)- sift = SIFTDescriptor(41)+ inp = torch.ones(2, 1, 15, 15)+ sift = SIFTDescriptor(15)out = sift(inp)- assert out.shape == (13, 128)+ assert out.shape == (2, 128)def test_batch_shape_non_std(self):- inp = torch.ones(13, 1, 41, 41)- sift = SIFTDescriptor(41, 5, 3)+ inp = torch.ones(3, 1, 19, 19)+ sift = SIFTDescriptor(19, 5, 3)out = sift(inp)- assert out.shape == (13, (3 ** 2) * 5)+ assert out.shape == (3, (3 ** 2) * 5)def test_print(self):sift = SIFTDescriptor(41)@@ -60,8 +60,8 @@ class TestSIFTDescriptor:assert_allclose(out, expected, atol=1e-3, rtol=1e-3)def test_gradcheck(self):- batch_size, channels, height, width = 1, 1, 41, 41+ batch_size, channels, height, width = 1, 1, 13, 13patches = torch.rand(batch_size, channels, height, width)patches = utils.tensor_to_gradcheck_var(patches) # to var- assert gradcheck(sift_describe, (patches, 41),+ assert gradcheck(sift_describe, (patches, 13),raise_exception=True)