Master the innovative world of deepfakes and generative AI for face replacement with this full-color guide
Purchase of the print or Kindle book includes a free PDF eBook
Key Features
Understand what deepfakes are, their history, and how to use the technology ethically
Get well-versed with the workflow and processes involved to create your own deepfakes
Learn how to apply the lessons and techniques of deepfakes to your own problems
Book Description
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.
What you will learn
Gain a clear understanding of deepfakes and their creation
Understand the risks of deepfakes and how to mitigate them
Collect efficient data to create successful deepfakes
Get familiar with the deepfakes workflow and its steps
Explore the application of deepfakes methods to your own generative needs
Improve results by augmenting data and avoiding overtraining
Examine the future of deepfakes and other generative AIs
Use generative AIs to increase video content resolution
Who this book is for
This book is for AI developers, data scientists, and anyone looking to learn more about deepfakes or techniques and technologies from Deepfakes to help them generate new image data. Working knowledge of Python programming language and basic familiarity with OpenCV, Pillow, Pytorch, or Tensorflow is recommended to get the most out of the book.
Author(s): Bryan Lyon and Matt Tora
Publisher: Packt Publishing Pvt Ltd
Year: 2023
Language: English
Pages: 256
Cover
Preface
Title Page
Copyright
Contributors
Table of Contents
Part 1: Understanding Deepfakes
Chapter 1: Surveying Deepfakes
Introducing deepfakes
Exploring the uses of deepfakes
Entertainment
Parody
Education
Advertisements
Discovering how deepfakes work
Generative auto-encoders
Assessing the limitations of generative AI
Resolution
Training required for each face pair
Training data
Looking at existing deepfake software
Faceswap
DeepFaceLab
First Order Model
Reface
Summary
Chapter 2: Examining Deepfake Ethics and Dangers
The unethical origin of deepfakes
Being an ethical deepfaker
Consent
Respect
Deception
Putting it into practice
The dangers of deepfakes
Reputation
Politics
Avoiding consequences by claiming manipulation
Preventing damage from deepfakes
Starving the model of data
Authenticating any genuine media
Deepfake detection
Public relations
Public awareness
Summary
Chapter 3: Acquiring and Processing Data
Why data is important
Understanding the value of variety
Pose
Expression
Lighting
Bringing this variety together
Sourcing data
Filming your own data
Getting data from historical sources
Improving your data
Linear color
Data matching
Upscaling
Summary
Chapter 4: The Deepfake Workflow
Technical requirements
Identifying suitable candidates for a swap
Preparing the training images
Extracting faces from your source data
Curating training images
Training a model
Setting up
Launching and monitoring training
Manual intervention
Applying a trained model to perform a swap
The alignments file
Cleaning the alignments file
Fixing the alignments file
Using the Preview tool
Generating the swap
Summary
Part 2: Getting Hands-On with the Deepfake Process
Chapter 5: Extracting Faces
Technical requirements
Getting image files from a video
Running extract on frame images
face_alignments.json
face_bbox_{filename}_{face number}.png
face_aligned_{filename}_{face number}.png
face_mask_{filename}_{face number}.png
Getting hands-on with the code
Initialization
Image preparation
Face detection
Face landmarking/aligning
Summary
Exercises
Chapter 6: Training a Deepfake Model
Technical requirements
Understanding convolutional layers
Getting hands-on with AI
Defining our upscaler
Creating the encoder
Building the decoders
Exploring the training code
Creating our models
Looping over the training
Teaching the network
Saving results
Summary
Exercises
Chapter 7: Swapping the Face Back into the Video
Technical requirements
Preparing to convert video
Getting hands-on with the convert code
Initialization
Loading the AI
Preparing data
The conversion loop
Creating the video from images
Summary
Exercises
Part 3: Where to Now?
Chapter 8: Applying the Lessons of Deepfakes
Technical requirements
Aligning other types of images
Finding an aligner
Using the library
Using the landmarks to align
The power of masking images
Types of masking
Finding a usable mask for your object
Examining an example
Getting data under control
Defining your rules
Evolving your rules
Dealing with errors
Summary
Chapter 9: The Future of Generative AI
Generating text
Recent developments
Building sentences
The future of text generation
Improving image quality
Various tactics
The future of image quality upgrading
Text-guided image generation
CLIP
Image generation with CLIP
The future of image generation
Generating sound
Voice swapping
Text-guided music generation
The future of sound generation
Deepfakes
Sound generation
Text-guided image generation
Improving image quality
Text generation
The future of deepfakes
The future of AI ethics
Summary
Index
About Packt
Other Books You May Enjoy