Gourieff / sd-webui-reactor

Fast and Simple Face Swap Extension for StableDiffusion WebUI (A1111 SD WebUI, SD WebUI Forge, SD.Next, Cagliostro)
GNU Affero General Public License v3.0
2.46k stars 263 forks source link

Identify and Tag Faces prior to Swap Feature #193

Open drdancm opened 10 months ago

drdancm commented 10 months ago

Feature description

There are currently a number of Image Manager Programs (like old Picasa from Google) that once you label a face (with maybe 5 or 10 instances) and give it it a name it will find and tag photos where that face appears, when it is alone or in a photo of a group of people. I wouldn't be surprised if one can find a program that does this right here on Github.

If such a process could be done prior to Face Swap (FSw), then it would make it far simpler and quicker to do the FSw when dealing with a group photo.

As of now both the Gender and Age guessing often gets things wrong, so although that would really help batch processing in many situations, it cannot be relied upon.

With a Pre-ID processing things could really work efficiently.

For example using 5-10 images of George to get the Pre-ID, we could then have George's face replaced in batch of 50 or a 100 photos which have 1 to 5 or even more other people. Running one or more Pre-IDs of other people in the group photos would even decrease the number of mis-identifications. I hope this example makes the suggestion clear.

Just a suggestion because as far as I know no Face Swapping App does anything like this right now.

drdancm commented 10 months ago

A quick search shows: https://github.com/topics/face-recognition-python

Here is one with a live demo that looks interesting: https://github.com/kby-ai/FaceRecognition-Windows https://web.kby-ai.com/

DRFR33MAN24 commented 10 months ago

This is similar to my feature request on reactor-comfyui extension: https://github.com/Gourieff/comfyui-reactor-node/discussions/104 also I think reface.ai gives you the ability to choose which face in a given video or sequence you want to map to which source image before doing the swapping.

Can't we simply transform the image of the target face to latent space and calculate the similarities with detected faces before swap ?

Gourieff commented 9 months ago

Interesting idea, but rather complicated to implement We need to store detected faces somehow (DB) and it will also reduce performance because we need to match a target face (or faces) from a frame with DB every time we start the processing of a new frame...

drdancm commented 9 months ago

Of course the Swap would slow down with the proposed identification, but if it would be an option turned on with a button, you would only use it when absolutely necessary on a large number of images run in batch mode. As for the amount of work needed to accomplish this.... It was just an idea we can certainly live without it, but thanks for responding in any case.