Make Your Own Deepfake Video in a Few Easy Steps
A simple guide for creating your own Deepfake video
If you’re reading this article, then you’ve likely seen or heard about a particular AI algorithm called deepfakes. Much of this hype has comes as a result of major apps like Snapchat, FaceApp, or Instagram using this algorithm to create entertaining content.
In this article, I’ll show you how to quickly and easily create your own deepfake video. To do this, I’ll be using the implementation for the research effort First Order Motion Model for Image Animation, developed by Aliaksandr Siarohin, Stéphane Lathuilière, Sergey Tulyakov, Elisa Ricci, and Nicu Sebe.
I'll show you how to use their code to create deepfakes using your own pictures and videos.
What is Deepfake?
A deepfake video is a fake photo, video, or story generated by neural networks. Deepfake developers use artificial intelligence and machine learning algorithms to imitate the facial features and body postures of real humans.
These deepfakes diverge from other common forms of fake media by being extremely hard to identify. In addition to their impressive technological underpinnings, deepfakes have the potential to cause enormous damage.
In April 2018, BuzzFeed showcased how far deepfake video technology has come by combining Barack Obama’s face with Jordan Peele’s convincing voice impersonation.
Deepfakes depend on autoencoder neural network type. It contains an encoder, which decreases an image to a lower-dimensional latent space, and a decoder, which reconstructs the image from the latent representation. Deepfakes use this structure by having a universal encoder which encodes a character into the latent space. The latent representation includes key characteristics of their facial features and body posture.
Now that we’ve taken a quick look at deepfakes and some of the controversy surrounding them, let’s look at how to implement our own.
Don’t worry about missing out on the latest ML news. Subscribe and let us find it and share it with you and 14,000 others every week.
For setting up our deepfake, I’ll be using Aliaksandr Siarohin’s Google Colab code.
First, make sure you copy his code to your Google Drive since we don’t want to alter his code:
For a faster compile time go to “Runtime -> Change runtime type -> Select GPU”
Before we get started, we need to download a few required files from the Drive link below. You just need to download one .jpeg image, one .mp4 video, a vox-cpk.pth.tar
file, and a vox-adv-cpk.pth.tar
file. But if you need to check with the images and videos they provided, download everything.
After downloading the files, create a folder named first-order-motion-model
in your Google Drive and upload the downloaded files.
To run with your own data…
- If you want your face to be added to a video, then take a selfie and change its size to
256 X 256
pixels (you can simply use Paint to edit the size). This is the input size that the model accepts.
Upload all your data to the first-order-motion-model
folder on your Drive.
To run your face on the videos they’ve provided, change the following code to your file name. Then follow the rest of the steps as presented.
source_image = imageio.imread('/content/gdrive/My Drive/first-order-motion-model/*File Name.png*')
- If you want someone else’s face to be added to your video file, that file also needs to be on the size of
256 X 256
pixels.
To convert your video into the above size, scroll down to the part of the code labeled “Run on your data”. Remove the boilerplate code provided and add the following code:
!ffmpeg -i /content/gdrive/My\ Drive/first-order-motion-model/*File Name.mp4* -s 256x256 -c:a copy result.mp4
This will create a converted video result.mp4

Copy the result.mp4
file into thefirst-order-motion-model
folder and change the following code from “Load driving video and source image”
driving_video = imageio.mimread('/content/first-order-model/result.mp4')
And that’s it. Here is an example I created using Nicolas Cage’s face and the TV show Friends.

I hope this quick start guide to setting up your very own deepfake was useful. Have fun making some funny content (nothing dangerous!). Thank you, and stay safe!
Editor’s Note: Heartbeat is a contributor-driven online publication and community dedicated to providing premier educational resources for data science, machine learning, and deep learning practitioners. We’re committed to supporting and inspiring developers and engineers from all walks of life.
Editorially independent, Heartbeat is sponsored and published by Comet, an MLOps platform that enables data scientists & ML teams to track, compare, explain, & optimize their experiments. We pay our contributors, and we don’t sell ads.
If you’d like to contribute, head on over to our call for contributors. You can also sign up to receive our weekly newsletters (Deep Learning Weekly and the Comet Newsletter), join us on Slack, and follow Comet on Twitter and LinkedIn for resources, events, and much more that will help you build better ML models, faster.