Welcome back to the course.
Now let's move on to facial unlock detection with the DELIV library, so open this notebook.
Let me do that now.
And this will include our instructional notebook that demonstrates how we can actually get extract and
plot facial landmarks on a picture of a face effectively.
So let's look at all libraries and pictures and our model, which is a safe predictor, which gives
us 68 facial landmarks, and I'll show you how to use that.
So let's go ahead and put these libraries.
Notice we're importing a library called Dylib.
Dylib is a very cool sort of like a machine learning library that has a lot of cool features.
We can load this model in it here, and we can actually use models know that these are the models.
Here is a that file and use them to get the facial landmarks.
So let's take a look at the score quickly.
So what we're doing here, we're just putting the part of model in this variable here.
We're loading the predictor that's a predictor object from dylib.
So it delivered what she predicts and we just point to the part of the model.
And then we create the detector here from using the deliberate frontal office.
The reason we have this is because we need to firstly extract office from the image.
So remember when we did it, her cascade visual detection detecting method, we got a bounding box that
was covering the face.
That's this is the lab's version of that so we can use to deliver get frontal face detector, which
is built into the library, which is pretty cool.
So we have a class.
This class can pretty much ignore these here.
These are just two room area exceptions.
This is the part we need to look at here.
Get landmarks, which is a simple function.
Takes in an image.
Runs it through the detector.
That's the setup to here.
Returns to bounding boxes here.
If it gives us one in one rectangle, a bowling box of Brexit with a link to four x over one.
We raised the arrow in too many faces here.
Otherwise, if we do, if it's equal to zero, we get new faces.
So exactly, we want exactly one.
Effectively, one piece.
And then this is a part where we actually run the predictor.
We take the image here.
Particular X introduce the first X, which is the only value we want one piece.
So we run it through the predictor here using the Stockport's function due process.
And they did write in the right format.
And then we just put it into this p dot x y.
This is a list comprehension here for the predictions, the landmark predictions that we get from predictor.
Yeah, this is the X and Y coordinates of to all those landmark predictions.
And we just don't agree with that number.
No matrix after.
So this might seem like a confusing line of code for beginners.
And indeed, it is.
Actually, Python does a lot of things in one line, which is one of the great things about Python,
but it can affect readability sometimes, too.
For people coming from Java or C++ backgrounds, oh, this might probably take you like 20 lines of
10 lines of code sometimes.
So this is the other part of the function here where it draws the line marks that we get onto the face.
So that's it's a simple function, actually.
So we just take the landmarks, you get the points and you can see where points are here and get the
position here.
And we just draw little circles around them here and we just use Botox here.
This just puts the text, which is each no numbers the points on the face so we can draw that there.
So not use these functions.
Just simply load the image here, including image of the Donald Trump.
Then we're showing the original the original image, getting the landmarks and then taken as landmarks
and giving it into another function called annotate landmarks, which draws the visual landmarks on
the image.
And then we're showing the output that produces an image, and then we show that result here.
So let's run this and take a look at our cool output.
Ta da.
So this is very cool.
It actually this is this works quite well.
You can see it gives us all of the landmarks.
I think from this point, going counterclockwise on his face and it draws eyes, and all of these numbers
do correspond to positions consistently.
So numbers twenty seven twenty twenty nine, all this we didn't know bridge of someone's views.
The lips always be this.
So you can actually use these these values, these numbers to basically detect if someone's lips moving,
if they're open, closed its eyes open and close.
So it's pretty cool.
You can actually do a lot of facial analytics with this type of stuff so that now let's do it again.
And the student.
Hillary Clinton.
And there we go.
So we draw the fish with crude fish lot marks on her as well.
So that's it for this lesson.
I hope you enjoyed using this.
We're going to move on to fish swaps here and actually remove the crude from the sea, wouldn't it,
in this notebook?
It's going to be in the second.
The next lesson, which is this in twenty eight fish using Velib to do fish swaps.
So let's stop there now, and I'll see you in the next lesson.
Thank you.