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?

Exercises

  1. We use the mask to cut out the swapped face from the rest of the image but then copy it over to the aligned face. This means that the areas of the aligned image that aren’t the face also get a lower resolution. One way to fix this would be to apply the mask to the original image instead of the aligned image. To do this, you’ll need to call cv2.warpAffine separately for the mask and the aligned image, then use the mask to get just the face copied over. You may want to view the documentation for OpenCV’s warpAffine at https://docs.opencv.org/3.4/d4/d61/tutorial_warp_affine.html.

Be sure to account for the fact that OpenCV’s documentation is based on the C++ implementation, and things can be a bit different in the Python library. The tutorial pages have a Python button that lets you switch the tutorial to using the Python libraries.

  1. We rely on pre-extracted faces in order to convert. This is because a lot of the data is already...