roop icon indicating copy to clipboard operation
roop copied to clipboard

Add option to process all detected faces within a frame

Open CeeBeeEh opened this issue 2 years ago • 11 comments

I've added the ability to swap all of the faces in a frame. This is useful of you want to face swap a video with multiple people within it. It adds the ability to edit the resulting video in a NLE without having to preprocess the video to isolate each face.

CeeBeeEh avatar May 31 '23 17:05 CeeBeeEh

A mind blowing addition for VR videos! We have to check your branch before merging it.

henryruhs avatar May 31 '23 18:05 henryruhs

I guess the use case works for VR. My intention was to faceswap a longer video (like a movie) and then isolate the swapped face in an editor. Instead of isolating first.

My reasoning is to do multiple faces and then editing together at once.

CeeBeeEh avatar May 31 '23 18:05 CeeBeeEh

Please resolve the conflicts... can you provide an example file?

Now looking into your branch

henryruhs avatar May 31 '23 20:05 henryruhs

@henryruhs conflicts resolved

CeeBeeEh avatar May 31 '23 21:05 CeeBeeEh

I don't want to be too picky but please align the checkboxes... they look wild :D

henryruhs avatar May 31 '23 22:05 henryruhs

@henryruhs It looks good on my end. I'm guessing you're using Windows? Python on Windows has a lot of inconsistencies when compared to all other platforms. I can try to make it look consistent on Windows, but I don't have a Windows system to test with.

roop_alignment

CeeBeeEh avatar May 31 '23 23:05 CeeBeeEh

@henryruhs I merged the change that "should" fix it, if not then I don't have a way to test the appearance and can't fix the UI elements on my end

CeeBeeEh avatar May 31 '23 23:05 CeeBeeEh

SimSwap provides a method to identify different faces (creating an identity vector for each face) and use a method to match a face to another face within an identity threshold. @CeeBeeEh Could you please explain what do you mean by VR Mode and NLE references in your post?

Mayorc1978 avatar Jun 01 '23 00:06 Mayorc1978

@Mayorc1978 I didn't set the title to VR. I believe it was done to match up with this enhancement request #178

As for the NLE comment, I realize after the fact that my comment is confusing. I simply meant it would make putting together a video with multiple swaps simpler by editing together the resulting videos in something like Kdenlive or After Effects.

CeeBeeEh avatar Jun 01 '23 00:06 CeeBeeEh

Okay, so there was a misunderstanding? Can you please provide an example before and after video?

Merge conflicts appear again... sorry

henryruhs avatar Jun 01 '23 15:06 henryruhs

@henryruhs I resolved the conflicts and I think I found a solution for the checkbox alignment issue that should work across all platforms.

As for a before/after video, it would just be all the faces in a video being swapped.

The idea is this: Souce: video with multiple people, I want to swap each one to a different person (let's say three individuals)

I have two options: Edit the source video three separate times to mask out all faces except for one person. Run Roop for each video/face. Edit the results back into a single video for desired result.

Better (IMO) option: Swap all the faces in source video. So run the video for each target face. Pull all the results into editor and mask out each face I want in the final video.

Basically this merge gives two options: swap all faces just for a fun video, or simpler workflow to do multi-person face swaps.

Edit: sorry about the odd commits, I initially messed up the merge on my local dev system.

CeeBeeEh avatar Jun 01 '23 17:06 CeeBeeEh

Thanks, I made a proper code review... hopefully not too strict for a POC but we like to move forward to clean code

set target branch to next

henryruhs avatar Jun 01 '23 18:06 henryruhs

"set target branch to next"

Done

CeeBeeEh avatar Jun 01 '23 18:06 CeeBeeEh

Made the requested changes. I went with "get_face_single" and "get_face_many" to make it consistent and to read a bit better. I also refactored the swapper.py file to split the code into smaller functions and to create fewer copies of the frame object.

CeeBeeEh avatar Jun 01 '23 19:06 CeeBeeEh

is this working now? multi face support is enabled?

IIIIIIIllllllllIIIII avatar Jun 01 '23 19:06 IIIIIIIllllllllIIIII

Now that I tested it on the next branch and made sure this is working, I have to give credit to @CeeBeeEh for this addition. Great job, more PRs like this are welcome. Thanks for taking the extra mile as of the code reviews.

henryruhs avatar Jun 01 '23 20:06 henryruhs

If video contains for example man and woman faces and I wanna to replace woman's only is it possible for now?

suphamster avatar Jun 03 '23 12:06 suphamster