Beispiel #1
0
 def test_recognise_no_faces(self):
     for img_fn in no_faces:
         # When there is no face, then this checks things don't explode when we give it a face bbox with no face
         bboxes = list(pre_calculated_faces.values())[0]
         logging.debug("Testing face recognition on file with no faces %s" % (img_fn,))
         result = recognise_face(self.stub, img_fn, bboxes)
         # Should still have the right number of responses, even if they are meaningless
         #print(np.array([f for f in result.identities[0].identity]))
         self.assertEqual(len(result.identities), len(bboxes))
Beispiel #2
0
 def test_align_no_faces(self):
     for img_fn in no_faces:
         # When there is no face, then this checks things don't explode when we give it a face bbox with no face
         bboxes = list(pre_calculated_faces.values())[0]
         logging.debug("Testing face alignment on file with no faces %s" %
                       (img_fn, ))
         result = align_face(self.stub, img_fn, source_bboxes=bboxes)
         # Should still have the right number of responses, even if they are meaningless
         self.assertEqual(len(result), len(bboxes))
         render_face_alignment_debug_image(self, img_fn, result)
 def test_get_landmarks_no_faces(self):
     for img_fn in no_faces:
         # When there is no face, then this checks things don't explode when we give it a face bbox with no face
         bboxes = list(pre_calculated_faces.values())[0]
         logging.debug("Testing face detect on file with no faces %s" % (img_fn,))
         result = get_face_landmarks(self.stub, img_fn, bboxes, model=self.algorithm)
         # Should still have the right number of responses, even if they are meaningless
         self.assertEqual(len(result.landmarked_faces), len(bboxes))
         for i in range(0, len(bboxes)):
             self.assertEqual(len(result.landmarked_faces[i].point), int(self.algorithm))
         render_face_landmarks_debug_image(self, img_fn, result)
Beispiel #4
0
 def test_recognise_no_faces(self):
     for img_fn in no_faces:
         # When there is no face, then this checks things don't explode when we give it a face bbox with no face
         bboxes = list(pre_calculated_faces.values())[0]
         logging.debug("Testing face recognition on file with no faces %s" %
                       (img_fn, ))
         boxes = [BoundingBox(**b) for b in bboxes]
         header = FaceRecognitionHeader(faces=boxes)
         with open(img_fn, 'rb') as infile:
             chunk = infile.read()
             request = FaceRecognitionRequest(
                 header=header, image_chunk=ImageRGB(content=chunk))
         result = self.stub.RecogniseFace(request)
         # Should still have the right number of responses, even if they are meaningless
         # print(np.array([f for f in result.identities[0].identity]))
         self.assertEqual(len(result.identities), len(bboxes))
 def test_align_no_faces(self):
     for img_fn in no_faces:
         # When there is no face, then this checks things don't explode when we give it a face bbox with no face
         bboxes = list(pre_calculated_faces.values())[0]
         logging.debug("Testing face alignment on file with no faces %s" %
                       (img_fn, ))
         boxes = [BoundingBox(**b) for b in bboxes]
         header = FaceAlignmentHeader(source_bboxes=boxes)
         with open(img_fn, 'rb') as infile:
             chunk = infile.read()
             request = FaceAlignmentRequest(
                 header=header, image_chunk=ImageRGB(content=chunk))
         result = self.stub.AlignFace(request)
         images = []
         for i in result.image_chunk:
             images.append(bytes(i.content))
         # Should still have the right number of responses, even if they are meaningless
         self.assertEqual(len(images), len(bboxes))
 def test_get_landmarks_no_faces(self):
     for img_fn in no_faces:
         # When there is no face, then this checks things don't explode when we give it a face bbox with no face
         bboxes = list(pre_calculated_faces.values())[0]
         logging.debug("Testing face detect on file with no faces %s" %
                       (img_fn, ))
         boxes = [BoundingBox(**b) for b in bboxes]
         header = FaceLandmarkHeader(
             landmark_model=self.algorithm,
             faces=FaceDetections(face_bbox=boxes))
         with open(img_fn, 'rb') as infile:
             chunk = infile.read()
             request = FaceLandmarkRequest(
                 header=header, image_chunk=ImageRGB(content=chunk))
         result = self.stub.GetLandmarks(request)
         # Should still have the right number of responses, even if they are meaningless
         self.assertEqual(len(result.landmarked_faces), len(bboxes))
         for i in range(0, len(bboxes)):
             self.assertEqual(len(result.landmarked_faces[i].point),
                              int(self.algorithm))