Reactor-Powered Face Swapping: Stable Diffusion

face swapping using reactor extension

When it comes to Face swapping with Reactor, its one of the best ways when using Stable diffusion. Well, we want to share our experience of why to chose Reactor over Roop. As usual one day, we noticed in the GitHub community that
they had discontinued the development because their developer had posted a problematic video into their documentation.

So, we were searching for some alternatives to it which
could be in the development stages so that whenever there are some issues
regarding it, we can easily ask the community to sort out the related problems.

 After diving into the
internet and checking out multiple Github repos we found one extension called “Reactor” which is built over the
Roop with extra modification plus multiple features added into it which can generate
similar results but with better experience.

Advantages of Reactor over Roop:

-It can
generate uncensored NSFW images which is restricted on Roop.

-it gives very fast and accurate results.

-Safetensors
Face models can be saved and loaded easily.

-Easily
compatible with Automatic1111, SD.Next, Cagliostro Colab UI, ComfyUI.

-This extension is API-supported and can be used via GET/POST request.

– It can be controlled
at the log-level system.

-This is packed with extra
features like Gender detection and better scaling features.

-Its
community is working to make it better than the older ones.

-We can do multiple
face-swapping features for the source and target images with just a single
selection.

Installation process:

1. Make sure you have already installed and set up Automatic 1111 and stable diffusion models. If not then we have already explained step by step tutorial on how to install Automatic 1111 with stable diffusion on a PC.
install Vscode for reactor

2. Now, we have to install Visual Studio by going to their official link.
vs code install for reactor

3. Click to open the Visual Studio installer to
download online and click continue to start the installation.

vs code install for reactor

4. Now, a new popup message will appear. Just uncheck these features which are 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++ 
-Visual Studio extension development 
Note: If you have these extensions already on your machine then you don’t need to follow this step.
vs code install for reactor

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 

reactor github repo

Now, copy the GitHub repo link of the Reactor extension.

https://github.com/Gourieff/sd-webui-reactor
 

installation for reactor extension

6. Open Automatic1111. Here, we need to
install the 
Reactor extension on our PC.
For that first, go
extension tab.
Then click on available and select on “
Install
from Url
” button.

Now,  paste the GitHub repo link for the Reactor extension that you copied earlier.  Just click on Install the button presented over to the left side of the dashboard. 

Restart Automatic1111

7. After getting installed, just Restart once again Automatic1111 to
get the effect. At the first stage of starting it will take some time to start because
it is used to download some prerequisites in the background.


Reactor extension installed


8. Next, go to the txt2img tab, and you will see
a new extension has been added called 
Reactor
as you see in the above-illustrated image.

Now, if you want to learn more about face swapping using Roop and never experienced then you should also experience that as well. With this, you get a clearer understanding of face swapping.


Using Reactor extension on txt2img:

After installation of the reactor extension into Automatic1111, make sure to check the enable box to activate the Reactor extension.

reactor multiple face swapping



Let’s say you have a source image of multiple faces. So, we will count from the left-hand side of the image starting with 0 as the index.

For illustration, we have used an image with four people. So we will count from left starting from 0,1,2,3. Similarly, for the targeted image we can use an image of multiple faces and the count starts from 0.

Now, if we want to swap faces with all the people of the source image with the targeted image then into the Comma separated face number input box of the source image we have to put 0,1,2,3 on the Comma separated face number input box of target image.

We have to put the single number 0 (if you have single face-targeted image), and if we want to use multiple targeted images (let’s say 4 faces in an image) then we have to put 0,1,2,3.

reactor face swap gender selection


Now let’s try for gender-specific with single-face swapping. For illustration, we are using the face of Megan Fox.

Reactor provides an extra feature for gender detection which is unable in Roop extension which you can select as your requirement.

reactor face swapping target image

For the target image, we are using the image with a single face. This has been generated using txt2img.


reactor face swapping process


Select the txt2img feature for working into this method, enable the Reactor extension, and click the Generate button.

reactor face swapping complete


And here is the fantastic result. You can see how the Japanese girl’s face has been swapped with the Megan fox’s face instantly.

Note: For better results, use the similar face shape and structure with the source and the target image.



Using Reactor extension on img2img:

We can use reactor extension on image to image or on inpainting mode as well.

reactor face swapping drag and drop image

1. Click on the “img2img” tab
presented over the left side of the Automatic1111 dashboard.


reactor face swapping target image

2. Now,
just drag and drop the image you want to do with face swapping. For illustration, we are using a Japanese girl image.

reactor face swapping setting dimensions


3. After dropping the image click the button to set the same dimension and
pixel of the image with the source and targeted image. Alternatively, you can set it with manual
settings as well.

Click on Reactor Extension
presented at the lower left corner of the Automatic1111 dashboard.


reactor face swapping drag and drop image


4. Now, drag and drop the image which you want to do a face swap with.


reactor face swap gender selection


5. Press on the Enable button of the Reactor extension if not yet, and select either of the options that are Codeformer or GFPGAN. ( Here what we experienced is that Codeformer gives much better results)


reactor face swap setting denoising


6. Adjust the image height and Width. Set the Denoising strength to 0
(this is important if you are working on the face)
.

And the other image, we have chosen Megan Fox’s face image to swap with.

At last click on Generate button.

reactor face swap process completed


Look
at the result after swapping. The face of the Japanese girl has been replaced with Megan Fox’s face. 

So, the most important thing to note is that if you want the best results then it’s recommended to choose the same face structure while swapping the face swap.

Conclusion:

So, we have concluded that Reactor is a good alternative to Roop which
provides many extra functionalities which increase productivity in the
field of image generation.

Not only this it’s an uncensored model that gives overall control to
create an art that gives more flexibility to think beyond the limit.