Skip to content

Commit

Permalink
(face) Update tests to assert if images are properly loaded
Browse files Browse the repository at this point in the history
  • Loading branch information
iasonth95 committed Feb 14, 2025
1 parent 79b2f12 commit 96f5895
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion image_recognition_face_recognition/test/test_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def test_import(self):

def test_get_embedding(self):
"""
Test the get_embedding method dimentions
Test the get_embedding method dimensions
"""
# Create a dummy image tensor [batch_size, C, H, W]
dummy_image = torch.randn(1, 3, 160, 160)
Expand Down Expand Up @@ -65,12 +65,14 @@ def test_detect(self):
"""
# Test with an image containing one face
single_face_image = cv2.imread('doc/1.jpg')
self.assertIsNotNone(single_face_image, "Failed to load image: doc/1.jpg")
recognized_faces = self.face_recognizer.detect(single_face_image)
self.assertIsInstance(recognized_faces, list)
self.assertEqual(len(recognized_faces), 1) # Expect exactly 1 face

# Test with an image containing multiple faces
multiple_faces_image = cv2.imread('doc/example.png')
self.assertIsNotNone(multiple_faces_image, "Failed to load image: doc/example.png")
recognized_faces = self.face_recognizer.detect(multiple_faces_image)
self.assertIsInstance(recognized_faces, list)
self.assertGreaterEqual(len(recognized_faces), 6) # Expect at least 2 faces
Expand Down

0 comments on commit 96f5895

Please # to comment.