Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple faces in source or target video #26

Open
BenjaminChua opened this issue Nov 3, 2020 · 4 comments
Open

Multiple faces in source or target video #26

BenjaminChua opened this issue Nov 3, 2020 · 4 comments

Comments

@BenjaminChua
Copy link

BenjaminChua commented Nov 3, 2020

My target video (or source for that matter) has 2 persons inside. I have checked that running the scripts would swap on only 1 person's face and in this case, it was the wrong person. May I ask what is the best way to filter out unwanted faces and only swap the chosen person's face?

@MarekKowalski
Copy link
Owner

The app should work fine for multiple faces in the video where the face are being swapped. If it does not, it may mean that one face is not detected. Can you take a look at the length of shapes2D in line 49 of zad2.py? If the result is 1 then one face was not detected. Perhaps it's not very well visible or far from frontal in the video?

@BenjaminChua
Copy link
Author

I think zad2.py does capture both faces. However, I would like to choose only 1 face to be swapped. May I ask how I can approach this task?

@MarekKowalski
Copy link
Owner

MarekKowalski commented Nov 10, 2020

If you want something simple, then you can choose the face you want using some conditions on the locations of the face keypoints. You can, for example, do something like this in zad2.py line 49:
face_centroids = np.mean(shapes2D, axis=2)
leftmost_face_idx = np.argmin(shapes2D[:, 0])
shapes2D = [shapes2D[leftmost_face_idx]]
This would only select the face that is furthest on the left. Keep in mind I did not test this code so there might be some small error in it.

@BenjaminChua
Copy link
Author

Thanks for your help. I believe faceswap.py in faceforensics repo does something similar for selecting a face if multiple were detected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants