Book Image

Exploring Deepfakes

By : Bryan Lyon, Matt Tora
Book Image

Exploring Deepfakes

By: Bryan Lyon, Matt Tora

Overview of this book

Applying Deepfakes will allow you to tackle a wide range of scenarios creatively. Learning from experienced authors will help you to intuitively understand what is going on inside the model. You’ll learn what deepfakes are and what makes them different from other machine learning techniques, and understand the entire process from beginning to end, from finding faces to preparing them, training the model, and performing the final swap. We’ll discuss various uses for face replacement before we begin building our own pipeline. Spending some extra time thinking about how you collect your input data can make a huge difference to the quality of the final video. We look at the importance of this data and guide you with simple concepts to understand what your data needs to really be successful. No discussion of deepfakes can avoid discussing the controversial, unethical uses for which the technology initially became known. We’ll go over some potential issues, and talk about the value that deepfakes can bring to a variety of educational and artistic use cases, from video game avatars to filmmaking. By the end of the book, you’ll understand what deepfakes are, how they work at a fundamental level, and how to apply those techniques to your own needs.
Table of Contents (15 chapters)
1
Part 1: Understanding Deepfakes
6
Part 2: Getting Hands-On with the Deepfake Process
10
Part 3: Where to Now?

Summary

In this chapter, we trained a neural network to swap faces. To do this, we had to explore what convolutional layers are and then build a foundational upscaler layer. Then we built the three networks. We built the encoder, then two decoders. Finally, we trained the model itself, including loading and preparing images, and made sure we saved previews and the final weights.

First, we built the models of the neural networks that we were going to train to perform the face-swapping process. This was broken down into the upscaler, the shared encoder, and the two decoders. The upscaler is used to increase the size of the image by turning depth into a larger image. The encoder is used to encode the face image down into a smaller encoded space that we then pass to the decoders, which are responsible for re-creating the original image. We also looked at activation layers to understand why they’re helpful.

Next, we covered the training code. We created instances of the network...