π Geometric Computer Vision Library for Spatial AI
Python artificial-intelligencecomputer-visiondeep-learninghacktoberfestimage-processingmachine-learningneural-networkpythonpytorchroboticsspatial-ai
test : add missing exception and dynamo tests for FaceDetector (#3520)
Kiran Dharmaraf0be4f93c8f
diff --git a/tests/contrib/test_face_detection.py b/tests/contrib/test_face_detection.pyindex cea9c5fe0..c06138fdd 100644--- a/tests/contrib/test_face_detection.py+++ b/tests/contrib/test_face_detection.py@@ -27,6 +27,10 @@ from testing.base import BaseTesterclass TestFaceDetection(BaseTester):+ @pytest.fixture+ def face_detector(self, device, dtype):+ return kornia.contrib.FaceDetector().to(device, dtype)+@pytest.mark.slowdef test_smoke(self, device, dtype):assert kornia.contrib.FaceDetector().to(device, dtype) is not None@@ -102,5 +106,25 @@ class TestFaceDetection(BaseTester):output_names=["loc", "conf", "iou"],dynamic_axes=dynamic_axes,)-assert model_path.is_file()++ def test_exception(self, face_detector, device, dtype):+ img = torch.rand(1, 4, 320, 320, device=device, dtype=dtype)++ with pytest.raises(RuntimeError):+ face_detector(img)++ @pytest.mark.slow+ def test_dynamo(self, face_detector, device, dtype, torch_optimizer):+ torch.manual_seed(44)+ img = torch.rand(1, 3, 320, 320, device=device, dtype=dtype)++ op_compiled = torch_optimizer(face_detector)++ out_ref = face_detector(img)+ out_opt = op_compiled(img)++ assert len(out_ref) == len(out_opt)++ for r, o in zip(out_ref, out_opt):+ torch.testing.assert_close(r, o, rtol=1e-4, atol=1e-4)