How to replace face in a video for free?

Do you want to replace a face with a deep fake? You’ve probably come across a few extensions for editing software and some online tools but none of them are free. Here’s a free tool that you can use offline on your PC to replace a face with a deep fake.

replace face in video

Deep Face Live Free

Deep Face Live is a free open-source software that you can use to swap faces in a video or swap faces in a real-time stream like video calls, webcam recording, etc.

Let’s see how to swap faces in a video for free using this software

Pre-requisites

You’ll need a PC with a decent graphic card and RAM for this software to work.

Installation

Step 1: Download

Download DeepFaceLive from here

Download deep face live

Download the latest NVIDIA build if you have a NVIDIA graphic card or else download the DirectX12 build.

Step 2: Set total virtual memory to 32 GB or more.

Press Windows + R on your keyboard and type sysdm.cpl

run command

Click on the advanced tab on the top and click on settings under the performance tab

performance tab

Select the Advanced tab again and click on “Change” in the virtual memory section

advanced tab

Select C drive > Select custom size > Enter 16384 in Initial size > Enter 32768 in Maximum size

virtual memory settings

Click Ok > Apply and restart your PC to apply the changes to virtual memory.

Step 3: Extract and open

Double-click on the download build file. It’ll open an extractor. Select the root of any one of the drives. I’ve selected E: in my case.

extract archive

Open the extracted folder and double-click on the DeepFaceLive.bat file

open the bat file

Step 4: Replace the video

Select a Video file in the file source

video source

Choose a Face detector and Device

face detector

Choose a Face marker and Device

face marker

Choose the Model and Device in Face Swapper

Face swapper

Now you see a swapped face in the Final frame preview window

swapper face preview

in Stream output choose Mode: Merged frame, Press the play button, and press window

merged frame in stream output

Now you can see the live output in the deep face live output window

output preview

A Working demo of the video with the face replaced

Check out the final output video where multiple characters’ face in the video is replaced with Elon Musk. Please don’t sue me 🫠

How to save the output video?

Select a folder in the stream output section. Make sure that you select an empty folder as multiple images will be saved to that folder.

save steam output

Now, Click on the play button and wait till the video playback completes. The video frames (images) with the face replaced will be generated in the selected folder.

How to convert generated image sequence to a video?

I personally use Adobe premiere pro to import the image sequence in the form of a video and then export it. Here’s how to do it premiere pro: Click on import in premiere pro > Select the first image and make sure to tick the Image Sequence checkbox.

import image sequence premiere pro

After this, The image sequence will be imported in the form of a video that you can export it as an MP4 or any video format that you want.

You can also use any online tools to convert an image sequence into a video. I did not find a good tool so I used Adobe Premiere Pro

Mac/Linux support

I have tried it out only on Windows but you can try it out on Mac/Linux as mentioned in the docs

Requirements

  • Nvidia-driver-470 (current)
  • cuda 11.4 (current)

Setup

git clone DeepFaceLive
cd DeepFaceLive/build/linux/
# start.sh builds and runs container with proper options, then example.sh will start DeepFaceLive with example options
./start.sh

Usage of ./start.sh
# -d specify a folder for DeepFaceLive data (videos, models, etc)
-d /home/user/DeepFaceLive_data
# -c will pass through existing video devices such as /dev/video0 and /dev/video1, etc

Supported face models

The library has already trained multiple face models which you can readily use. Check out all the trained models here

If you want a higher quality or better face match, you can train your own face model using DeepFaceLab

supported face models

Use your own picture to replace

If you want to use your own pictures instead of the existing face models then you can do it as well.

Simply take a pic of your face in a passport-size format > Click on the Eye icon in the Face Swap (Insight section) > Paste your image there > Click on the refresh icon next to the eye icon in the Face Swap section.

Now you’ll be able to see your picture name in the Face dropdown. Select your picture name and click on the play button to run the analysis and replace the face in the video with your face!

Conclusion

You can also use this library to replace face in live streams as well. Go ahead and try it out by changing the file source!

The clarity of the face swap is surprisingly good even without tweaking any configuration parameters. If you want to further fine-tune it then you can do it by playing around with different face detector models and face aligner configuration options ✌🏻

Ranjith kumar
5 3 votes
Article Rating
Subscribe
Notify of
guest

3 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Rohith
Rohith
7 months ago

Content creators can learn this skill.

Wim Mertens
Wim Mertens
4 months ago

Hi, thx for the good tutorial. I did everything like you told but my video outcome is not fluent but slow and schoking? Any suggestions?