Convert MASKED FACES ONLY with Alpha ?

Converting source frames into swapped frames
Forum rules
Read the FAQs and search the forum before posting a new topic.

Please mark any answers that fixed your problems so others can find the solutions.
Post Reply
User avatar
Dan
Posts: 17
Joined: Sat Oct 12, 2019 1:24 am
Has thanked: 9 times
Been thanked: 1 time

Convert MASKED FACES ONLY with Alpha ?

Post by Dan » Sun Nov 17, 2019 12:52 pm

Hi All,

I was wondering, about something:
After I aligned faces, they also have their mask around the face and everything.

Can I Convert ONLY these Masked Faces as PNG sequence or Video with their Alpha?
The reason is that I could use the MASKED FACES in other software such as After Effects without Masking the faces by myself manually which take lots of time.

If this is possible in FaceSwap, what are the steps I need to do?
please explain step-by-step since I'm still new to FaceSwap and it will be very helpful to follow along.

Thanks ahead!

User avatar
kilroythethird
Posts: 20
Joined: Fri Jul 12, 2019 11:35 pm
Answers: 1
Has thanked: 2 times
Been thanked: 9 times

Re: Convert MASKED FACES ONLY with Alpha ?

Post by kilroythethird » Sun Nov 17, 2019 4:43 pm

Go to Settings->Configure Convert plugins->Writer->Opencv and check "Draw Transparent".
Then just convert using the opencv writer.
that amd guy

User avatar
Dan
Posts: 17
Joined: Sat Oct 12, 2019 1:24 am
Has thanked: 9 times
Been thanked: 1 time

Re: Convert MASKED FACES ONLY with Alpha ?

Post by Dan » Sun Nov 17, 2019 5:28 pm

kilroythethird wrote:
Sun Nov 17, 2019 4:43 pm
Go to Settings->Configure Convert plugins->Writer->Opencv and check "Draw Transparent".
Then just convert using the opencv writer.
Thanks for the reply, are you sure it should work without training, only for converting faces?
because I tried that, but it's not working for me.

I put these paths:
Input Dir (the extruded aligned faces that I want to convert to PNG with Mask)
Output Dir (the place I want the final result after converting)
Alignments (the alignments that created when I Extract the faces from the video file)
Model Dir (I don't even use a Model ...but I put it anyway)

I get "No alignment found for" then list of all the images...
and It doesn't make any sense since I obviously CHOSE the Alignments Path and selected that ONLY one file.

Code: Select all

...
No alignment found for Image_000034.png, skipping
No alignment found for Image_000035.png, skipping
No alignment found for Image_000036.png, skipping

and so on... for ALL THE IMAGES

Process exited.
What am I missing?

User avatar
kilroythethird
Posts: 20
Joined: Fri Jul 12, 2019 11:35 pm
Answers: 1
Has thanked: 2 times
Been thanked: 9 times

Re: Convert MASKED FACES ONLY with Alpha ?

Post by kilroythethird » Sun Nov 17, 2019 5:48 pm

Looks like i misunderstood your question, sorry.
What i described above would require training and would produce images where everything except the converted face would be transparent.

Only using the detector/alignment part of faceswap and export the masked original faces is not supported as far as i know.
It would be kinda easy to write a script to do this for you, but that wouldn't be part of faceswap and not supported.
But if that's what you want to do i could write you a little script to extract the masked faces from the source data using the alignment file the coming days.
that amd guy

User avatar
Dan
Posts: 17
Joined: Sat Oct 12, 2019 1:24 am
Has thanked: 9 times
Been thanked: 1 time

Re: Convert MASKED FACES ONLY with Alpha ?

Post by Dan » Sun Nov 17, 2019 5:53 pm

Thanks for your detailed reply,

Unfortunately I couldn't find anything that does that part like FaceSwap (without training).
Maybe there is, because it's like Half-Job of what FaceSwap does but it would probably be hard or impossible to find and it probably won't be a user-friendly or using GUI like FaceSwap so I won't be able to use such tool if it's form github or anything like that.

Bummer... I wish we could have this features just for the Alignment + Mask + Render the PNG with Transparent to use on After Effects.

User avatar
Dan
Posts: 17
Joined: Sat Oct 12, 2019 1:24 am
Has thanked: 9 times
Been thanked: 1 time

Re: Convert MASKED FACES ONLY with Alpha ?

Post by Dan » Sun Nov 17, 2019 5:55 pm

kilroythethird wrote:
Sun Nov 17, 2019 5:48 pm
But if that's what you want to do i could write you a little script to extract the masked faces from the source data using the alignment file the coming days.
If you can do that, would it be easy to run? since it won't use a GUI / Buttons
I'm only guessing I have no clue how it works, but I'm curious and appreciate your time!

User avatar
kilroythethird
Posts: 20
Joined: Fri Jul 12, 2019 11:35 pm
Answers: 1
Has thanked: 2 times
Been thanked: 9 times

Re: Convert MASKED FACES ONLY with Alpha ?

Post by kilroythethird » Sun Nov 17, 2019 8:06 pm

Its not that hard to use.

If you can post the content of your "faceswap_win_launcher.bat" (if you are on windows) or "faceswap_gui_launcher.sh" (linux) i can give you a file you'd only need to click and follow the dialog :)

I am currently throwing together the script. Just to be sure: you want output like this ? Or only the mask ?
match_000027.png
match_000027.png (127.6 KiB) Viewed 163 times
that amd guy

User avatar
Dan
Posts: 17
Joined: Sat Oct 12, 2019 1:24 am
Has thanked: 9 times
Been thanked: 1 time

Re: Convert MASKED FACES ONLY with Alpha ?

Post by Dan » Sun Nov 17, 2019 8:22 pm

Nice!!!
Exactly like this, but the background will be transparent right? (not white or colored)

Also, will I be able to control the blur amount on the edges of the mask via FaceSwap itself before using your script?
or changing the blur amount via the script itself?

Just wondering, but sounds like you got the idea, thank you for taking the time to do that!

User avatar
kilroythethird
Posts: 20
Joined: Fri Jul 12, 2019 11:35 pm
Answers: 1
Has thanked: 2 times
Been thanked: 9 times

Re: Convert MASKED FACES ONLY with Alpha ?

Post by kilroythethird » Sun Nov 17, 2019 10:25 pm

Yes the background is transparent.

Download this file ( https://gist.githubusercontent.com/kilr ... _masked.py ) to your faceswap directory.

Just run it inside your anaconda environment.
If you don't know how to do this please post the content of the "faceswap_win_launcher.bat" (if you are on windows) or "faceswap_gui_launcher.sh" (if you are on linux) from your faceswap folder and i can give you a batch script you can click.
In the future that might be easier but for now that is how it is.

The tool needs:
- A folder with your source frames or a video as input.
- The path to the alignment (.fsa) file you got from extracting faces for the input frames. Make sure you are using a mask for the extraction ;)
- The path you want the masked frames to be saved in.
- OPTIONAL the blur amount
that amd guy

User avatar
Dan
Posts: 17
Joined: Sat Oct 12, 2019 1:24 am
Has thanked: 9 times
Been thanked: 1 time

Re: Convert MASKED FACES ONLY with Alpha ?

Post by Dan » Sun Nov 17, 2019 10:34 pm

Hi Thank you for dedicating your time to make this script, I appreciate it! ;)

Unfortunately I have no clue what Anaconda Environment is, I use Windows 10.
I don't know exactly what do you mean by:
If you don't know how to do this please post the content of the "faceswap_win_launcher.bat" (if you are on windows)
So I guess I can't run it by rename it to .bat since it's a Python script? (just guessing, I'm clueless)

By reading the options (tools) you wrote, it sounds really cool, I'm curious to test it, please let me know if I can somehow use it as .bat file or something?

Thanks ahead, You ROCKS!

User avatar
kilroythethird
Posts: 20
Joined: Fri Jul 12, 2019 11:35 pm
Answers: 1
Has thanked: 2 times
Been thanked: 9 times

Re: Convert MASKED FACES ONLY with Alpha ?

Post by kilroythethird » Sun Nov 17, 2019 10:42 pm

Happy to help.

In the folder you have faceswap installed in should be a file called "faceswap_win_launcher.bat".
Please open this with notepad or any other text editor and paste the content in this thread (or send it to me via discord if you want).

Additionally you will need to download the file i linked above to the same folder the "faceswap_win_launcher.bat" file is in.
that amd guy

User avatar
Dan
Posts: 17
Joined: Sat Oct 12, 2019 1:24 am
Has thanked: 9 times
Been thanked: 1 time

Re: Convert MASKED FACES ONLY with Alpha ?

Post by Dan » Sun Nov 17, 2019 10:54 pm

ohhh... I see, there is the path to the installation on my Windows OS.
so you need to put this path manually on the script?

I wonder if there is another way if I'll install to another machine, different path.

How do I found you on discord, maybe it will be easier :)

User avatar
kilroythethird
Posts: 20
Joined: Fri Jul 12, 2019 11:35 pm
Answers: 1
Has thanked: 2 times
Been thanked: 9 times

Re: Convert MASKED FACES ONLY with Alpha ?

Post by kilroythethird » Sun Nov 17, 2019 11:07 pm

Join our server, we have cookies. https://discordapp.com/invite/FC54sYg

Just check the #general chat fe: you find me in the Primary dev group in the user list.
that amd guy

Post Reply