Table of Contents

Deepfake Video Examples

Background

Creating your own deepfakes has been possible for a while now but the problem was that it required a lot of data, computing power, and time.

But now, thanks to the researchers Aliaksandr Siarohin, Stéphane Lathuilière, Sergey Tulyakov, Elisa Ricci and Nicu Sebe, their paper “First Order Motion Model for Image Animation,” and their implementation, we are now able to create a deepfakes with a single image.

Better yet, not only can we create deepfakes with a single image, but they also don’t take hours or days to make, now they take only mere seconds and at most a couple of minutes. In addition, no coding experience is required.

If you’d like to understand more of how this works, you can watch this video by Two Minute Papers.

Things you’ll need

  • An image of what you want to animate
  • A video to extract the animation from
  • Some free time

Before starting

Sign in to your Google account

Image for post
Image for post

You’ll need to sign in to your Google account to interact with this document.

I’d suggest you create a new Google account here.

Connecting to the Google Colab

To do so click on the connect button at the top right of the page.

Image for post
Image for post

If you don’t get any error messages, you can skip straight to (Step 3).

If you get the following message, that means that you won’t be able to use Google’s GPU which essentially means you can’t follow the tutorial at this time because all the GPUs are being used.

Image for post
Image for post

To fix this, you can either (1) wait and come back later, (2) upgrade to colab pro, (3) run this repository locally on your own machine (not covered in this tutorial but you can go here to follow a tutorial), or (4) create another Google account and try again.

If you click “Connect Without GPU” then, later on, you’ll encounter the following error:

Image for post
Image for post

Creating your own deepfakes

(Step 1) Cloning the Repo

Image for post
Image for post

You’ll want to click on that play button to clone their repository.

(Step 2) Change your directory

Image for post
Image for post

(Step 3) Mounting your Google drive folder on Colab

Image for post
Image for post

Before this can actually happen however, you have to click the link allowing the permission to do so:

Image for post
Image for post

Then you’ll be prompted to sign in to your Google account again. Sign in to the same google account you originally signed into since starting this tutorial.

You will then see the following page:

Image for post
Image for post

Copy and paste the authorization code into the colab like so and hit enter:

Image for post
Image for post

Now you’ll want to click on the following link:

Image for post
Image for post

You’ll then get sent to a Google drive that will have several files.

Image for post
Image for post

You only need to download the files called “vox-adv-cpk.pth.tar” and “vox-cpk.pth.tar” but I would also suggest you download a video and an image from here too.

For the purposes of this tutorial, I’ll be downloading the aforementioned files as well as “05.png,” which is an image of The Mona Lisa, and “10.mp4,” which is a video of Leonardo DiCaprio’s face.

Downloading the files may take some time so just be patient.

(Step 5) Create a folder called “first-order-model-motion” in your Google Drive

Image for post
Image for post

It’s in this folder that you’ll want to upload the files you just downloaded.

Note: You can also upload your own video and images but just make sure they are cropped to 256px by 256px.

For the purposes of this tutorial, we’ll just be using an image of The Mona Lisa and a video of Leonardo DiCaprio’s face.

Image for post
Image for post

This will also take some time so just be patient.

(Step 6) Loading your image and video

Image for post
Image for post
Just make sure that the ending of the path has the correct name, i.e. ‘…/your_image_file.png’ and ‘…/your_video_file.mp4’

Now you want to go ahead and click the play button.

Image for post
Image for post

This will take a couple of seconds but once that’s done, scroll down and you should see something like this

Image for post
Image for post

(Step 7) Creating the model and loading the checkpoints

Image for post
Image for post
In the image above you see a square icon because I was already running it but you should see a play icon.

Click on the play button and wait for it to finish.

(Step 8) Creating the deepfake

Scroll down until you see the header “Perform image animation” and click on the play button like so:

Image for post
Image for post

Now you’ll have to wait a little more but once that finished you should see something like the following:

Image for post
Image for post

Congrats! You just created your first deepfake!

(Step 9) Saving your deepfake

Image for post
Image for post

Click on the icon with three vertical dots and then click download.

Image for post
Image for post

And voila, you’re done!

Errors

Click on the “Runtime” tab.

Image for post
Image for post

Click on “Factory reset runtime.”

Image for post
Image for post

Click “Yes” and reload the page.

Image for post
Image for post

If you still encounter errors you can watch this video here.

Using your own image

Also, make sure it’s saved in the “.png” format.

Other image types may work, such as .jpg, but .png will give you the best results, at least in my experience.

Using your own video

The Google colab provides a tool for you to do this.

Before we can actually crop our own video, we have to upload our video to our Google drive.

Scroll down to the header that says “Running on your data”

Image for post
Image for post

You’ll want to paste the following line making sure you replace “…/my_video_file.mp4” to match your file name.

!ffmpeg -i /content/gdrive/My\ Drive/first-order-motion-model/my_video_file.mp4 -s 256x256 -c:a copy /content/gdrive/My\ Drive/first-order-motion-model/result.mp4

Then you should see a video called “result.mp4” in your google drive.

You can then use this video in step 6 and onward making sure that you use the name “result.mp4” for the video.

The video result can be a hit or miss. I’d suggest you crop the video yourself using video editing software.

Video tutorials

20-minute video tutorial.

Creating a deepfake without using Google Colab.

Originally published at https://blog.alanjc.com.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store