|

How To Face Swap in Stable Diffusion (Using ReActor)

Do you want to swap your face into images of superheroes? Or do you just want to make funny face swaps with your best friend for their birthday? 

Whatever the case may be, this guide will be your holy grail. In this guide, I’ll teach you how to face swap in Stable Diffusion. With this guide, you’ll be able to do super realistic face swaps of any face you want. 

That being said, let’s get started. 

Note: Before we begin, I want to point out that the techniques shared in this guide are powerful and allow face swapping in a matter of clicks. That being said, we do not recommend or encourage the use of real-life people/celebrity faces to create any inappropriate or demeaning images.

How To Face Swap In Stable Diffusion 

There are many methods for swapping faces in Stable Diffusion such as using ControlNet, LoRA models, random names, and using extensions. 

In fact, I’ve covered most of these methods in this guide to showcase how you can generate consistent faces in Stable Diffusion. 

But for swapping faces, I recommend using the ReActor extension which lets you quickly swap faces in Stable Diffusion. 

There’s another similar extension for face swapping called Roop but that has now been discontinued and ReActor is the best option out there now. 


So, let’s see how to face swap in Sable Diffusion using the ReActor extension: 

Install ReActor Extension 

First, we’ll have to install the ReActor extension in Stable Diffusion. The extension is available for both Automatic1111 and ComfyUI

For this guide, I’ll be using Automatic1111 as it’s the most preferred Stable Diffusion WebUI. 

Step 1. In your Automatic1111 WebUI, go to Extensions > Install from URL

Automatic1111 - Install Extension from URL

Enter this URL – https://github.com/Gourieff/sd-webui-reactor

Step 2. Click on the Install button and the ReActor extension will be installed. Once it’s successfully installed, close your webui-user.bat and restart it to restart Stable Diffusion. 

If you’re facing any problems installing ReActor, make sure you have Visual Studio 2022 or VS C++ Build Tools installed on your computer. 

I had a few errors installing this extension so I recommend checking out their installation guide which is quite extensive and also has some troubleshooting for some common errors people face during installation. 

Set Up ReActor Extension 

Once ReActor is installed, we’ll now set it up to begin the face swapping process. 

Step 3. In Automatic1111, go to the txt2img tab and you’ll find a new ReActor tab. Click on the checkbox to enable the extension. 

Automatic1111 - ReActor Extension

Step 4. Now, upload the image of the face you want to swap. 

Automatic1111 - ReActor Upload Face

To get the most accurate face swap, make sure the face image you upload is clear and close up. 

Step 5. In the ReActor extension settings, check the Face Mask Correction option. 

Face Swap In Stable Diffusion

Swap Your Face

Now, we’ll write a prompt to generate a new image with your uploaded face on it. 

Step 6. In the prompt box, write a positive and a negative prompt for your image. 

Here are the positive and negative prompts I’m using: 

Positive Prompt: 

portrait photo of 1girl, closeup, upper body, night city, outdoors, bokeh, blonde hair

Negative Prompt: 

blurry, deformed, text, ugly, cartoon, illustration

Step 7. In the image generation settings, set the following settings as shown below: 

Generation Settings:

  • Image Size: 512x768px 
  • Sampler: DPM++ 2M SDE Heun Karras
  • Steps: 30 
  • CFG Scale: 6

Step 8. Now, choose a checkpoint model for your image. I’m using the epicphotogasm checkpoint model which is great at generating realistic images. 

ReActor - Generate Prompt

Step 9. Finally, click on the Generate button and create a new face swap image. 

Here are the output images: 

Fixing & Upscaling The Image

The face-swapped images we generated are very blurry which is not impressive. That’s because the face swapping model in the ReActor extension or any other face swapping extension uses a 128px model which is low quality. 

Step 10. To fix the blurriness in the image, click on the CodeFormer option in the Restore Face setting you’ll find in the ReActor extension. 

ReActor - Enable CodeFormer

Step 11. Generate the image again and you’ll notice the blurriness has gone completely and the images look stunning with our swapped faces on them. 

But we can make them look even better by upscaling our generated image. You can use the Extras tab in Automatic1111 to upscale your image. 

But the ReActor extension has a built-in upscaling option which is better when you’re swapping faces in Stable Diffusion. 

Step 12. Click on the Upscale tab in the ReActor extension and enable the Face Restore & Upscale option. 

ReActor - Upscaling

Step 13. Choose an upscaler from the dropdown. I recommend using the R-ESRGAN 4x+ or 4x_NMKD-Siax_200k upscalers. 

Step 14. Set the Scale By option to whatever amount you want to upscale the image to. I recommend upscaling the image to 2x or 4x. 

Now, when you generate the image again, your images will have no blurriness and will be upscaled to a very high quality. 

That’s how you can swap faces in Stable Diffusion using the ReActor extension. 

Here is another example of a face swap in Stable Diffusion using Kaley Cuoco’s face:

Again, I used the same settings as before:

Face Swap In Stable Diffusion - Kaley Cuoco

Recommended: How To Run Stable Diffusion On Android

Face Swapping On Existing Images 

Swapping your face on newly generated images is great but the real fun lies when you swap faces on existing faces. 

Want to swap yourself into Henry Cavill’s Superman? Or how about swapping your face into the Mona Lisa? 

You can swap your face on existing images using the ReActor extension as well. For this, we’ll be using the img2img feature of Stable Diffusion paired with the ReActor extension. 

Let’s see how it’s done. 

Step 1. In Automatic1111, go to the img2img tab and you’ll find the ReActor extension here as well. 

Step 2. Enable the extension and upload the image of the face you want to swap. 

ReActor - Img2Img Face Swap

Step 3. Enable the Face Mask Correction option and choose CodeFormer in the Restore Face settings. Also, make sure the Swap In Source Image option is selected. 

ReActor - Img2Img Face Swap Settings

Step 4. Scroll up and upload the image on which you want your face swapped in the img2img tab. 

ReActor - Img2Img Face Swap Target Image Upload

Step 5. Set the denoising strength to a very low value between 0.125-0.25. You don’t have to change the other settings and can leave them as they are. 

ReActor - Img2Img Face Swap Denoising Strength

Here are the generation settings I’m using: 

  • Image Size: 1200*766
  • Sampler: DPM++ 2M SDE Heun Karras
  • Steps: 30 
  • CFG Scale: 6
  • Denoising Strength: 0.125

Step 7. We don’t have to enter any prompts when swapping faces so click on the Generate button. 

Here are the output images: 

The key to getting the most accurate face swaps with img2img is to set a very low denoising strength to avoid the image being changed completely. 

Also, experiment with different samplers to see which one gives the best output. I’ve had good results with the Euler Ancestral, DPM2 Karras, and DPM++ 2M SDE Heun Karras samplers. 

This technique of face swapping in Stable Diffusion works wonderfully and gives out really good results. 

Create A Face Swap Model In ReActor

So, now you know how to swap faces in Stable Diffusion using ReActor. You can do it in txt2img or img2img pretty easily. 

But uploading your source image every single time you want to swap faces is a bit time-consuming. 

Well, the ReActor extension has a feature that lets you turn your face into a model using one image. Unlike LoRA models where you have to train with hundreds of images, you can create a face model for ReActor using a single image. 

Let’s see how it’s done. 

Step 1. In Automatic1111, go to the ReActor extension and click on the Tools tab. 

ReActor - Tools

Step 2. On this tab, you’ll find an option named ‘Build & Save’. Upload the image of your face for which you want to build the model. 

ReActor - Build Face Model

Step 3. Write a name for your model and click on the Build & Save button. Your face model will be created successfully. 

Now, whenever you want to use this model, simply select the Face Model as your image source and select the model from your dropdown. You won’t have to upload images anymore for that face. 

ReActor - Use Face Model

And if you’re wondering, the results from using an image and a face model to swap faces are the same. 

FAQs

Here are some frequently asked questions about how to face swap in Stable Diffusion: 

What are the best face swap extensions for Stable Diffusion? 

ReActor is the best face swap extension for Stable Diffusion. Alternatively, you can also try the FaceSwapLab extension or use ControlNet using an IP Adapter to swap faces in Stable Diffusion. 

How do I get consistent faces in Stable Diffusion? 

There are many techniques to get consistent faces in Stable Diffusion such as using ReActor for face swapping or using ControlNet models. 

What do I do if my output images look blurry? 

The ReActor face swap model is a 128px model which causes the images to look blurry. To fix this, check the CodeFormer or GFPGAN option in the Face Restore settings in the ReActor extension. 

Conclusion 

Swapping faces in Stable Diffusion is very simple using the ReActor as it’s easy and fast. While there are many face swapping methods, using this extension is a good starting point if you’re a beginner. 

In conclusion, you can use this extension to make fun edits of yourself and impress your friends and family. Or you can even use face swapping professionally for your work. 

Regardless, I hope this guide helped you learn about face swapping in Stable Diffusion and hopefully, this helps you avoid those face swapping websites that are data privacy nightmares. 

Lastly, if you have any questions about this tutorial, feel free to ask your questions in the comments section below.

Stable Diffusion Prompt Organizer

One Comment

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.