faceswap icon indicating copy to clipboard operation
faceswap copied to clipboard

Face on angles >180 degrees not recognized on extraction

Open babilio opened this issue 8 years ago • 4 comments

Hi guys thanks for the amazing work here!

I have been following the landmark detection dialogue #187 and have tried both hog and cnn with both face-alignment and face_recognition. I got face-alignment with cnn working great, with pytorch on win10 now. However, I noticed that none of the above are able to reliably able to identify faces where the face is pointing downwards, for example with the forehead pointing from 6 to 9 o'clock.

I think all these algorithms tend to look for eyes being above the level of the mouth.

For example [Image Removed) this image would not be detected and extracted by hog or cnn in face-alignment or face_recognition.

However by rotating it 90 deg to the right, so that the forehead is pointing up, makes it extracted.

Would it be possible to have an argument set to resend the image for alignment but rotated if it was not caught the first time?

I am ok with python and novice with git but could maybe even give it a try if someone points me to where the frame is passed for extraction.

Thanks!

babilio avatar Feb 15 '18 04:02 babilio

I am pretty newbish with coding and will try anyway, I find this in extract.py

def handleImage(self, filename):
    count = 0

    image = cv2.imread(filename)
    faces = self.get_faces(image)
    rvals = []
    for idx, face in faces:
        count = idx

        resized_image = self.extractor.extract(image, face, 256)
        output_file = get_folder(self.output_dir) / Path(filename).stem
        cv2.imwrite(str(output_file) + str(idx) + Path(filename).suffix, resized_image)
        f = {
            "x": face.x,
            "w": face.w,
            "y": face.y,
            "h": face.h,
            "landmarksXY": face.landmarksAsXY()
        }
        rvals.append(f)

also rotating from https://docs.opencv.org/3.0-beta/doc/py_tutorials/py_imgproc/py_geometric_transformations/py_geometric_transformations.html#geometric-transformations will report back if I found a solution.

Deadfishzzway avatar Feb 17 '18 19:02 Deadfishzzway

I'm facing the same issue. Any ideas? I found out that if the image gets rotated so that the forehead is facing upwards, detection works. So maybe if no face gets detected, the script should try again after rotating the image.

ppmdo avatar Feb 20 '18 17:02 ppmdo

I've submitted a PR for this. Feel free to test. #253

torzdf avatar Mar 08 '18 18:03 torzdf

This issue can be closed.

torzdf avatar Mar 11 '18 16:03 torzdf