How to detect DeepFakes with MesoNet | 20 MIN. PYTHON TUTORIAL

Kite
17 Sept 202018:31

Summary

TLDRIn this video, Kalyn from Kite explores deep fakes and introduces Mesonet, a neural network designed to detect them. The video discusses how deep fakes are generated using autoencoders and the creation of a dataset from existing deep fake videos. It then delves into Mesonet's architecture, a convolutional neural network, and its performance in identifying real and fake images. The script also highlights a data bias issue where the majority of deep fake images are pornographic, potentially skewing the model's predictions.

Takeaways

  • 😲 Deep fakes are synthetic media created by deep neural networks, making them nearly indistinguishable from real images, audio, or video.
  • 👀 The potential misuse of deep fakes for spreading misinformation and undermining trust is a serious concern.
  • 🧠 Masonet is a convolutional neural network designed to identify deep fakes, trained on a dataset of real and fake images.
  • 🎨 Deep fakes can be generated by training autoencoders on different datasets, allowing for the blending of distinct visual styles.
  • 📸 The Masonet dataset was assembled by extracting face images from existing deep fake videos and real video sources.
  • 🤖 Masonet's architecture consists of four convolutional blocks followed by a fully connected layer, optimized for image feature recognition.
  • 🔍 Batch normalization in neural networks helps improve training speed, performance, and stability by normalizing layer inputs.
  • 📊 The model's predictions are influenced by the nature of the training data, which in this case includes a significant amount of pornographic deep fakes.
  • 🔎 The video suggests a potential bias in Masonet's predictions due to the prevalence of pornographic content in the deep fake dataset.
  • 💻 The video also promotes Kite, an AI-powered coding assistant that enhances programming efficiency through features like autocompletion and documentation.

Q & A

  • What is the main topic of the video?

    -The main topic of the video is deep fakes and the exploration of a neural network called MesoNet designed to identify them.

  • What is a deep fake?

    -A deep fake refers to images, audio, or video that are fake, depicting events that never occurred, created by deep neural networks to be nearly indistinguishable from real counterparts.

  • How can deep fakes be generated?

    -Deep fakes can be generated using autoencoders, which compress and decompress image data, allowing for the blending of different images, such as merging Van Gogh's 'Starry Night' with Da Vinci's 'Mona Lisa'.

  • What is MesoNet and what is it used for?

    -MesoNet is a convolutional neural network designed to identify deep fake images. It is used to make predictions on image data to distinguish between real and deep fake images.

  • How does MesoNet handle the data it is trained on?

    -MesoNet handles data by extracting face images from existing deep fake videos and real video sources like TV shows and movies, ensuring a balanced distribution of facial angles and resolutions.

  • What is the structure of MesoNet's neural network?

    -MesoNet's neural network consists of four convolutional blocks followed by one fully connected hidden layer and an output layer for predictions.

  • What is batch normalization and why is it used in MesoNet?

    -Batch normalization is a technique that normalizes the inputs to each layer of a network to improve speed, performance, and stability. It reduces the interdependence between parameters and the input distribution of the next layer.

  • How does MesoNet make predictions on image data?

    -MesoNet makes predictions by loading weights, processing image data through its convolutional and fully connected layers, and outputting a value that indicates whether an image is real or a deep fake.

  • What is a problematic data artifact mentioned in the video regarding deep fake data?

    -A problematic data artifact is that an overwhelming amount of deep fake data is pornographic, which can lead MesoNet to use this statistical reality as a heuristic for its predictions.

  • What is Kite and how does it relate to the video?

    -Kite is an AI-powered coding assistant that helps users code faster and smarter by providing autocomplete suggestions and reducing keystrokes. It is mentioned in the video as a tool that can be integrated into various code editors.

  • What is the significance of the data collection method for MesoNet's performance?

    -The data collection method is significant because it affects the model's ability to generalize and make accurate predictions. The video discusses how MesoNet's training data, which includes a high percentage of pornographic deep fake content, could influence its predictions.

Outlines

00:00

😲 Deep Fakes and the Role of AI in Detection

Kalyn introduces the concept of deep fakes, which are AI-generated images, audio, or video that depict events that never occurred, and are nearly indistinguishable from real media. The video discusses the potential for deep fakes to be used maliciously to spread misinformation, highlighting the need for AI tools like MesoNet to identify them. The script also references a video of a deep fake of President Obama, which is actually actor Jordan Peele, to illustrate the technology's capabilities. The video will explore MesoNet's ability to predict whether images are deep fakes or real, and touch on the ethical implications and potential misuse of deep fake technology.

05:02

💻 Implementing MesoNet: An AI Model for Deep Fake Detection

This segment delves into the technical aspects of implementing MesoNet, a convolutional neural network designed to identify deep fakes. It discusses the creation of the deep fake dataset used to train MesoNet, which involved extracting face images from existing deep fake videos and real video sources. The video explains the process of auto-encoding used to generate deep fakes and how MesoNet's architecture, including its convolutional blocks and fully connected layers, contributes to its ability to make predictions. The script also introduces Kite, an AI-powered coding assistant that helps programmers code more efficiently by providing autocompletion and documentation.

10:02

🔍 Analyzing MesoNet's Performance on Deep Fake Detection

The script describes the process of preparing image data for MesoNet, including scaling pixel values and using an image data generator. It outlines the steps for creating a classifier, setting up the network architecture with convolutional and pooling layers, and loading pre-trained weights. The video then demonstrates how to use MesoNet to make predictions on individual images, discussing the implications of predicted output values and how they relate to the model's confidence in its predictions. It also introduces a plotter function to visually analyze the model's performance across different categories of images, such as correctly identified deep fakes and misclassified real images.

15:04

🚨 Addressing the Prevalence of Pornographic Deep Fakes in Datasets

The final paragraph addresses a significant issue in deep fake detection: the overwhelming presence of pornographic content in deep fake datasets. It discusses how this bias could lead MesoNet to make predictions based on the statistical likelihood of an image being pornographic rather than its authenticity. The video suggests a potential solution to this problem by proposing the use of real data from pornographic sites to balance the dataset. It concludes by summarizing the key points about deep fakes, the role of AI in detecting them, and the importance of considering data biases when training AI models.

Mindmap

Keywords

💡Deep Fakes

Deep fakes refer to the synthetic media, such as images, audio, or video, that have been manipulated using deep learning techniques to appear real. They are created by neural networks to be nearly indistinguishable from genuine content. In the video, deep fakes are exemplified by a video of President Obama that was actually created using the voice of Jordan Peele, illustrating the potential for misinformation and the challenges in discerning authenticity.

💡Neural Networks

Neural networks are a set of algorithms modeled loosely after the human brain that are designed to recognize patterns. They are used to create deep fakes by learning from and generating new content. The video discusses how these networks are 'impressive and alarming' due to their ability to create highly convincing fakes, which underscores the need for advanced detection methods.

💡Mesonet

Mesonet is a convolutional neural network designed to identify deep fakes. The video explains that it is trained to make predictions on image data to distinguish between real and fake images. Mesonet is central to the video's exploration of deep fake detection, highlighting its role in combating the spread of misinformation by accurately identifying manipulated media.

💡Autoencoders

Autoencoders are a type of neural network used for unsupervised learning, specifically for tasks like dimensionality reduction or feature learning. In the context of the video, they are mentioned as a method for generating deep fakes by compressing and decompressing data, allowing for the blending of different images, such as merging Van Gogh's 'Starry Night' with Da Vinci's 'Mona Lisa'.

💡Convolutional Neural Network (CNN)

A CNN is a class of deep neural networks most commonly applied to analyzing visual imagery. Mesonet, as described in the video, utilizes a CNN architecture with convolutional blocks to identify features in images that may indicate a deep fake. CNNs are crucial for the video's discussion on how deep fakes can be detected, as they form the basis of Mesonet's image analysis capabilities.

💡Batch Normalization

Batch normalization is a technique used to improve the training of neural networks by normalizing the inputs to each layer. In the video, it is mentioned as part of the convolutional blocks in Mesonet's architecture, which helps in stabilizing the learning process and improving the performance of the network. This concept is important for understanding how Mesonet efficiently processes and analyzes image data.

💡Max Pooling

Max pooling is an operation used in convolutional neural networks that reduces the dimensionality of the data while retaining important features. The video explains that Mesonet uses max pooling to reduce pixel values to a region's maximum value, which speeds up computation and focuses the model on significant image features, essential for the detection of deep fakes.

💡Binary Classification

Binary classification is a type of supervised learning where the goal is to classify instances into one of two classes. In the video, Mesonet is used for binary classification to predict whether an image is real or a deep fake. This concept is fundamental to the video's demonstration of Mesonet's functionality in distinguishing between authentic and synthetic media.

💡Data Stratification

Data stratification is the process of dividing data into different subsets or 'strata' to ensure that certain characteristics are evenly distributed. The video mentions that the authors of Mesonet stratified their data to ensure varied facial angles and resolutions were represented in both the real and deep fake datasets. This keyword is crucial for understanding the importance of diverse and balanced data in training accurate machine learning models.

💡Kite

Kite is an AI-powered coding assistant mentioned in the video that helps programmers write code more efficiently. While not directly related to deep fakes, Kite is highlighted as a tool that utilizes machine learning to assist with coding tasks, showcasing the broader applications of AI beyond deep fake detection and media analysis.

Highlights

Introduction to deep fakes and the challenges they pose in terms of authenticity and misinformation.

Exploration of the potential for deep fakes to be used for both creative and malicious purposes.

Discussion of the importance of developing technology to identify deep fakes to combat misinformation.

Introduction to MesoNet, a convolutional neural network designed to identify deep fakes.

Explanation of the two different models developed to identify deep fakes and their training on distinct datasets.

Overview of the process of generating deep fakes using auto encoders and the creation of a blended artwork example.

Description of how the deep fake dataset was assembled from existing videos, contrasting with generating deep fakes from scratch.

Insight into the stratification of the dataset to ensure even distribution of facial angles and resolutions.

Detailed explanation of the MesoNet architecture, including its convolutional blocks and fully connected layers.

Discussion on the role of batch normalization in improving the performance of neural networks.

Explanation of the max pooling layer's function in reducing data dimensionality for faster computation.

Demonstration of how to instantiate the MesoNet model and load its weights for prediction.

Process of preparing image data for MesoNet, including scaling and data generator setup.

Identification of potential issues with class indices and the solution to remove hidden folders affecting data processing.

Evaluation of MesoNet's predictions on individual images and the interpretation of confidence levels.

Organization of predictions into categories for analysis: correctly predicted deep fakes, reals, misclassified deep fakes, and reals.

Analysis of the problematic data artifact where deep fakes are predominantly pornographic, affecting the model's predictions.

Suggestion for neutralizing the effect of pornographic deep fakes in the dataset by balancing the data sources.

Conclusion summarizing the video's exploration of deep fakes, the MesoNet model, and the challenges in identifying deep fakes accurately.

Transcripts

play00:00

hey everybody it's kalyn from kite the

play00:01

ai-powered coding assistant

play00:03

and today we're going to explore the

play00:05

topic of deep fakes and examine a neural

play00:07

network designed to identify them

play00:09

called mesonet

play00:10

[Music]

play00:13

the concept of deep fake refers to

play00:15

images audio or video that are fakes

play00:18

that is they depict events that never

play00:20

occurred but unlike

play00:21

methods of manipulating media in the

play00:23

past like photoshop

play00:25

these deep fakes are created by deep

play00:27

neural networks to be nearly

play00:28

indistinguishable

play00:30

from their real counterparts check out

play00:32

this video of president obama addressing

play00:34

the nation for example

play00:35

we're entering an era in which our

play00:37

enemies can make it look like

play00:38

anyone is saying anything at any point

play00:40

in time did anything sound strange

play00:43

that's because it wasn't obama speaking

play00:45

it was jordan peele

play00:46

the advances in the field of deep fakes

play00:48

are equal parts impressive

play00:50

and alarming on the upside the fidelity

play00:52

with which we can alter media will

play00:54

certainly lead to some world-class

play00:56

memes but in the wrong hands this

play00:58

technology can be used to spread

play01:00

misinformation

play01:01

and undermine public trust almost like a

play01:04

sci-fi type of identity theft

play01:06

where you can get anyone to say anything

play01:08

and it's opposite

play01:09

this means that as we get better at

play01:11

generating deep fakes

play01:13

we must also get better at identifying

play01:15

them masonette is a convolutional neural

play01:18

network designed for exactly this

play01:19

purpose

play01:20

in today's video we'll use masonette to

play01:22

make predictions on image data

play01:24

we'll examine four sets of images

play01:26

correctly identify deep fakes

play01:28

correctly identified reals misidentified

play01:31

deep fakes

play01:32

and misidentified reals and we'll see

play01:34

whether the human eye can pick up on

play01:36

any insights into the world of deep

play01:38

fakes let's begin with a brief

play01:40

discussion of masonette

play01:41

and by the way you can find a link to

play01:43

the author's white paper in the

play01:44

description below

play01:46

in the paper the researchers explained

play01:48

that they had developed two different

play01:49

models to identify deep fakes

play01:51

both of which were trained and evaluated

play01:53

on two different data sets

play01:55

we will be using the meso four model

play01:57

trained on the deep fake data set

play02:00

now let's begin by exploring how deep

play02:02

fakes are generated and how this data

play02:04

set was assembled

play02:05

and then we'll proceed to the model deep

play02:07

fakes can be generated by using auto

play02:09

encoders

play02:10

at the highest level auto encoders work

play02:12

like this when the data are processed

play02:14

such as image data data get compressed

play02:16

by an encoder

play02:17

the purpose of this compression is to

play02:19

suppress the effect of noise in the data

play02:21

and to reduce

play02:22

computational complexity conversely the

play02:25

original image can be restored

play02:26

at least approximately by passing the

play02:29

compressed version of the image

play02:30

through a decoder now suppose we want to

play02:32

create a deep fake that blends van

play02:34

gogh's starry night and da vinci's mona

play02:36

lisa

play02:37

to do so when we train the auto encoders

play02:40

for different data sets

play02:41

we allow the encoders to share weights

play02:43

while keeping their decoders separate

play02:45

that way an image of the mona lisa can

play02:47

be compressed according to a general

play02:49

logic

play02:50

taking into account things like the

play02:51

illumination position

play02:53

and the expression of her face but when

play02:55

it gets restored

play02:57

this will be done according to the logic

play02:58

specific to the starry night

play03:00

which has the effect of overlaying van

play03:02

gogh's distinctive style

play03:04

onto da vinci's masterpiece although

play03:07

this is how deep fakes are

play03:08

often generated the authors note that

play03:10

their deep fake data set was created

play03:12

differently

play03:13

rather than generating deep fakes from

play03:14

scratch which they explained would limit

play03:17

the amount

play03:17

and diversity of the fake data that they

play03:19

could then feed masonette

play03:21

they chose to extract face images from

play03:23

existing deep fake videos

play03:25

they used about 175 existing videos

play03:29

pulled from popular deep fake

play03:31

platforms and that created their deep

play03:33

fake data set

play03:34

they explained that they extracted the

play03:35

specific frames that contain

play03:37

faces from the deep fake videos they

play03:39

also note that they followed a similar

play03:41

process for extracting the real

play03:43

image data from real video sources like

play03:45

tv shows and movies

play03:47

and finally they explain how they

play03:49

stratified their data so that the

play03:50

various angles of the faces and levels

play03:52

of resolution

play03:53

were distributed evenly across the real

play03:56

and deep fake data sets

play03:58

since machine learning is all about

play04:00

finding patterns in data

play04:01

it's actually extremely important to

play04:03

understand the nature of the data and

play04:05

how it's collected

play04:06

because you're ultimately going to feed

play04:07

that through a model to understand it

play04:09

as you'll see later with this

play04:11

understanding of the data we reveal some

play04:13

important insights

play04:14

but stick around for that let's first

play04:15

explore the model

play04:17

meso4 is a convolutional neural network

play04:20

with four convolutional blocks followed

play04:22

by one

play04:23

fully connected hidden layer as we

play04:26

reproduce the model we'll explain what

play04:28

each of these means

play04:29

and you can find a link to the masonette

play04:31

authors repository in the description as

play04:33

well below

play04:34

i want to take a minute to talk about

play04:36

kite which is an ai-powered

play04:37

coding assistant that'll help you code

play04:39

faster and smarter

play04:41

whether you're new to python or already

play04:43

a pro you should try out kite as your

play04:45

autocomplete to reduce your keystrokes

play04:46

and save time programming

play04:48

i use a free plugin for your code editor

play04:50

that uses machine learning to save you

play04:52

keystrokes while you're programming

play04:53

so if you're using atom vs code spyder

play04:56

pycharm

play04:57

sublime or vim kite will seamlessly

play04:59

integrate into your coding workflow

play05:01

kite can complete entire lines of code

play05:03

and it has a feature called intelligent

play05:05

snippets that will help you fill in

play05:06

arguments and method calls with

play05:08

variables defined earlier in your script

play05:10

the window on the right side of my

play05:11

screen here is also a kite feature

play05:14

called the kite copilot

play05:15

it automatically shows you relevant

play05:17

python documentation while you type

play05:19

based on your cursor location this saves

play05:21

you time from having to google search

play05:23

for docs the best part of kite is that

play05:25

it's free and you can download it from

play05:26

the link in the description below

play05:29

let's begin with our imports

play05:34

and then let's create a dictionary

play05:36

called image dimensions to store our

play05:38

image dimensions

play05:39

which are the height and width of the

play05:41

image in pixels

play05:43

and the number of color channels we set

play05:46

the height and the width to 256

play05:49

and since we're using color images we

play05:51

want to set the channels to three

play05:54

then we create a classifier class just

play05:56

as the authors had done

play05:58

which makes for very neat code by

play05:59

prescribing just the essential methods

play06:01

for the network in simple terms

play06:03

we will be using the methods to load

play06:05

weights and to make predictions

play06:10

and next let's create a mesa 4 class the

play06:13

mesa 4 class takes just one argument

play06:16

and that's the classifier class we just

play06:18

created we set the gradient descent

play06:20

optimizer and we set its learning rate

play06:23

in the constructor

play06:24

and we set the parameters to compile the

play06:26

model

play06:29

now it's time to create the network

play06:30

architecture we create a method called

play06:33

init

play06:33

model first we create our input layer

play06:36

and assign it to the variable x

play06:38

for the input layer we just need to pass

play06:40

the three dimensions of our image data

play06:42

then we create our four convolutional

play06:45

blocks

play06:46

convolutional blocks always include a

play06:47

convolutional layer

play06:49

and a max pooling layer and in masonette

play06:51

these blocks also include a batch

play06:53

normalization layer

play06:55

the convolutional layer represented by

play06:57

conv 2d

play06:58

is the trickiest part here we set the

play07:01

size

play07:01

and the number of filters we will use in

play07:03

convolution

play07:04

check out this illustration here's how

play07:07

it works

play07:08

each filter represents a distinct image

play07:10

feature for example a horizontal line

play07:13

during convolution this filter is passed

play07:15

over an image to assess the degree to

play07:17

which specific regions of that image

play07:19

correspond with the filter if you're a

play07:21

math whiz this is done by calculating

play07:23

the dot product of the filter

play07:25

with each filter size region of the

play07:28

image for each of the color channels

play07:30

for the rest of us the important thing

play07:32

to know is that the filter

play07:33

identifies the existence and location of

play07:36

specific image features

play07:38

like horizontal or vertical lines

play07:41

after the convolutional layer comes the

play07:42

batch normalization layer

play07:44

batch normalization is a novel technique

play07:46

for improving the speed

play07:48

performance and stability of neural

play07:50

networks

play07:51

it works by normalizing the inputs to

play07:53

each layer of the network

play07:55

which reduces the interdependence

play07:57

between the parameters for a given layer

play07:59

and the input distribution of the next

play08:01

layer

play08:02

this interdependence is called internal

play08:05

covariate

play08:06

shift and it has a destabilizing effect

play08:08

on the learning process

play08:10

for more about batch normalization check

play08:12

out the link in the description below

play08:14

the last layer of our convolutional

play08:16

blocks is the pooling layer

play08:18

it is in the pooling layer that we

play08:19

significantly reduce the dimensionality

play08:21

of our data

play08:22

which greatly speeds up computation

play08:25

masonette uses max pooling for this

play08:27

layer

play08:27

which means we reduce a region of pixel

play08:30

values to that region's maximum value

play08:32

it may seem like we're throwing away too

play08:34

much data in this pooling layer

play08:36

but remember during convolution our

play08:39

model was able to locate

play08:40

important image features which means we

play08:42

can focus on just the parts that matter

play08:44

most

play08:45

think about your own visual field right

play08:47

now odds are you're focusing on a very

play08:49

small subset of the available data

play08:51

just like masonette with successive

play08:54

blocks in the convolutional base

play08:56

cnns proceed to higher order feature

play08:58

representations

play08:59

from lines to corners to shapes to faces

play09:03

masonette has four blocks in its

play09:04

convolutional base followed by a fully

play09:07

connected hidden layer

play09:08

and then the output layer for the

play09:10

prediction now that we've got the

play09:11

network architecture established

play09:13

we need to instantiate the model and

play09:15

load the weights

play09:16

we download the weights from the

play09:18

masonette github repo and then save the

play09:20

file mesa 4

play09:21

df in a folder called weights

play09:24

we load the weights using the load

play09:26

method of our classifier by specifying

play09:28

the file path

play09:29

mesonet is now ready to make predictions

play09:31

on image data

play09:32

so next up we start preparing our image

play09:34

data we download the deep fake

play09:37

validation data set

play09:38

from the mesonet github repo again

play09:40

that's linked in the description below

play09:42

we structure our real and deep fake

play09:44

image data in separate folders

play09:46

underneath a folder we call

play09:48

data this is important for the flow from

play09:50

directory method

play09:51

which infers classes from the file

play09:53

structure

play09:55

the pixel values in our image data exist

play09:57

in the range between 0

play09:58

and 255. large integer coefficients like

play10:02

this

play10:02

complicate gradient descent when using

play10:04

typical learning rates

play10:06

so the next step is to scale our data by

play10:08

a factor of one

play10:09

divided by 255 that way the pixel values

play10:13

fall into the range from zero to one

play10:16

we instantiate our image data generator

play10:18

that rescales our images

play10:20

then we pass in our data by specifying

play10:22

the directory path to our data folder

play10:24

we set the batch size to 1 so we process

play10:27

images individually

play10:28

and then we set the class mode to binary

play10:30

for a binary classification task of

play10:33

predicting images

play10:34

as real or deep fake

play10:37

now let's check our class indices

play10:40

flow from directory should have inferred

play10:42

the names of our classes from the names

play10:43

of the sold folders within the data

play10:45

folder

play10:46

and there should be just two classes

play10:48

where our deep fakes are represented by

play10:50

zero

play10:51

and are reals by one there are two

play10:53

problems that might arise

play10:55

first if your classes are reversed such

play10:57

that your deep fakes are represented by

play10:58

one

play10:59

and the reals by zero you'll have to

play11:01

flip mesonet predictions by subtracting

play11:03

these values from one

play11:05

the second issue relates to having more

play11:06

than just two classes

play11:08

as we discussed flow from directory uses

play11:10

file structure to process data

play11:12

and is therefore sensitive to the

play11:14

structure many ids including jupiter

play11:16

labs which we're using today

play11:18

will conduct periodic autosaves and

play11:20

store this data in

play11:21

hidden folders called i pymb

play11:24

checkpoints this extra folder

play11:27

compromises the flow from directory

play11:28

method

play11:29

so we'll have to remove it we can do

play11:32

this by opening our terminal

play11:33

accessing the working directory that

play11:34

holds our data and removing the hidden

play11:36

file

play11:38

or we can do this directly from a

play11:39

jupiter cell by using a magic command

play11:42

we just type the exclamation mark to

play11:44

invoke the command line interface

play11:46

and then issue our command to remove

play11:47

this file

play11:49

after this let's return the image data

play11:51

generator and recheck our class

play11:53

indices to ensure we successfully

play11:55

removed this autosave folder

play12:04

great things are looking good now and

play12:06

we're ready to pass in an image through

play12:08

mesonet

play12:09

the generator.next method returns two

play12:12

items the pixel data of a given image

play12:14

and the actual label for it whether it's

play12:17

real or a deep fake

play12:18

so let's set variables x and y equal to

play12:21

generator.next

play12:22

let's write three print statements to

play12:24

evaluate the prediction

play12:26

for the first let's show mason that's

play12:27

predicted output for the image

play12:29

rounded to four digits for the second

play12:32

let's show the actual label and for the

play12:35

third let's see whether masonette's

play12:37

prediction is accurate

play12:38

that is whether the actual label

play12:40

corresponds with masonette's predicted

play12:42

output after rounding to 0

play12:44

or 1. we can also see the image in

play12:46

question by using the m show

play12:48

function from the matplotlib dot pi plot

play12:51

package

play12:52

our x data currently has an extra

play12:54

dimension for its position in the batch

play12:56

and this needs to be removed before

play12:57

imshow can properly render the image

play13:00

we can do this by using the numpy

play13:01

function squeeze passing numpy.squeezex

play13:05

as the argument

play13:06

for plot m show

play13:15

now we can see how mesonet performed on

play13:17

a particular image

play13:21

when predicted outputs are nearly 0 or 1

play13:23

this corresponds with high degree of

play13:25

confidence in the prediction

play13:27

but when the predicted output approaches

play13:28

0.5 the confidence in the model

play13:30

prediction approaches a random guess

play13:33

so let's run this a few more times and

play13:35

let's see if we see

play13:36

any patterns

play13:44

let's organize our predictions into four

play13:46

categories correctly predicted deep

play13:48

fakes

play13:49

correctly predicted reels misclassified

play13:52

deep fakes

play13:53

and misclassified reels

play13:57

and we create lists to keep track of

play13:58

which images fall into each category

play14:01

then we write a for loop to iterate

play14:03

through our data set and sort each

play14:04

observation into one of these four

play14:06

categories

play14:07

we create two lists for each category

play14:09

one to store the image data

play14:11

and the other to store the corresponding

play14:13

prediction value

play14:19

now let's create our plotter function

play14:21

which we'll use to show random batches

play14:23

of images in each category

play14:25

plotter takes two arguments a list of

play14:28

image data and the list of corresponding

play14:30

predictions

play14:31

we use an f string for the x label so we

play14:33

can show mesonet's predicted output for

play14:35

the image in question

play14:38

let's check out a collection of

play14:39

correctly identified real images

play14:41

we pass correct real and correct real

play14:44

pred

play14:44

into our plotter function

play14:49

checking out these images things look

play14:50

pretty good you might see some

play14:52

characters from tv or movies that you

play14:54

recognize here

play14:55

look at the predicted output for the

play14:56

images the closer these values are to

play14:59

one the more confidence masonette

play15:00

has that the image is real notice that

play15:03

most of these outputs vary between a

play15:05

range pretty close to one

play15:08

okay for contrast let's look at real

play15:10

images that were misclassified as deep

play15:13

fakes

play15:14

let's again use our plotter function but

play15:16

this time we pass it misclassified real

play15:18

and misclassified real pred

play15:23

although these are all representing

play15:25

errors it is reassuring to note that the

play15:27

model's confidence for these predictions

play15:29

tends to be closer to 0.5 and that's to

play15:32

say that it's less confident in these

play15:33

predictions that turned out to be wrong

play15:35

so it's pretty much a guess and i guess

play15:37

that's okay

play15:42

now let's check our correctly identified

play15:44

deep fakes

play15:49

whoa okay that's an

play15:52

odd pattern in our data there

play15:55

and let's also check the deep fakes

play15:57

misclassified as real

play16:08

we now return to masonette's method of

play16:10

collecting deep fake data

play16:12

you may recall that they acquired deep

play16:14

fake image data from popular deep fake

play16:16

video platforms that are online

play16:18

well according to the september 2019

play16:20

report called the state of deep fakes

play16:23

conducted by deep trace labs 96

play16:26

of deep fake media is pornographic deep

play16:29

fake pornography is among

play16:31

the worst abuses in the world of deep

play16:33

fakes and besides being a significant

play16:35

social issue this also complicates the

play16:37

technical side of our deep fake

play16:38

classifier

play16:39

here is why masonette was trained on

play16:42

real data

play16:43

acquired from tv and movies sources that

play16:46

offer a great variety of facial

play16:47

expressions and settings

play16:48

however the deep fake data that the

play16:50

authors acquired

play16:52

was from popular deep fake platforms on

play16:54

the internet sources that are

play16:55

overwhelmingly dominated by pornographic

play16:57

content

play16:58

therefore it's expected that the model

play17:00

took advantage of a data artifact

play17:02

the statistical reality that deep fakes

play17:04

tend to be pornographic

play17:06

and reals tend to be non-pornographic

play17:08

and used it as a heuristic for its

play17:10

predictions

play17:11

the authors explain that the models make

play17:13

predictions under real conditions of

play17:14

diffusion on the internet

play17:16

which explains their use of popular deep

play17:18

fake platforms including pornographic

play17:20

websites

play17:21

one wonders then whether we can

play17:23

neutralize this effect and force the

play17:24

model to recognize deep fakes without

play17:26

the aid of statistical accidents

play17:28

by using some different data since deep

play17:31

fake data is limited in supply

play17:33

and overwhelmingly pornographic we could

play17:35

acquire our real data from pornographic

play17:37

sites as well

play17:38

rather than just tv shows and movies and

play17:40

unlike deep fake data pornography is

play17:42

relatively easy to find on the internet

play17:44

or so i've heard today we talked about

play17:48

deep fakes

play17:49

what they are how they're generated and

play17:50

why they matter

play17:52

we examined a model designed to identify

play17:54

deep fake images called masonette

play17:56

and we implemented it to explore how it

play17:58

works in doing so we did encounter a

play18:00

problematic data artifact

play18:02

that an overwhelming amount of deep fake

play18:04

images are indeed pornographic

play18:07

we explained why this matters and we

play18:09

gave a suggestion for how we could

play18:10

potentially neutralize this effect

play18:12

well i hope you enjoyed today's video

play18:14

and that you learned something about

play18:15

deep fakes and neural nets

play18:17

make sure to subscribe to our channel

play18:18

for more data science content like this

play18:20

and remember to download kite the ai

play18:22

powered coding assistant

play18:24

so you can code faster and smarter

Rate This

5.0 / 5 (0 votes)

関連タグ
Deep FakesNeural NetworksAI AssistantMedia ManipulationMesonetData ScienceFake DetectionMachine LearningCoding ToolsKite AI
英語で要約が必要ですか?