How to Create a Deepfake Video Using DeepFaceLab

deep fake cover

In this tutorial you will learn how to create a deepfake video using DeepFaceLab. This application uses machine learning to swap almost any face from a video for one that you choose. DeepFaceLab is currently the best software by far for making deepfakes. In this tutorial we will be using the Windows 10 operating system. However the steps are pretty much the same if you are using Linux. So you should be able to utilize this tutorial with either operating system. It is advised that you have a powerful GPU such as a Nvidia GTX 1060 or better for creating deepfakes. If you want the best experience possible I would recommend you use a RTX 3080 or RTX 3090 graphics card. The software will still work with a low end GPU, but it could take multiple weeks to train your model. Having a high end GPU will also allow you to render the face swaps in a higher resolution. To learn how to create a deepfake continue reading below.

Download DeepFaceLab

The first step is to download the latest version of DeepFaceLab. You can do so by going to the DeepFaceLab Github page and scrolling down to releases. Click on the Windows (Mega.nz) link to download the correct release for your graphics card. If you are installing in Linux you will have to follow the instructions provided on the Linux (github) page.

deepfacelab releases

Choose Version

After navigating to the Mega.nz download link you will need to select a version of DeepFaceLab. This is based on which graphics card you have installed. In this tutorial I am using a GTX 1080 so I will download “DeepFaceLab_NVIDIA_up_to_RTX2080Ti_build_11_20_2021.exe”. Choose the version that is correct for your system.

deepfacelab choose version to download

Open the Workspace

After downloading the application, extract the zip file and open the folder. Your folder should look similar to this.

open the workspace

Collect source videos

This is by far the most important step of getting a good result from the process. You need to select a video of your source (persons face you want to copy). As well as a destination video (where you want your source face copied to). You want to find a clip for each that is 5-10 minutes long with multiple angles of the faces. A good source for these videos are interviews on YouTube. Below are the two videos I am going to use. After you download the videos rename the source video to “data_src.mp4” and the destination video to “data_dst.mp4”. Then move both MP4 files into the “workspace” folder.

Source face:

Destination Face:

Extract images from source video

step 1 enter src fps

To start we will need to extract the image frames from the source video. Double click on “2) extract images from video data_src.bat”, you will then see the above window open. Type in 7 or 8 and press “Enter”.

enter source output format

Next type in “png” and press “Enter”.

wait for source images to extract

Wait for the extraction process to complete.

source extraction complete

Once you see this screen the process is complete and you can close the window.

Extract images from destination video

select destination output image format

Next you need to extract every frame from the destination video as an image. Double click on “3) extract images from video data_dst FULL FPS.bat”. You will see the above window open. Type in “png” and press “Enter”.

wait for images to extract destination

Wait for all of the destination images to be extracted.

destination image extract complete

Once you see this screen the process is complete and you can close the window.

Extract the source video’s faceset

select gpu source video face extract

Next you will need to extract the source video’s faceset images. To begin double click on “4) data_src faceset extract.bat”. It will open the window you see above. Select your GPU device and press “Enter”.

select face extract type source

Afterwards you will be asked which face type to use. Type in the default option “wf” (whole face) and press “Enter”.

extracted source face image size

Then you will select the faces image size. Type in “512” and press “Enter”.

extracted source face jpeg quality

Next set the jpeg quality to “90”. Once you press “Enter” the face extraction process will start.

wait for source faces to extract

Wait for the extraction process to complete.

source video face extraction complete

You will see this screen once the source face extraction is complete. Press “any key” to exit and close the window.

Extract the destination video’s faceset

select gpu source video face extract

The destination video face extraction process will be similar to the source extraction. To begin double click on “5) data_dst faceset extract.bat”. Once the window opens, select the GPU device and press “Enter”.

select face extract type source

Type in “wf” and press “Enter” to use the whole face.

extracted source face image size

Set the face image size to “512” then press “Enter” to continue.

extracted source face jpeg quality

Finally set the jpeg quality to “90” and press “Enter”.

wait for source faces to extract

Wait for the destination face extraction process to complete.

source video face extraction complete

At completion you will see this screen. You can press “any key” to save and exit. At this point you have both of your videos faces extracted and ready for use in the deepfake video.

Sort the source and destination faceset’s

run the sorting tool

In this step we will be sorting the faces by similarity to make it easier to remove blurry and unwanted faces. To sort the source faces double click on “4.2) data_src sort.bat”. You will see the above screen. Type in “5” and press “Enter”.

wait for sort tool

Wait for the sorting process to complete.

sort tool complete

The source faces are now sorting by similarity. You now need to sort the destination faces. Double click on “5.2) data_dst sort.bat”. After the terminal window opens repeat the same steps above that you used to sort the source face.

Remove unwanted face images

bad faces examples

This is the last step before beginning to train the model. It is very important to complete this step to obtain a good result. Open the “workspace” folder and navigate to the “data_src” folder. Finally open the “aligned” folder and delete all images that do not contain a face, are blurry, or have hands in front of the face. After you complete this step, repeat the same by navigating to the “data_dst” then the “aligned” folder. Above are some examples of bad photos that I would remove. Use your best judgement when deciding which photos to remove.

Train the deepfake model

set model name

Now you will need to train the model. There are a few training batch files to choose from. If you are new to making deepfakes I would recommend the Quick96 model. To get started double click on “6) train Quick96.bat”.

select gpu for training

Select the GPU device to use for training. If you have multiple GPU’s you will see them here. Unfortunately you are currently only able to use one GPU at a time. Once you press “Enter” the model training will begin. Now you will need to wait for the model to train. Within 24 hours you should start to see the faces in the preview window. I recommend you train the model for at least 7 days to get high quality results. If you need to use your computer for something else you can press “CTRL+C” to save and exit. The next time you open the Quick86 trainer it will resume from the last saved iteration.

train it 1

Preview at 1 iteration.

train it 650

Preview at 643 iterations.

train it 2500

Preview at 2,569 iterations.

train it 400000

Preview at 403,891 iterations.

Merge the deepfake video

select model

Next you will need to merge the faces into each frame of the video. This replaces the destination face with the source face for each frame. The merging process will also allow you to adjust the blur, erode mask, and color matching profile. This will allow you to get a more realistic final result. “Double click on “7) merge Quick96.bat”. Then type “0” and press “Enter” to load the model.

select gpu

Select the GPU device to use for the merging process.

use interactive merger

Type “y” and press “Enter” to use the interactive merger tool. The interactive merger allows you to visualize the changes you are making.

select amount of workers

Set the number of workers to “16” and press “Enter”. If you have any issues with the interactive merger opening you should reduce the number of workers.

controls

The above screen will open. These are the different shortcut keys for the merge tool. You are able to adjust many parameters, but we will be changing just a few of them. To begin click anywhere in the gray box and press “Tab”.

set erode and blur

You will then see the videos first frame as well as different values in the terminal. If you just see a black screen use the less than symbol “>” until you get to the first frame to show the face. Now you will have to change the erode_mask_modifier as well as the blur_mask modifier. This will help the face seem more realistic during scenes with heavy movement. To do this press the “W” key 20 times. Then press the “E” key 100 times. After doing this your values will be set. To start the merge press shift plus forward slash “SHIFT+/”, then press shift plus the less than key “SHIFT+>”.

wait until merge is 100%

You will see the “merging” progress bar fill up. Once it gets to 100% the merge is complete.

press esc to save

After the video has finished merging click on the video output window and press “Escape” to save and close the merge.

Export the video file

export deepfake mp4

The final step is to export the video as a MP4 file. Double click on “8) merged to mp4 lossless.bat” to begin the process. Once you see the above screen you have completed the deepfake tutorial. Navigate to “workspace” to find your video file. It will be saved as “result.mp4”.

This is the result of the process after training for 1,000,000 iterations. If you want a better result you can train for longer, use a RTX 3090 graphics card, and or provide more source video material to improve the models quality.

Questions?

If you have any questions or comments feel free to leave them below.

Related Resources

View our Deep Learning Image Style Transfer Tutorial Using Neural Style Pt.

Check our our The Best Mechanical Gaming Keyboards to Purchase in 2023 article.

Learn How to Install Ubuntu Server 22.04 [Step by Step].

Click here to learn How to Install MySQL on Ubuntu Server 22.04 LTS.

View our other Machine Learning Tutorials.

Learn How to Mount an SMB (Samba) Share in Linux with cifs-utils.

View all of our available online tools and converters at Formatswap.com.

Affiliate Disclaimer:

This website may contain affiliate links. This means we may receive a small commission if you purchase through our links. However, this does not impact our reviews and comparisons, as we only promote products we personally believe in. We are independently owned and the opinions expressed here are our own.

How to Easily Create a Bootable Linux Installation USB Drive Using Rufus

create bootable usb with rufus splash image

In this tutorial you will learn how to create bootable USB drives using Rufus. One of the main benefits of using Rufus is that it is free, open source, and easy to use. Rufus is a good lightweight alternative to Unetbootin. Additionally with this universal USB installer you can easily create installation drives for Linux, Mac OS, and Windows. It is compatible with most .ISO files and bootable image formats, as well as raw disk image file support. Rufus also supports the creation of bootable FreeDOS installations.

Download Rufus

The first step will be to download Rufus. You will want to navigate to the Rufus Download Page. Then scroll down to the Download section and click on “Rufus 3.20” to download the application.

Download Rufus

After you download Rufus, double click on “rufus-3.2.0.exe” to launch the application. At this point you will also want to plug in your USB flash drive.

Select Installation ISO File

Select Installation ISO File

Next you will select the iso file that you want to flash to the USB drive. Click on the “SELECT” button. You will then get a file selection dialog, navigate to where your iso is and select it. In this example I will be using “ubuntu-22.04-live-server-amd64”. If you wish to download the ISO you can do so on the Ubuntu website.

Select Storage Device

Select Storage Device

Afterwards you will need to select the storage device you want to use. This will be the flash drive that you plugged in a few moments ago. Select it from the drop down list then continue. *WARNING* be careful to select the right drive as all of the data will be deleted.

Set Boot Selection

Set Boot Selection

Now you will select the “Boot selection” I recommend keeping this option at the default “Disk or ISO image”.

Choose Partition Scheme

Choose Partition Scheme

Next choose the partition scheme. Usually you can keep this at the default unless you have a very old PC. If you end up having issues change this option and re-flash. We will be keeping it at “MBR”.

Choose Target System

Choose Target System

The next option is the “Target system” I would leave it at “BIOS or UEFI” unless you have a specific reason to change it. This option will work for almost every PC.

Create a Volume Label (optional)

Create a Volume Label (optional)

This step is optional but if you want to give your flash drive a name just type it in this box. This name will show up in the file explorer after you complete the process.

Set Cluster Size

Set Cluster Size rufus

For the cluster size you can keep it and the default of “64 kilobytes”. This will work for most flash drives.

Set File System

Set File System rufus

Finally select the file system. Most people use either NTFS or FAT file formatting. I will be using FAT for this tutorial.

Start Flashing Process

Start Flashing Process rufus

Finally we can start the ISO flashing process. Click on the start button to begin flashing your USB drive.

Confirm Rufus Drive Flashing Process

Confirm Drive Flashing

This window will ask you to confirm that you really want to flash the USB drive.

Wait for Flashing to Complete

Wait for Flashing to Complete

Now you will have to wait for the flashing process to begin. This can take a while so go make yourself a cup of coffee while you wait.

Rufus Flashing Complete

Flashing Complete

When the flashing process completes you will see a green bar at the bottom, as well as the word “READY”. Your installation media is now ready to be used. You can now eject your flash drive and close Rufus.

Additional Questions?

If you have any additional questions or thoughts feel free to comment them below.

Related Resources

View our list of The Top 5 Programming Languages to Learn in 2022.

Check our our The Best Mechanical Gaming Keyboards to Purchase in 2023 article.

Learn How to Install Ubuntu Server 22.04 [Step by Step].

Click here to learn How to Install MySQL on Ubuntu Server 22.04 LTS.

View our How to Setup OpenSSH with Keys on Ubuntu 22.04 tutorial.

Learn How to install Kali Linux 2022.3 [step by step].

View all of our available online tools and converters at Formatswap.com.

Affiliate Disclaimer:

This website may contain affiliate links. This means we may receive a small commission if you purchase through our links. However, this does not impact our reviews and comparisons, as we only promote products we personally believe in. We are independently owned and the opinions expressed here are our own.

How to Install Ubuntu Server 22.04 [Step by Step]

ubuntu splash image

In this beginner friendly tutorial you will learn how to install Ubuntu Server 22.04 LTS. Ubuntu Server is currently one of the most popular Linux based server operating system. One of the biggest advantages to using Ubuntu Server is the stability that it brings. As an LTS release it will provide you five years of security updates and support by default. This will ensure your server is always secure and has the latest software. To start this tutorial make sure you have a virtual machine, an unused hard drive, or a empty partition to be able to install the operating system. If you want to learn how how to make a bootable installation flash drive click here. You will also have to download the Ubuntu Server ISO file. You can do that by clicking this link. Download Ubuntu Server 22.04 LTS

Language selection

ubuntu install window

The first step after booting into your Ubuntu Server or ISO is to select the language. Choose your language and then press “Enter”.

Update the installer

ubuntu install window

Next the installer will ask you if you want to update. I recommend updating to the latest installer. Select “Update to the new installer” then press “Enter”.

Keyboard configuration

ubuntu install window

After that you will be brought to the keyboard configuration page. If you are okay with the default (automatic) keyboard layout, select “Done” and press “Enter” to continue.

Installation type

ubuntu install window

This page will ask you if you want to do the default Ubuntu Server installation or the minimal version. I recommend the first option. Select your choice then select “Done” and press “Enter”.

Network configuration

ubuntu install window

Next we have the network configuration page. By default the installer will automatically detect your IP address settings. If you want to change it select the network adapter “ens18” and press “Enter”. I recommend just keeping it at its default settings. Select “Done” and press “Enter”.

Configure network proxy

ubuntu install window

Afterward you will be brought to the proxy configuration page. If you have a proxy you would like to use enter its information. Else just select “Done” and press “Enter”.

Guided storage configuration

ubuntu install window

Now we will need to setup the storage configuration. Luckily the installer does the hard part for us. If you are using a full physical or virtual disk, select “Use an entire disk” and press “Space” to mark it. Afterwards select “Done” and press “Enter” to proceed.

Review storage configuration

install ubuntu 22.024

This next page will show you a review of the storage configuration changes that will take place. Review the disk and partition names, and if everything looks correct proceed to the next step.

Confirm storage configuration

install ubuntu 22.024

Now you will be asked to confirm the storage configuration options. Select “Continue” and press “Enter” to proceed to the next step.

Setup Ubuntu user account

install ubuntu 22.024

Afterwards you will need to setup your user account. Enter a name, server name, username, and password. Then click on “Done” and press “Enter”.

Install SSH

install ubuntu 22.024

This step is optional. If you would like to enable the SSH server select “Install OpenSSH server” then press “Space” to mark it. Afterwards press “Done.” and press “Enter”.

Wait for system to be installed

install ubuntu 22.024

Now the system will begin installing. This can take anywhere from 20-30 mins to fully install Ubuntu Server. Wait for it to complete.

Installation complete

install ubuntu 22.024

Once the installation is complete you will see this screen. Select “Reboot Now” and press “Enter” to reboot the system and continue.

Unmount USB drive or ISO file

install ubuntu 22.024

After the system reboots you will get a message telling you to “Please remove the installation medium, than press Enter”. Remove your USB drive or ISO file if you are using a virtual machine. Once you have completed this step press “Enter” one final time to reboot.

Login to Ubuntu Server 22.04

install ubuntu 22.024

You will be brought to the Ubuntu Server login screen. Type in the credentials you created for your account. You will then be logged into the system. You have now successfully installed Ubuntu Server 22.04. If you are looking for other Linux tutorials check out our articles below.

Related Resources

View our list of The Top 5 Programming Languages to Learn in 2022.

Check our our The Best Mechanical Gaming Keyboards to Purchase in 2023 article.

How to Install VeraCrypt and Encrypt a Flash Drive on Ubuntu 22.04.

Click here to learn How to Install MySQL on Ubuntu Server 22.04 LTS.

View our Programming Articles and Tutorials.

Learn more cool things in Linux with our Linux Tutorials.

View all of our available online tools and converters at Formatswap.com.