faceswap icon indicating copy to clipboard operation
faceswap copied to clipboard

When 2 faces in scene, some faces can't be recognized

Open modelsex opened this issue 8 years ago • 13 comments

*Compare test again with latest code! *Original test source has more than 1900 pics, about 10% faces are missing after extracted, select 100 pics as typical example for compare. *Test files [Link Removed]

Expected behavior

Not sure, limitation ? or possible to improve ?

Actual behavior

For female face in test file: FakeApp1.1 extract rate is 90/100 faceswap -D all -r on extract rate is 91/100

[Image Removed]

*Some test pics with 2 faces in scene, but only 1 face be recognized, like dilif0001 -> dilif0003 *Face extract is not stable even use rotate, in this case I get a lot of interval frame recognized. For example, female face be recognized in 0004, but not in 0005, normal in 0006, failed again in 0007, etc. But if compare each frame, no big gap in there.

Steps to reproduce

python faceswap.py extract -i D:/project3/test/ -o D:/project3/test/output/ -D all -r on

Other relevant information

Operating system and version: Windows, macOS, Linux Windows10 Python3.6.4 CUDA9.0 dlib 19.9 The others env same as requirements-gpu-python36-cuda9.txt GTX1080 8GB

modelsex avatar Mar 24 '18 18:03 modelsex

I would guess that is because that face is rotated 90 degrees. At current implementation rotation only kicks in if it doesn't find a face, but it already found the male face which is upright.

There's some work going on with rotations at the moment, if this isn't covered, I may look to extend functionality to capture all faces. In the meantime, using the filter flag may help.

torzdf avatar Mar 24 '18 18:03 torzdf

The only problem is that the new rotations will either make everything take 4x as long (force check all 90 degree angles) or require attention to specify the angle specifically.

Ideally, I'd like a super fast face detection that may not include landmarks to give a range and angle to feed into a proper face recognition with landmarks to ensure we find all faces.

bryanlyon avatar Mar 24 '18 19:03 bryanlyon

@modelsex how much vram you have?

iperov avatar Mar 26 '18 06:03 iperov

@iperov I test with GTX1080 8GB

modelsex avatar Mar 26 '18 06:03 modelsex

@modelsex try increase

scale_to in FaceLandmarksExtractor.py

#scale_to=2048 with dlib upsamples=0 for 3GB VRAM Windows 10 users
def extract(input_image, detector, verbose, all_faces=True, input_is_predetected_face=False, scale_to=2048):

iperov avatar Mar 26 '18 06:03 iperov

we can fix subj, if make extracting with 2 passes. First pass detecting rects by dlib with higher scale_to value. Save rects to temp.json. Keras model never loaded. Second pass detect landmarks from rect in temp.json by keras model, dlib never loaded.

iperov avatar Mar 26 '18 07:03 iperov

Current scale_to=2048 optimized to load both dlib and keras model for 3GB Vram.

iperov avatar Mar 26 '18 07:03 iperov

@iperov Thanks a lot for your guidance, I have tired increase or decrease scale_to, also tired re-scale original 960x544 to 1280x720, seem don't work to improve.

modelsex avatar Mar 26 '18 10:03 modelsex

faceswap uses same dlib cnn face rects detector as fakeapp, so differences only in params.

iperov avatar Mar 26 '18 12:03 iperov

or fakeapp do something else with image :D

iperov avatar Mar 26 '18 12:03 iperov

@modelsex also try latest commit

iperov avatar Mar 26 '18 14:03 iperov

Fixed on latest update, not found side effect issue except a little slow on no face scene. THANKS ALL !!! This issue can be closed.

modelsex avatar Mar 26 '18 15:03 modelsex

@modelsex then close it

iperov avatar Mar 26 '18 17:03 iperov