Hi and welcome back in this section, we'll take a look at using fierceness and PyTorch to perform facial
similarity.
So let's get started by opening Notebook 40 and we'll begin to listen.
So firstly, a bit about face that face that uses something called an empty CNN, which stands for multitask
cascaded convolutional network.
It's what it means the architecture that was designed for this and its network.
And it also uses to resonate as a backbone inside of that work.
So it's pretty cool.
So let's take a look.
So firstly, to use this network, we have to clone the repo here.
This is the face that ripple and then installed to install the first net PyTorch module here, which
I've already done.
So you can go ahead and do it.
Run these blocks of code if you're quite short to execute.
Next, we'll look at some of the modules that will be using in Python.
And as well as the weather, we're using GPU or CPU, hopefully.
Let's actually tune on CPU here.
Well, actually, Olivia lived a CPA because it works fine in this CPU.
Anyway, we're not training.
So what we do here, we create no, the MTC, another module.
And these are the parameters that we're recommending.
We specify from the get repo.
These are just some basic parameters.
You can mess with this later on, but they wouldn't interfere with this right now.
And then what we're going to do, we're going to use the big face to network the weights for out here
until the inception resonant V1 module.
So we create the resonant here.
So this might seem a bit confusing, but what's happening here is just this is just the name of the
weird section.
The Inception Resonant V1 network is being has is moving onto, so we have to resonant model here.
Next, we define the data sets in detail what else.
So we just created quickly a function to call it.
And then we'll just use that to enable data loader here.
And let's run that.
That's really been run, actually.
And we just pointed to our test images here.
That's what we'll be using to identify names later on.
So we can quickly view some of the images in our dataset here to test images here so you can take a
look at them there.
These are some of the images of celebrities.
No, what we're going to do.
We're going to use the empty CNN to perform facial recognition.
So how do we do that?
Well, we just it's actually quite simple.
All we have to do is just run the input from our order to the MTC in a module here and return the probabilities
productive equal to true.
So we get the aligned fierce output as well as a probability if X is not, if it's none.
I mean, just with the fierce wasn't detected.
If it if it's not known, it means a face was detected and we can output the probability as well.
So then let's run that and you can see we just just detects probability would face here.
So that's it.
So we get the facial prefaces detected there.
I should have said this is actually just facial detection going on right here.
What we did remember, we need to get the extract defense first.
So MTNL has a facial detection module, which I should have mentioned initially.
So that's for the faces detected in the image here, and we store them in disarray.
So no, we can calculate the facial embedding.
So what we're going to do, we're going to compare the faces that we extracted in that area.
So to do that, we put a single batch of data and then we perform inference on it here.
As you can see, this is what we do.
So we just create a batch here from the images that we got above that's in the aligned array and then
this person to the network and then send it to the CPU to get the embeddings out afterward.
And then we can now visualize print in the data frame here that shows the embedding.
So it just shows you here.
Angelina Jolie is basically their own, similar to the original Angelina Jolie image, which is obvious.
And then you can see which celebrity she's more similar to.
Apparently, kids single.
Let's take a look at the images here.
So Angelina Jolie was more similar to Kate Siegel, and actually, they do look quite similar.
So you can see Bradley Cooper was more similar to Paul Rudd and then shared with him a bit afterward.
Kate Siegel is actually going to be more similar to Angelina Jolie and seems to get the same matching
score above, which makes sense.
And you can see how it works for all of them as well.
So this is pretty cool.
So if you have like a big family and you want to see who resembles who the most, you can run them through
this code here and then get the similarity of scores.
Probably a fun project to do.
Or you get if you have a group of friends, you can do it as well.
It would be pretty cool.
So that's it for this lesson.
So what we'll do next, we'll take a look at deep deepfakes, which allows us to do age, gender expression
and facial recognition and a few other things as well.
So stay tuned for that.
It's going to be quite cool.
Thank you.