AI EngineeringAI Engineering
AI Engineering4 min read

Create and Understand DeepFakes in 5 minutes

Understand how deep fakes work and create your own! You should definitely give it a shot if deepfakes interest you!

Updated Sep 25, 2021
Create and Understand DeepFakes in 5 minutes
Contents

Key takeaways

  • Deepfakes matter because image and video generation can now change trust, identity, and evidence, not only entertainment.
  • The technical idea is pattern transfer: models learn enough about faces, motion, and style to synthesize convincing media.
  • Detection is a moving target, so responsible use needs provenance, media literacy, platform rules, and technical checks together.

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.

Visual example from Create and Understand DeepFakes in 5 minutes

Visual example from Create and Understand DeepFakes in 5 minutes

Image from DeepFaceLab, https://github.com/iperov/DeepFaceLab

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.

Visual example from Create and Understand DeepFakes in 5 minutes

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.

Visual example from Create and Understand DeepFakes in 5 minutes

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


How DeepFakes are made

Visual example from Create and Understand DeepFakes in 5 minutes

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.

Visual example from Create and Understand DeepFakes in 5 minutes

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.

Visual example from Create and Understand DeepFakes in 5 minutes

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!

Visual example from Create and Understand DeepFakes in 5 minutes

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.

Discussion

Comments

Loading

No account needed. Your name and comment will be public, so do not include private information. See the privacy page for details.

Keep learning

Want the practical side of AI, without the hype fog?

I share the useful parts on YouTube, Substack, and the AI engineering guides.

FAQ

What is a deepfake?

A deepfake is synthetic or edited media that uses AI to change a face, voice, identity, or action in a way that can look real.

How do deepfakes work?

Most deepfake systems learn visual or audio patterns from data, then generate or transform media so the output matches a target identity or style.

Why are deepfakes risky?

They can be used for scams, impersonation, harassment, misinformation, and fake evidence, especially when people see the media without context.

Can deepfakes be useful?

Yes, they can support dubbing, accessibility, creative production, education, and restoration, but only when consent and disclosure are handled properly.

How can people check suspicious synthetic media?

Look for source provenance, inconsistent details, strange motion or lighting, missing context, reverse-image matches, and confirmation from trusted sources.