1
00:00:00,180 --> 00:00:06,240
Hi and welcome back in this section, we'll take a look at using fierceness and PyTorch to perform facial

2
00:00:06,240 --> 00:00:07,030
similarity.

3
00:00:07,050 --> 00:00:11,590
So let's get started by opening Notebook 40 and we'll begin to listen.

4
00:00:11,640 --> 00:00:19,490
So firstly, a bit about face that face that uses something called an empty CNN, which stands for multitask

5
00:00:19,490 --> 00:00:21,750
cascaded convolutional network.

6
00:00:22,260 --> 00:00:27,210
It's what it means the architecture that was designed for this and its network.

7
00:00:27,630 --> 00:00:31,790
And it also uses to resonate as a backbone inside of that work.

8
00:00:31,800 --> 00:00:32,700
So it's pretty cool.

9
00:00:33,270 --> 00:00:34,540
So let's take a look.

10
00:00:34,560 --> 00:00:38,160
So firstly, to use this network, we have to clone the repo here.

11
00:00:38,640 --> 00:00:44,640
This is the face that ripple and then installed to install the first net PyTorch module here, which

12
00:00:44,640 --> 00:00:45,510
I've already done.

13
00:00:45,930 --> 00:00:47,580
So you can go ahead and do it.

14
00:00:47,580 --> 00:00:50,670
Run these blocks of code if you're quite short to execute.

15
00:00:51,420 --> 00:00:54,690
Next, we'll look at some of the modules that will be using in Python.

16
00:00:55,380 --> 00:00:58,800
And as well as the weather, we're using GPU or CPU, hopefully.

17
00:00:59,400 --> 00:01:02,310
Let's actually tune on CPU here.

18
00:01:02,340 --> 00:01:05,460
Well, actually, Olivia lived a CPA because it works fine in this CPU.

19
00:01:05,670 --> 00:01:06,660
Anyway, we're not training.

20
00:01:08,250 --> 00:01:12,180
So what we do here, we create no, the MTC, another module.

21
00:01:12,570 --> 00:01:14,820
And these are the parameters that we're recommending.

22
00:01:14,820 --> 00:01:16,860
We specify from the get repo.

23
00:01:17,670 --> 00:01:19,500
These are just some basic parameters.

24
00:01:19,500 --> 00:01:22,830
You can mess with this later on, but they wouldn't interfere with this right now.

25
00:01:23,520 --> 00:01:30,330
And then what we're going to do, we're going to use the big face to network the weights for out here

26
00:01:30,780 --> 00:01:33,290
until the inception resonant V1 module.

27
00:01:33,330 --> 00:01:35,310
So we create the resonant here.

28
00:01:35,850 --> 00:01:40,470
So this might seem a bit confusing, but what's happening here is just this is just the name of the

29
00:01:40,470 --> 00:01:41,280
weird section.

30
00:01:41,670 --> 00:01:49,020
The Inception Resonant V1 network is being has is moving onto, so we have to resonant model here.

31
00:01:50,100 --> 00:01:52,580
Next, we define the data sets in detail what else.

32
00:01:52,580 --> 00:01:55,290
So we just created quickly a function to call it.

33
00:01:56,010 --> 00:01:59,490
And then we'll just use that to enable data loader here.

34
00:02:00,300 --> 00:02:01,410
And let's run that.

35
00:02:01,410 --> 00:02:02,850
That's really been run, actually.

36
00:02:02,940 --> 00:02:05,740
And we just pointed to our test images here.

37
00:02:06,270 --> 00:02:09,630
That's what we'll be using to identify names later on.

38
00:02:10,950 --> 00:02:17,220
So we can quickly view some of the images in our dataset here to test images here so you can take a

39
00:02:17,220 --> 00:02:18,300
look at them there.

40
00:02:18,330 --> 00:02:21,540
These are some of the images of celebrities.

41
00:02:24,900 --> 00:02:26,370
No, what we're going to do.

42
00:02:26,400 --> 00:02:30,480
We're going to use the empty CNN to perform facial recognition.

43
00:02:31,110 --> 00:02:32,370
So how do we do that?

44
00:02:32,400 --> 00:02:34,230
Well, we just it's actually quite simple.

45
00:02:34,860 --> 00:02:43,470
All we have to do is just run the input from our order to the MTC in a module here and return the probabilities

46
00:02:43,470 --> 00:02:44,640
productive equal to true.

47
00:02:45,120 --> 00:02:51,000
So we get the aligned fierce output as well as a probability if X is not, if it's none.

48
00:02:51,540 --> 00:02:53,700
I mean, just with the fierce wasn't detected.

49
00:02:53,700 --> 00:02:59,610
If it if it's not known, it means a face was detected and we can output the probability as well.

50
00:03:00,270 --> 00:03:06,750
So then let's run that and you can see we just just detects probability would face here.

51
00:03:06,900 --> 00:03:07,650
So that's it.

52
00:03:08,100 --> 00:03:10,530
So we get the facial prefaces detected there.

53
00:03:11,160 --> 00:03:14,730
I should have said this is actually just facial detection going on right here.

54
00:03:15,270 --> 00:03:18,630
What we did remember, we need to get the extract defense first.

55
00:03:19,080 --> 00:03:23,310
So MTNL has a facial detection module, which I should have mentioned initially.

56
00:03:24,690 --> 00:03:30,420
So that's for the faces detected in the image here, and we store them in disarray.

57
00:03:31,170 --> 00:03:33,720
So no, we can calculate the facial embedding.

58
00:03:33,720 --> 00:03:38,460
So what we're going to do, we're going to compare the faces that we extracted in that area.

59
00:03:39,150 --> 00:03:45,210
So to do that, we put a single batch of data and then we perform inference on it here.

60
00:03:45,600 --> 00:03:47,160
As you can see, this is what we do.

61
00:03:47,160 --> 00:03:53,760
So we just create a batch here from the images that we got above that's in the aligned array and then

62
00:03:53,760 --> 00:04:00,150
this person to the network and then send it to the CPU to get the embeddings out afterward.

63
00:04:00,720 --> 00:04:05,640
And then we can now visualize print in the data frame here that shows the embedding.

64
00:04:05,640 --> 00:04:06,890
So it just shows you here.

65
00:04:06,900 --> 00:04:13,890
Angelina Jolie is basically their own, similar to the original Angelina Jolie image, which is obvious.

66
00:04:14,460 --> 00:04:17,100
And then you can see which celebrity she's more similar to.

67
00:04:17,100 --> 00:04:18,540
Apparently, kids single.

68
00:04:18,930 --> 00:04:20,790
Let's take a look at the images here.

69
00:04:21,390 --> 00:04:26,790
So Angelina Jolie was more similar to Kate Siegel, and actually, they do look quite similar.

70
00:04:28,680 --> 00:04:36,630
So you can see Bradley Cooper was more similar to Paul Rudd and then shared with him a bit afterward.

71
00:04:37,290 --> 00:04:42,540
Kate Siegel is actually going to be more similar to Angelina Jolie and seems to get the same matching

72
00:04:42,540 --> 00:04:44,220
score above, which makes sense.

73
00:04:44,910 --> 00:04:47,480
And you can see how it works for all of them as well.

74
00:04:47,520 --> 00:04:48,480
So this is pretty cool.

75
00:04:48,480 --> 00:04:55,020
So if you have like a big family and you want to see who resembles who the most, you can run them through

76
00:04:55,020 --> 00:04:57,750
this code here and then get the similarity of scores.

77
00:04:58,290 --> 00:04:59,660
Probably a fun project to do.

78
00:04:59,670 --> 00:05:02,370
Or you get if you have a group of friends, you can do it as well.

79
00:05:02,940 --> 00:05:03,990
It would be pretty cool.

80
00:05:04,200 --> 00:05:06,120
So that's it for this lesson.

81
00:05:06,870 --> 00:05:12,060
So what we'll do next, we'll take a look at deep deepfakes, which allows us to do age, gender expression

82
00:05:12,390 --> 00:05:15,120
and facial recognition and a few other things as well.

83
00:05:15,450 --> 00:05:16,520
So stay tuned for that.

84
00:05:16,860 --> 00:05:18,090
It's going to be quite cool.

85
00:05:18,750 --> 00:05:19,110
Thank you.
