1
00:00:00,450 --> 00:00:01,710
Welcome back to the course.

2
00:00:01,890 --> 00:00:07,770
Now let's move on to facial unlock detection with the DELIV library, so open this notebook.

3
00:00:08,010 --> 00:00:09,240
Let me do that now.

4
00:00:10,590 --> 00:00:17,850
And this will include our instructional notebook that demonstrates how we can actually get extract and

5
00:00:17,850 --> 00:00:21,750
plot facial landmarks on a picture of a face effectively.

6
00:00:22,470 --> 00:00:28,590
So let's look at all libraries and pictures and our model, which is a safe predictor, which gives

7
00:00:28,590 --> 00:00:31,500
us 68 facial landmarks, and I'll show you how to use that.

8
00:00:32,040 --> 00:00:34,140
So let's go ahead and put these libraries.

9
00:00:34,170 --> 00:00:36,360
Notice we're importing a library called Dylib.

10
00:00:36,990 --> 00:00:43,200
Dylib is a very cool sort of like a machine learning library that has a lot of cool features.

11
00:00:43,200 --> 00:00:49,160
We can load this model in it here, and we can actually use models know that these are the models.

12
00:00:49,170 --> 00:00:53,580
Here is a that file and use them to get the facial landmarks.

13
00:00:53,700 --> 00:00:56,310
So let's take a look at the score quickly.

14
00:00:56,970 --> 00:01:02,470
So what we're doing here, we're just putting the part of model in this variable here.

15
00:01:03,120 --> 00:01:05,940
We're loading the predictor that's a predictor object from dylib.

16
00:01:06,300 --> 00:01:10,380
So it delivered what she predicts and we just point to the part of the model.

17
00:01:11,190 --> 00:01:15,930
And then we create the detector here from using the deliberate frontal office.

18
00:01:16,440 --> 00:01:21,840
The reason we have this is because we need to firstly extract office from the image.

19
00:01:22,320 --> 00:01:29,040
So remember when we did it, her cascade visual detection detecting method, we got a bounding box that

20
00:01:29,040 --> 00:01:30,660
was covering the face.

21
00:01:31,170 --> 00:01:36,420
That's this is the lab's version of that so we can use to deliver get frontal face detector, which

22
00:01:36,420 --> 00:01:38,280
is built into the library, which is pretty cool.

23
00:01:39,180 --> 00:01:40,280
So we have a class.

24
00:01:40,290 --> 00:01:42,810
This class can pretty much ignore these here.

25
00:01:42,840 --> 00:01:45,990
These are just two room area exceptions.

26
00:01:46,740 --> 00:01:48,240
This is the part we need to look at here.

27
00:01:48,250 --> 00:01:50,340
Get landmarks, which is a simple function.

28
00:01:50,730 --> 00:01:51,570
Takes in an image.

29
00:01:51,990 --> 00:01:53,220
Runs it through the detector.

30
00:01:53,250 --> 00:01:54,330
That's the setup to here.

31
00:01:55,110 --> 00:01:56,700
Returns to bounding boxes here.

32
00:01:57,240 --> 00:02:03,570
If it gives us one in one rectangle, a bowling box of Brexit with a link to four x over one.

33
00:02:04,200 --> 00:02:06,600
We raised the arrow in too many faces here.

34
00:02:07,260 --> 00:02:12,040
Otherwise, if we do, if it's equal to zero, we get new faces.

35
00:02:12,040 --> 00:02:13,650
So exactly, we want exactly one.

36
00:02:13,770 --> 00:02:15,330
Effectively, one piece.

37
00:02:16,290 --> 00:02:18,780
And then this is a part where we actually run the predictor.

38
00:02:19,710 --> 00:02:20,730
We take the image here.

39
00:02:21,330 --> 00:02:26,250
Particular X introduce the first X, which is the only value we want one piece.

40
00:02:26,970 --> 00:02:31,690
So we run it through the predictor here using the Stockport's function due process.

41
00:02:31,690 --> 00:02:33,540
And they did write in the right format.

42
00:02:34,350 --> 00:02:38,810
And then we just put it into this p dot x y.

43
00:02:39,750 --> 00:02:44,970
This is a list comprehension here for the predictions, the landmark predictions that we get from predictor.

44
00:02:45,420 --> 00:02:49,330
Yeah, this is the X and Y coordinates of to all those landmark predictions.

45
00:02:50,070 --> 00:02:52,050
And we just don't agree with that number.

46
00:02:52,050 --> 00:02:52,920
No matrix after.

47
00:02:53,250 --> 00:02:56,970
So this might seem like a confusing line of code for beginners.

48
00:02:56,970 --> 00:02:58,410
And indeed, it is.

49
00:02:58,410 --> 00:03:04,500
Actually, Python does a lot of things in one line, which is one of the great things about Python,

50
00:03:04,500 --> 00:03:08,010
but it can affect readability sometimes, too.

51
00:03:08,640 --> 00:03:15,510
For people coming from Java or C++ backgrounds, oh, this might probably take you like 20 lines of

52
00:03:15,520 --> 00:03:16,680
10 lines of code sometimes.

53
00:03:18,180 --> 00:03:25,110
So this is the other part of the function here where it draws the line marks that we get onto the face.

54
00:03:25,350 --> 00:03:27,300
So that's it's a simple function, actually.

55
00:03:27,900 --> 00:03:33,480
So we just take the landmarks, you get the points and you can see where points are here and get the

56
00:03:33,480 --> 00:03:34,230
position here.

57
00:03:34,770 --> 00:03:40,050
And we just draw little circles around them here and we just use Botox here.

58
00:03:40,410 --> 00:03:47,010
This just puts the text, which is each no numbers the points on the face so we can draw that there.

59
00:03:47,550 --> 00:03:49,230
So not use these functions.

60
00:03:49,480 --> 00:03:52,860
Just simply load the image here, including image of the Donald Trump.

61
00:03:53,760 --> 00:04:00,000
Then we're showing the original the original image, getting the landmarks and then taken as landmarks

62
00:04:00,000 --> 00:04:05,250
and giving it into another function called annotate landmarks, which draws the visual landmarks on

63
00:04:05,250 --> 00:04:05,760
the image.

64
00:04:06,450 --> 00:04:10,590
And then we're showing the output that produces an image, and then we show that result here.

65
00:04:10,980 --> 00:04:15,390
So let's run this and take a look at our cool output.

66
00:04:16,740 --> 00:04:17,190
Ta da.

67
00:04:17,340 --> 00:04:18,810
So this is very cool.

68
00:04:19,980 --> 00:04:21,960
It actually this is this works quite well.

69
00:04:22,320 --> 00:04:24,870
You can see it gives us all of the landmarks.

70
00:04:24,870 --> 00:04:31,080
I think from this point, going counterclockwise on his face and it draws eyes, and all of these numbers

71
00:04:31,080 --> 00:04:33,780
do correspond to positions consistently.

72
00:04:33,780 --> 00:04:39,150
So numbers twenty seven twenty twenty nine, all this we didn't know bridge of someone's views.

73
00:04:39,570 --> 00:04:40,820
The lips always be this.

74
00:04:40,820 --> 00:04:47,790
So you can actually use these these values, these numbers to basically detect if someone's lips moving,

75
00:04:48,600 --> 00:04:51,090
if they're open, closed its eyes open and close.

76
00:04:51,990 --> 00:04:53,070
So it's pretty cool.

77
00:04:53,400 --> 00:04:59,040
You can actually do a lot of facial analytics with this type of stuff so that now let's do it again.

78
00:04:59,190 --> 00:04:59,750
And the student.

79
00:04:59,880 --> 00:05:01,080
Hillary Clinton.

80
00:05:04,080 --> 00:05:04,980
And there we go.

81
00:05:05,490 --> 00:05:09,570
So we draw the fish with crude fish lot marks on her as well.

82
00:05:10,230 --> 00:05:12,330
So that's it for this lesson.

83
00:05:12,780 --> 00:05:14,880
I hope you enjoyed using this.

84
00:05:14,910 --> 00:05:19,080
We're going to move on to fish swaps here and actually remove the crude from the sea, wouldn't it,

85
00:05:19,080 --> 00:05:19,710
in this notebook?

86
00:05:20,040 --> 00:05:21,750
It's going to be in the second.

87
00:05:22,110 --> 00:05:27,600
The next lesson, which is this in twenty eight fish using Velib to do fish swaps.

88
00:05:28,200 --> 00:05:30,900
So let's stop there now, and I'll see you in the next lesson.

89
00:05:31,080 --> 00:05:31,500
Thank you.
