DeepFaceLab

DeepFaceLab

DeepFaceLab is the leading software for creating deepfakes. More than 95% of Deepfake videos are created with DeepFaceLab.

Table of Contents

Step 1: Download & Install DeepFaceLab Step 2: Extract Images Step 3: Extract Facesets Step 4: View Facesets Step 5: Training Step 6: Merging

Step 1: Download & Install DeepFaceLab

Visit https://github.com/iperov/DeepFaceLab.

Scroll down to the section labeled ‘Releases’. You can select the torrent magnet link or download from mega.nz. Mega users can right-click on the file, select download, then standard download.

Download DeepFaceLab 2.0 from Mega.nz

Once your download is complete you can double-click on the .exe file or use your favorite zip program to extract. There is no setup for DeepFaceLab. Once the files are extracted the installation is complete.

Open the folder labeled DeepFaceLab_NVIDIA. Here you will see a couple of folders and several batch files used in the deepfake process. For this tutorial we will only be using 9 of these files.

First let’s have a look at the workspace folder. In this directory you will see 3 more folders which will hold our images and trained model files. The 2 video files include data_src (our source video) and data_dst (our destination video). Click back to the main folder and we’ll get started with the deepfake.


Step 2: Extract Images

Throughout this tutorial we will be using DeepFaceLab’s default settings by pressing Enter or Return when asked for input.

Double-click on the file labeled ‘2) extract images from video data_src’ and press enter a few times to use the default values. The video file will be processed and a .png file for each frame will be created. Press any key or simply close the window.

Do the same for data_dst using the file ‘3) extract images from video data_dst FULL FPS’ with default values.


Step 3: Extract Facesets

Now we’ll process the images and extract the faces to be used in our deepfake. Double-click the file ‘4) data_src faceset extract’ and use the default values. After a few minutes the extraction will complete and give you a report on the number of images found and faces detected.

Do the same for data_dst using the file ‘5) data_dst faceset extract’.


Step 4: View Facesets

After extraction we can view the source and destination facesets using the files ‘4.1) data_src view aligned result’ and ‘data_dst view aligned results’ respectively. Here we can remove unwanted faces from the project but for now we will be using all the images. Close the image viewer.


Step 5: Training

It is now time to begin training our deepfake model. Double-click the file labeled ‘6) train Quick96.bat’. Again, we will use the default settings. The software will load all our images files and attempt to run the first iteration of our training. If it is successful, then the training preview window will open. If the trainer fails to run, then you will need to try CPU only training which is not covered in this video.

Let’s take a moment to look at the preview window. At the top we have some keyboard commands. Below that a graph indicating the accuracy of our training, and a preview of our model images.

Press the P key to update the preview window and notice the graph and images change. These lines represent loss values that will approach zero over time, so the lower the line the better the results will be. You can see these same values represented as numbers in the command window.

The image preview has several columns showing our source and destination images being processed. In the last column we can see the current progress of our deepfake faceset. Use this preview window to decide when you want to end the training. Press Enter to save the model and exit.


Step 6: Merging

Now that our training is complete, we can merge the faces and create our final deepfake video.

Start by running ‘7) merge Quick96’ and press Enter a few times to load the default settings. In the merger window you will see a map of keyboard commands. For this tutorial we will only be using a few of these commands.

Press the Tab key to switch between the preview window and the keyboard map. If you see a black preview just use the > key to advance to the first frame. You will notice the current frame number and settings displayed in the command window. Use the W and S keys to change the erode mask value to 20, noticing how the border around the face contracts. Next use the E and D keys to raise the blur mask value to 100.

Now we apply these setting to the rest of our frames by pressing the Shift and / keys simultaneously. Finally, we process the remaining frames by pressing the Shift and > keys. Once the merger reaches 100 percent, we can close both windows.

The last part of this process is to merge our new deepfake frames into a video file with our destination audio. Double-click the file labeled ‘8) merged to mp4.bat’ and press Enter to begin processing. Close the window when merging is done.

Finally we are ready to view our deepfake video. Navigate to the workspace folder and you will see a couple new files. Play the file labeled ‘result.mp4’. Congratulations! You have successfully created a deepfake!

Last updated