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

I'm having a problem with overlapping faces. #21

Open
mbeytekin opened this issue Jan 30, 2023 · 3 comments
Open

I'm having a problem with overlapping faces. #21

mbeytekin opened this issue Jan 30, 2023 · 3 comments

Comments

@mbeytekin
Copy link

mbeytekin commented Jan 30, 2023

swap_family-of-four-7101-a234e9249b2c7223d4e4d8cd9432f9e9@1x

I guess to fix this I have to merge all the found faces separately. Can you help with this?

By the way, the app already finds softmasks of faces. After all, isn't it better to use them when merging faces into the picture?

@mbeytekin
Copy link
Author

I made some changes in simswap.py and got better results:
soft_face_mask, _ = self.smooth_mask(face_mask)
img_white=soft_face_mask*255.
# Only take face area from the swapped image
swapped_img = swapped_img * soft_face_mask
swap_1280px-Happy_family_(1)

However, in some cases, overlaps can occur.
swap_family-of-four-7101-a234e9249b2c7223d4e4d8cd9432f9e9@1x

swap_happy-families-couple700x400

@mike9251
Copy link
Owner

Hey @mbeytekin , you can blend faces separately. At the end of the simswap.py file do not sum img_mask and target_image, instead blend each crop independently.

I think a better solution would be computing intersection between crops and compensating it during the blend step. I'll take a look later.

@mike9251
Copy link
Owner

Fixed the issue with the latest update

before

swap_before

After
swap_fix

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