1adrianb / face-alignment

:fire: 2D and 3D Face alignment library build using pytorch
https://www.adrianbulat.com
BSD 3-Clause "New" or "Revised" License
7.03k stars 1.34k forks source link

Landmarks detection failure with some faces #220

Closed rakadambi closed 3 years ago

rakadambi commented 3 years ago

I am having issue with landmark detection with couple of faces. These are the faces that were generated from one of the 3d face reconstruction models. I am using standard SFD face detector. I think the error seems to be at the detector from the logs:

The image is:

matched_frame_lm

The error is as follows:

====================================================================== ERROR: test_predict_points (main.Tester)

Traceback (most recent call last): File "facealignment_test.py", line 8, in test_predict_points fa.get_landmarks('assets/matched_frame_lm.png') File "/home/aditya/Python_code_learning/dev/kython_env/lib/python3.7/site-packages/face_alignment/api.py", line 141, in get_landmarks return self.get_landmarks_from_image(image_or_path, detected_faces) File "/home/aditya/Python_code_learning/dev/kython_env/lib/python3.7/site-packages/face_alignment/api.py", line 171, in get_landmarks_from_image detected_faces = self.face_detector.detect_from_image(image[..., ::-1].copy()) File "/home/aditya/Python_code_learning/dev/kython_env/lib/python3.7/site-packages/face_alignment/detection/sfd/sfd_detector.py", line 51, in detect_from_image bboxlist = detect(self.face_detector, image, device=self.device) File "/home/aditya/Python_code_learning/dev/kython_env/lib/python3.7/site-packages/face_alignment/detection/sfd/detect.py", line 20, in detect img = img - np.array([104, 117, 123]) ValueError: operands could not be broadcast together with shapes (1024,1024,4) (3,)

Any ideas?

rakadambi commented 3 years ago

The issue was that the image had alpha channel. Reading without alpha channel fixes it. Closing this.