Face Swapping with Roop Extension in Automatic1111

 

face sapping using roop extension

The image generation becomes so easy after the arrival of Stability.ai. One of the great features you have ever heard of face swapping in stable diffusion using Roop extension.

Yes! This can be easily achieved with just a few clicks using the Roop extension which you can use with stable diffusion with Automatic1111. The cool thing about this software is you don't need to accumulate or train huge datasets.

Here, we will help you how to do a face swap. For the tutorial, we are using Automatic 1111 with stable diffusion. But all the steps will be the same for other applications as well.


Installation process:

1. first of all, make sure you have already installed and set up Automatic 1111 and stable diffusion models

face swapping using roop extension

2. Now, we have to install Visual Studio by going to their official link.


face swapping using roop extension

3. Click to open the Visual Studio online installer(wherever the installation .exe downloaded) to download online and click continue to start the installation.


face swapping using roop extension installation

4. Now, a new popup message will appear. Just uncheck these features which  is not required in stable diffusion face swapping (Uncheck): 
-Asp.net web development
-Azure development
-.NET desktop development

And check these options:
-Python dev.,
-Desktop dev. For C++ and
-Visual Studio extension development 

If you have these extensions already on your machine then you don’t need to follow this step.                                                                                                             

face swapping using roop extension installation


5. By pressing the window key + R and type cmd to open and Run this command on your command prompt :

pip install insightface==0.7.3 

face swapping using roop extension installation


6. Now, open Automatic 1111. Here, we need to install the Roop extension on our PC. For that first go Extension tab. Then click on Available and select on “Load from” button.


face swapping using roop extension installation


7. On the search box type “Roop” to get the roop extension on the list. Just click on Install the button presented over to the right side of the list. The installation process for the roop extension will be processed. The installation will be according to your network speed.


face swapping using roop extension installation


8. After getting installed, just restart again Automatic 1111 to get the changes into effect. At the first stage of starting it will take some time to start.


face swapping using roop extension installation


9. Next, go to the text to the image tab, and you will see a new extension has been added called Roop as you are seeing in the above illustrated image.

Using Roop extension with image generation:

Using Roop extension on image to image or on inpainting mode as well, but here we have used image to image to make you understand as simple as it is.


Swapping Face with single subject on image:

face swapping with roop extension single subject

1. Now, just drag and drop the image you want to do with face swapping.


2. Click on the “img2img” tab presented over the left side of the Automatic 1111 dashboard.



face swapping with roop extension single subject

3. Now, press the "Interrogate Clip" button presented on the top of the dashboard beside the generate button.


face swapping with roop extension single subject

4. Click on Roop Extension presented at the lower left corner of the Automatic 1111 dashboard.


face swapping with roop extension single subject


5. Now, drag and drop the image which you want to do a face swap with. 
Here, we have chosen Megan fox's face image. You can choose any image as your requirement.


face swapping with roop extension single subject

6. Press on Enable button and select either of the options, CodeFormer or GFPGAN.


face swapping with roop extension single subject


7. Adjust the image height and Width. Set the Denoising strength to 0 or 0.1 approx (this is important if you don’t want your actual output image to get impact) At last click on Generate button.



face swapping with roop extension single subject

Look at the result after swapping. The face of celebrity face has been replaced with Megan Fox's face.

Quite impressive! Right?

Sometimes when we generate images using Stable Diffusion it doesn’t generate clean faces. So, here we can use Roop extension face swapping as well. 


Swapping Face with single subject on image:

Now, if you have multiple faces in an image and you want to replace a targeted face then yes, you can do that as well.

To do that first of all go to that installed folder of the Stable Diffusion extensions folder.

face swapping with roop extension single subject

Search for “sd-webui-roop” folder in the Stable diffusion extension folder. Copy this folder and paste it to make a duplicate copy of it and rename it to something different as per your requirements.

In our case, we renamed it to “sd-webui-roop2”. Now just restart the Automatic 1111 to take effect.

 Now you will see two Roop extensions on the extensions tab of Automatic 1111. You can use it first for single-face swapping and another new one for multiple-face swapping.


face swapping with roop extension multiple subject

We have generated the above image. From the left to right direction, we count the subject's face.

So, here you can observe in the above image that the second woman’s eye is not looking good and looks like a ghostly image. So, here we will use this multiple-face-swapping technique to replace the second woman's face.


For the new face, we are using Megan Fox's image.

face swapping with roop extension single subject

1. Now, just drag and drop the image into the Roop extension place and click on Enable.

2. Select the number (Starting from 0) of the face number you want to replace with.


3. Like in our case we want to select the first subject (first woman face). So into the comma-separated face number we have set the value to 0 and click on Generate.

 

And this is the generated output. Now you can see how intelligently it has replaced that first woman’s face with the new face. The refinement and detailing are quite satisfactory.


face swapping with roop extension single subject

1. Now, let’s say we want to work on the second target subject. So into the
Comma separated face number
section we have set the value to 1 and clicked on Generate.



face swapping with roop extension multiple subject

The second face was also successfully swapped.


2. Again, let’s say we want to work on both the subjects. So into the
Comma separated face number
section we have set the value to 0,1 and clicked on Generate.


face swapping with roop extension multiple subject

And here is the output of both subject's faces got swapped.


Unfortunately, due to some malpractices and uncensored issues, the Roop community has discontinued the support. We may see some good results if they try to work more on this model.

 

Conclusion:

The only problem with this extension is that sometimes it doesn’t work perfectly if you try to use a face that does not have the same face shape as the targeted one.

But, in the above tutorial, we used different face shapes for swapping and the generated output is not that bad which seems like the model trained very much well.