From 89d0a6e4709fcbecec806345f6af752c5bff4695 Mon Sep 17 00:00:00 2001 From: Aditya Oke Date: Sat, 7 Nov 2020 23:34:12 +0530 Subject: [PATCH 1/5] tries adding anchor tests --- test/test_models_detection_anchor_utils.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 test/test_models_detection_anchor_utils.py diff --git a/test/test_models_detection_anchor_utils.py b/test/test_models_detection_anchor_utils.py new file mode 100644 index 00000000000..ea5419c792b --- /dev/null +++ b/test/test_models_detection_anchor_utils.py @@ -0,0 +1,13 @@ +import unittest +from torchvision.models.detection.anchor_utils import AnchorGenerator + + +class Tester(unittest.TestCase): + def test_incorrect_anchors(self): + incorrect_sizes = (128, 258, 512) + incorrect_aspects = (0.5, 1.0, 2.0) + self.assertRaises(ValueError, AnchorGenerator, incorrect_sizes, incorrect_aspects) + + +if __name__ == '__main__': + unittest.main() \ No newline at end of file From 7db86cc23c7685f37a67068f9848873defc181cf Mon Sep 17 00:00:00 2001 From: Aditya Oke Date: Sat, 7 Nov 2020 23:36:34 +0530 Subject: [PATCH 2/5] fixes lint --- test/test_models_detection_anchor_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_models_detection_anchor_utils.py b/test/test_models_detection_anchor_utils.py index ea5419c792b..c9c6fa0f5d8 100644 --- a/test/test_models_detection_anchor_utils.py +++ b/test/test_models_detection_anchor_utils.py @@ -10,4 +10,4 @@ def test_incorrect_anchors(self): if __name__ == '__main__': - unittest.main() \ No newline at end of file + unittest.main() From ec203aa654b3b2f97c585d3da760417a54cd7f8a Mon Sep 17 00:00:00 2001 From: Aditya Oke Date: Tue, 10 Nov 2020 00:19:43 +0530 Subject: [PATCH 3/5] tries fixing --- test/test_models_detection_anchor_utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/test_models_detection_anchor_utils.py b/test/test_models_detection_anchor_utils.py index c9c6fa0f5d8..b2bb5610a36 100644 --- a/test/test_models_detection_anchor_utils.py +++ b/test/test_models_detection_anchor_utils.py @@ -4,8 +4,8 @@ class Tester(unittest.TestCase): def test_incorrect_anchors(self): - incorrect_sizes = (128, 258, 512) - incorrect_aspects = (0.5, 1.0, 2.0) + incorrect_sizes = ((128, 258, 512), (128, 32)) + incorrect_aspects = ((0.5), (1.0), (2.0, 3.0)) self.assertRaises(ValueError, AnchorGenerator, incorrect_sizes, incorrect_aspects) From e04d1ecf13837b7316493de866a47f0de715bd32 Mon Sep 17 00:00:00 2001 From: Aditya Oke Date: Tue, 10 Nov 2020 00:38:31 +0530 Subject: [PATCH 4/5] tries one more time --- test/test_models_detection_anchor_utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/test_models_detection_anchor_utils.py b/test/test_models_detection_anchor_utils.py index b2bb5610a36..81c3c7f6fca 100644 --- a/test/test_models_detection_anchor_utils.py +++ b/test/test_models_detection_anchor_utils.py @@ -4,8 +4,8 @@ class Tester(unittest.TestCase): def test_incorrect_anchors(self): - incorrect_sizes = ((128, 258, 512), (128, 32)) - incorrect_aspects = ((0.5), (1.0), (2.0, 3.0)) + incorrect_sizes = ((128, 128, 128), (258, 32), ) + incorrect_aspects = ((0.5, 2.0), (3.0)) self.assertRaises(ValueError, AnchorGenerator, incorrect_sizes, incorrect_aspects) From 27a7722f777a963584e0b7d62e0df49e3459ea3e Mon Sep 17 00:00:00 2001 From: Aditya Oke Date: Tue, 10 Nov 2020 15:53:25 +0530 Subject: [PATCH 5/5] fixes the test --- test/test_models_detection_anchor_utils.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/test/test_models_detection_anchor_utils.py b/test/test_models_detection_anchor_utils.py index 81c3c7f6fca..d606b7848e4 100644 --- a/test/test_models_detection_anchor_utils.py +++ b/test/test_models_detection_anchor_utils.py @@ -1,13 +1,15 @@ +import torch import unittest from torchvision.models.detection.anchor_utils import AnchorGenerator +from torchvision.models.detection.image_list import ImageList class Tester(unittest.TestCase): def test_incorrect_anchors(self): - incorrect_sizes = ((128, 128, 128), (258, 32), ) - incorrect_aspects = ((0.5, 2.0), (3.0)) - self.assertRaises(ValueError, AnchorGenerator, incorrect_sizes, incorrect_aspects) - - -if __name__ == '__main__': - unittest.main() + incorrect_sizes = ((2, 4, 8), (32, 8), ) + incorrect_aspects = (0.5, 1.0) + anc = AnchorGenerator(incorrect_sizes, incorrect_aspects) + image1 = torch.randn(3, 800, 800) + image_list = ImageList(image1, [(800, 800)]) + feature_maps = [torch.randn(1, 50)] + self.assertRaises(ValueError, anc, image_list, feature_maps)