Create and Understand DeepFakes in 5 minutes

Understand how deep fakes work and create your own!

Create and Understand DeepFakes in 5 minutes

Watch the video and support me on YouTube!

It seems like it was always there, but deepfakes first appeared in 2018, only two years ago!

Since then, it has evolved in a way nobody could ever imagine. As you can see, you can easily make a video look real where a person isn’t even there! The reality is that you can’t believe what you see anymore, and DeepFakes has a big role in this.

In fact, the DeepFake technology makes it possible to literally put words in the mouth of anyone while also creating a fake video of the person saying it.

It is both an awesome new technology and a dangerous tool.


What is a DeepFake & how does it work?

A deepfake is a synthetic media in which the identity of a person in an image or video is replaced with someone else. Either their voice, their face or even both.

DeepFakes uses machine learning algorithms to manipulate or generate the visual and/or audio content of such videos to imitate someone else’s voice and/or face.

With the progress of GPUs over the last few years, researchers were able to develop deep learning techniques making these applications possible, such as autoencoders and GANs. Which I already covered in previous videos if you are interested in learning more about those machine learning frameworks.

Now you may wonder, how do they work?

Well, the answer isn’t that simple. Deepfake applications work in many various ways. Just like in this gif, some try to map the face of a target person, like putting the face of Elon Musk onto a target video of a baby playing around.

Baby Elon Musk Montage Deepfake: https://www.youtube.com/watch?v=WHwQeetjLwk&ab_channel=TheFakening

How DeepFakes are made

Image from https://www.alanzucconi.com/2018/03/14/understanding-the-technology-behind-deepfakes/

Like most recent AI-based applications, it uses deep neural network architectures to achieve this. As I said, it uses autoencoders, merged with GANs, which is especially good for computer vision applications like this one.

It consists of an encoder, which reduces an image to a lower-dimensional latent space and a decoder, which reconstructs the image from the latent representation.

The encoder is used to encode the person we want to imitate into the latent space. This latent space then contains the key features of their facial features and body posture to reproduce his facial and body movements.

Image from https://www.slideshare.net/IanMcCarthy/deepfakes-trick-or-treat

Then, a model trained specifically for the target video is used to decode this latent space. This means that the target’s detailed information will be superimposed on the underlying facial and body features of the original video, represented in the latent space previously encoded.

GANs can be merged with such autoencoders to improve the results of this algorithm. It makes the deepfake constantly evolve and improve in realistically.


Make your own DeepFake

Fortunately for us, there are many online tools available to produce deepfakes.

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

There is DeepFaceLab that is completely free with the code publicly available and many resources available to train your own deepfake on your images and videos. You can do many things using their code, such as replacing a face from a picture or video, replace the whole head, and even manipulate the voice of a specific person.

Check out their GitHub for more information, everything is clearly explained, and you can even run the code directly on google colab if you don’t have the computation power to train such a big network on your own computer. They even shared a complete video tutorial to help you create your own deepfakes!

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

Of course, every resource cited here is completely free. You should definitely give it a shot if deepfakes interest you!

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


If you like my work and want to stay up-to-date with AI, you should definitely follow me on my other social media accounts (LinkedIn, Twitter) and subscribe to my weekly AI newsletter!

To support me:

  • The best way to support me is by following me here on Medium or subscribe to my channel on YouTube if you like the video format.
  • Support my work on Patreon
  • Join our Discord community: Learn AI Together and share your projects, papers, best courses, find Kaggle teammates, and much more!

Conclusion

As I said, this is both an awesome and dangerous new technology. Please, do not abuse this technology and stay ethically correct. The goal here is to help improve this technology and not to use it for the wrong reasons. Plus, there are many techniques to detect deepfakes, which will be the subject of a whole other video.