1
00:00:02,000 --> 00:00:04,000
Well here is that train.py script.

2
00:00:04,000 --> 00:00:08,000
That train.py script contains the convolutional neural network model.

3
00:00:08,000 --> 00:00:13,000
I trained the convolution neural model on the face images of men and women.

4
00:00:13,000 --> 00:00:16,000
So let me show you the dataset images as well.

5
00:00:16,000 --> 00:00:20,000
So in front of you you can see the men and women folder.

6
00:00:20,000 --> 00:00:27,000
So both these folders contain this folder, contain the men images, and in the woman images I have

7
00:00:27,000 --> 00:00:33,000
the women images face images of women and in the men folder I have the face images of men.

8
00:00:33,000 --> 00:00:39,000
So I train the convolution neural network model on the face images of men and women.

9
00:00:39,000 --> 00:00:44,000
So this is the architecture of the convolution neural network model, which you can see over here.

10
00:00:44,000 --> 00:00:51,000
The the convolution neural network consists of multiple layers of convolution 2D layers.

11
00:00:51,000 --> 00:00:56,000
You can see over here we have the batch normalization, we have the max pooling 2D layers, we have

12
00:00:56,000 --> 00:00:59,000
the flatten layer, we have the dense layer as well.

13
00:00:59,000 --> 00:01:05,000
And I trained this convolution neural network model on 100 epochs, which you can see over here.

14
00:01:05,000 --> 00:01:10,000
I will not go into the training as again, but after training the convolution neural network model,

15
00:01:10,000 --> 00:01:15,000
I saved the model into my text by the name gender detection dot model.

16
00:01:15,000 --> 00:01:22,000
So I will use this train gender detection model of in when after doing the face detection, I will use

17
00:01:22,000 --> 00:01:26,000
this gender detection model to classify whether it is a man or woman.

18
00:01:26,000 --> 00:01:33,000
So for face detection, I will use YOLO V8 and to classify whether it is a man and woman, I will use

19
00:01:33,000 --> 00:01:39,000
convolution this gender detection model which is trained on the images of men and women.

20
00:01:39,000 --> 00:01:44,000
Or okay, so here is the gender detection model.

21
00:01:44,000 --> 00:01:50,000
After saving and here I have the training loss, validation, loss, training, accuracy and validation

22
00:01:50,000 --> 00:01:50,000
accuracy.

23
00:01:50,000 --> 00:01:56,000
So you can see that the results are fine and we are getting a very fine results as well.

24
00:01:56,000 --> 00:02:00,000
And it's ready to do the gender classification as well.

25
00:02:00,000 --> 00:02:01,000
Okay.

26
00:02:01,000 --> 00:02:07,000
So you can do the training as well if you want, but I'm not doing the training again because it will

27
00:02:07,000 --> 00:02:08,000
the video will become very lengthy.

28
00:02:08,000 --> 00:02:15,000
So let's move towards the CoLab script in which we will first see how we can train the YOLO V8 model

29
00:02:15,000 --> 00:02:16,000
for the face detection.

30
00:02:16,000 --> 00:02:21,000
Then we will use this gender detection model after doing the face detection to classify whether it is

31
00:02:21,000 --> 00:02:23,000
a man or woman.

32
00:02:23,000 --> 00:02:29,000
And then we will further write the script for the crowd counting and see how we can generate an alert

33
00:02:29,000 --> 00:02:33,000
system when when there is an overcrowd like more than five people.

34
00:02:33,000 --> 00:02:37,000
But you can set it at like more more than 100 people appear in a frame.

35
00:02:37,000 --> 00:02:40,000
Then we can generate an alert that is overcrowded.

36
00:02:40,000 --> 00:02:47,000
Okay, so let's move towards the YOLO script and see how we can train the YOLO model on the face for

37
00:02:47,000 --> 00:02:48,000
the face detection.

38
00:02:51,000 --> 00:02:52,000
Well, not.

39
00:02:52,000 --> 00:02:56,000
We will see how we can fine tune your V8 model for face detection.

40
00:02:56,000 --> 00:03:04,000
So for face detection I will be using this face images dataset which is available publicly on roboflow.

41
00:03:04,000 --> 00:03:14,000
So here we have around 1369 images of faces and we have only one class over here which is of face.

42
00:03:14,000 --> 00:03:19,000
So we will use using this dataset to detect the faces in the video or in an image.

43
00:03:19,000 --> 00:03:25,000
So you can see that the dataset consists of only one class, which is face, and we have around 1369

44
00:03:25,000 --> 00:03:27,000
images in our dataset.

45
00:03:27,000 --> 00:03:33,000
But after doing the augmentation, the dataset images in the training set increased to 2900.

46
00:03:33,000 --> 00:03:41,000
And in the validation set we have the 267 images and in the train testing set we have around 145 images.

47
00:03:41,000 --> 00:03:45,000
So first of all, we will be using this dataset to detect the faces.

48
00:03:45,000 --> 00:03:49,000
So I will fine tune the YOLO V8 model using this dataset.

49
00:03:49,000 --> 00:03:56,000
And so after fine tuning the YOLO V8 model on this dataset, my model will be able to detect the faces.

50
00:03:56,000 --> 00:04:01,000
So let's first overview this complete process in the Google CoLab notebook.

51
00:04:01,000 --> 00:04:03,000
So here we have the Google CoLab notebook.

52
00:04:03,000 --> 00:04:08,000
So first of all, please make sure that you select the runtime as GPU.

53
00:04:08,000 --> 00:04:13,000
I've already run this script, so first of all, I will leave, disconnect and delete the runtime so

54
00:04:13,000 --> 00:04:15,000
all my previous files are lost now.

55
00:04:15,000 --> 00:04:20,000
So I will now start from the start and explain you the all the process one by one.

56
00:04:20,000 --> 00:04:23,000
And thus first I will select the runtime as GPU.

57
00:04:24,000 --> 00:04:25,000
Okay.

58
00:04:25,000 --> 00:04:29,000
Then i will import that from ipython dot display import image.

59
00:04:29,000 --> 00:04:34,000
Basically I'm using this library to import any or to import the image library.

60
00:04:34,000 --> 00:04:40,000
I'm basically use the image library when I want to display any input or output image into our Google

61
00:04:40,000 --> 00:04:41,000
CoLab notebook.

62
00:04:41,000 --> 00:04:47,000
So to display input or output image into the Google CoLab notebook, we use the image library.

63
00:04:48,000 --> 00:04:54,000
Okay, so in the next step I will download some required files of YOLO V8 from the Google Drive.

64
00:04:54,000 --> 00:05:00,000
So I have placed the files in the form of zip format into my Google Drive, so I'm just downloading

65
00:05:00,000 --> 00:05:01,000
the files from my drive.

66
00:05:02,000 --> 00:05:06,000
So these are the files necessary to run the YOLO script.

67
00:05:06,000 --> 00:05:12,000
So here we have the unzipped folder of all these files based detection, YOLO V8.

68
00:05:12,000 --> 00:05:18,000
So here I've just downloaded the required files from my Google Drive into the Google CoLab notebook.

69
00:05:18,000 --> 00:05:23,000
Then I want to set this downloaded folder as my current directory.

70
00:05:23,000 --> 00:05:28,000
So I'm just setting this folder into my as my current directory.

71
00:05:28,000 --> 00:05:32,000
Then we need to install all the required libraries necessary to run this project.

72
00:05:32,000 --> 00:05:35,000
So in this step I'll install all the dependencies.

73
00:05:35,000 --> 00:05:41,000
So it will install all the required libraries which you can see over here like matplotlib numpy torch

74
00:05:41,000 --> 00:05:43,000
or seaborne hydra.

75
00:05:43,000 --> 00:05:49,000
So it is necessary to run this cell because if you don't run this cell or skip this step, then you

76
00:05:49,000 --> 00:05:50,000
might face this error.

77
00:05:50,000 --> 00:05:53,000
Then the following libraries is not installed or some libraries not installed.

78
00:05:53,000 --> 00:06:00,000
So it's always necessary to run this cell so that all the required packages gets installed.

79
00:06:00,000 --> 00:06:06,000
Okay, so here we have the Jinja2 library and all the libraries, so it's necessary to install all the

80
00:06:06,000 --> 00:06:07,000
required libraries first.

81
00:06:08,000 --> 00:06:12,000
So as here we are just doing the detection, face detection.

82
00:06:12,000 --> 00:06:19,000
So we will go to ultralytics, YOLO V8 and go to the detect folder and set this folder as our current

83
00:06:19,000 --> 00:06:24,000
directory because here we have the prediction training validation.py file.

84
00:06:24,000 --> 00:06:30,000
So just go to here, click on copy path and set this folder as our current directory.

85
00:06:30,000 --> 00:06:31,000
Okay.

86
00:06:31,000 --> 00:06:38,000
So in the next step, what we need to do is we need to export this data set from Roboflow into our Google

87
00:06:38,000 --> 00:06:39,000
CoLab notebook.

88
00:06:39,000 --> 00:06:40,000
So just click on download.

89
00:06:40,000 --> 00:06:44,000
So here, just go to select the YOLO V5, PyTorch or YOLO V8 format.

90
00:06:44,000 --> 00:06:50,000
Basically Yolov5, PyTorch and YOLO V8 both were released from Roboflow so you can select any of the

91
00:06:50,000 --> 00:06:51,000
format.

92
00:06:51,000 --> 00:06:57,000
Then just click here and click on copy and just paste this over here.

93
00:06:57,000 --> 00:07:03,000
So in this way you can download the dataset from Roboflow into your Google CoLab notebook, but it's

94
00:07:03,000 --> 00:07:06,000
necessity that you make an account on Roboflow as well.

95
00:07:06,000 --> 00:07:12,000
Like you can see here, I have created an account on Roboflow by the name my name, so you can go to

96
00:07:12,000 --> 00:07:15,000
sign up and create your account on Roboflow as well.

97
00:07:15,000 --> 00:07:22,000
Then you can easily access this dataset and download this dataset from Roboflow into your Google CoLab

98
00:07:22,000 --> 00:07:23,000
notebook as well.

99
00:07:23,000 --> 00:07:27,000
So the dataset is being downloaded over here.

100
00:07:28,000 --> 00:07:30,000
So it might take a few seconds.

101
00:07:30,000 --> 00:07:30,000
Okay.

102
00:07:30,000 --> 00:07:33,000
So you can see that it's currently in the zip format.

103
00:07:34,000 --> 00:07:38,000
So after this, it will automatically unzip and we can see these files as well.

104
00:07:38,000 --> 00:07:39,000
Okay.

105
00:07:39,000 --> 00:07:43,000
So, okay, so it's 75%.

106
00:07:43,000 --> 00:07:44,000
It's 77%.

107
00:07:44,000 --> 00:07:46,000
It's 81.

108
00:07:46,000 --> 00:07:47,000
86%.

109
00:07:49,000 --> 00:07:53,000
There's 95% and okay, so it's 100% as well.

110
00:07:53,000 --> 00:07:55,000
So the data set is completely downloaded.

111
00:07:55,000 --> 00:07:59,000
And now here we can see the face detection dataset.

112
00:07:59,000 --> 00:08:06,000
Here we have the train test validation files, script file, validation folder, train test and validation

113
00:08:06,000 --> 00:08:09,000
folders, which contains the images and labels folder as well.

114
00:08:09,000 --> 00:08:13,000
Okay, so here we have the data dot HTML file which contains the number of classes.

115
00:08:13,000 --> 00:08:18,000
We have only one class, which is space, and here we have the path for the train test and validation

116
00:08:18,000 --> 00:08:19,000
folders.

117
00:08:19,000 --> 00:08:23,000
Okay, so now in the next step we need to train the custom model.

118
00:08:23,000 --> 00:08:26,000
I have already done the training so I will not train the model again.

119
00:08:26,000 --> 00:08:32,000
So you can see that I have trained the model for eight epochs, so I will not train the model again.

120
00:08:32,000 --> 00:08:34,000
So here we have the training results.

121
00:08:34,000 --> 00:08:42,000
So you can see that, uh, that we got the mean average precision with IOU 50 as 0.904 and the mean

122
00:08:42,000 --> 00:08:48,000
average precision with 5295 is 0.585.

123
00:08:48,000 --> 00:08:55,000
So we are getting fine results like the mean average precision with 50 is 90.4% and mean average precision

124
00:08:55,000 --> 00:08:59,000
with IOU, 50 to 95 is 58.5%.

125
00:08:59,000 --> 00:09:00,000
Okay.

126
00:09:00,000 --> 00:09:07,000
So after training, I have saved the weights of the best weights of my model on the Google Drive.

127
00:09:07,000 --> 00:09:11,000
So I will just download those weights from the Google Drive into the Google CoLab notebook.

128
00:09:11,000 --> 00:09:17,000
So you it is always better to save the weights because you can require those weights after this as well.

129
00:09:17,000 --> 00:09:23,000
So I always save the weights into my Google Drive so I can just directly download those weights from

130
00:09:23,000 --> 00:09:27,000
the Google drive into my Google CoLab notebook whenever it is required.

131
00:09:27,000 --> 00:09:31,000
So just now you can see the weights file over here as well.

132
00:09:32,000 --> 00:09:33,000
So I'll just refresh it.

133
00:09:33,000 --> 00:09:37,000
And here you can see the best the weight file as well.

134
00:09:37,000 --> 00:09:42,000
So now you can validate this custom model as well, or you can validate that train model as well.

135
00:09:42,000 --> 00:09:48,000
Like you can see here, I've passed the path of the best dot PDF file, so I'm just validating my model

136
00:09:48,000 --> 00:09:49,000
on the test images.

137
00:09:49,000 --> 00:09:54,000
I have not used the test data, set images for that training, so it's always better to have a look

138
00:09:54,000 --> 00:09:58,000
and see how what, how our model is performing on the test images.

139
00:09:58,000 --> 00:10:01,000
So these are the test images on which I'm talking about.

140
00:10:01,000 --> 00:10:04,000
So I'm just testing my model on these test images.

141
00:10:04,000 --> 00:10:05,000
Okay.

142
00:10:06,000 --> 00:10:07,000
So let's see.

143
00:10:07,000 --> 00:10:09,000
What results do we get over here?

144
00:10:09,000 --> 00:10:12,000
Okay, so what?

145
00:10:12,000 --> 00:10:14,000
See what mean average precision we get.

146
00:10:14,000 --> 00:10:20,000
So the mean average precision with 50 we get is 91.2% and mean average precision with 52.

147
00:10:20,000 --> 00:10:23,000
95 is 58.9%.

148
00:10:23,000 --> 00:10:23,000
Okay.

149
00:10:23,000 --> 00:10:27,000
So here we are also performing the object tracking using Deepsort.

150
00:10:27,000 --> 00:10:32,000
Like for each of the detected object, we will assign a unique ID to each of the detected object.

151
00:10:32,000 --> 00:10:39,000
Like Let me show you what I am talking about so you can have a more better understanding for it as well.

152
00:10:39,000 --> 00:10:42,000
So let me just share my screen and explain this.

153
00:10:42,000 --> 00:10:44,000
What basically I'm talking.

154
00:10:45,000 --> 00:10:49,000
So now you can see over here like you can see that.

155
00:10:49,000 --> 00:10:50,000
Let me just stop.

156
00:10:50,000 --> 00:10:55,000
So for each of the detected object, like you can see the man face, we have a unique ID 192 over here.

157
00:10:55,000 --> 00:10:56,000
Okay.

158
00:10:56,000 --> 00:10:59,000
Like for now, for here, man as well.

159
00:10:59,000 --> 00:11:01,000
We have a unique ID 193 over here.

160
00:11:01,000 --> 00:11:02,000
Now for here.

161
00:11:02,000 --> 00:11:05,000
WOMAN We have a unique ID of 94 over here.

162
00:11:05,000 --> 00:11:06,000
Now for here.

163
00:11:06,000 --> 00:11:09,000
MAN We have a unique ID of 195 as well.

164
00:11:09,000 --> 00:11:12,000
So you can see here we have a unique ID of 208.

165
00:11:12,000 --> 00:11:18,000
So using object tracking, we assign a unique ID to each of the detected object like or each of the

166
00:11:18,000 --> 00:11:20,000
detected face over here.

167
00:11:20,000 --> 00:11:28,000
So whether it is a man face or a woman face, we assign a unique ID like 205, 154 over here, 121 over

168
00:11:28,000 --> 00:11:28,000
here.

169
00:11:28,000 --> 00:11:33,000
So using object tracking, we assign a basically unique ID to each of the detected object so we can

170
00:11:33,000 --> 00:11:36,000
have save the record for that as well.

171
00:11:36,000 --> 00:11:37,000
Okay.

172
00:11:37,000 --> 00:11:42,000
So to do a object tracking here, we will be using deepsort for the object tracking.

173
00:11:42,000 --> 00:11:47,000
So first of all, we will download a deepsort file from the Google Drive and unzip those files.

174
00:11:49,000 --> 00:11:53,000
Okay, so I've downloaded the files or deepsort files from the Google Drive and unzip those files.

175
00:11:53,000 --> 00:11:56,000
So here we have the Deepsort PyTorch folder.

176
00:11:56,000 --> 00:11:59,000
So I will use deepsort for the object tracking.

177
00:11:59,000 --> 00:12:01,000
Okay, so now I'm in the next step.

178
00:12:01,000 --> 00:12:06,000
I showed you that I have saved the gender detection model, which I showed you over here.

179
00:12:06,000 --> 00:12:08,000
So let me just show it here.

180
00:12:08,000 --> 00:12:13,000
So I have saved this gender detection model on on basically, I have trained a convolution neural network

181
00:12:13,000 --> 00:12:17,000
model on the image dataset of men and woman faces.

182
00:12:17,000 --> 00:12:20,000
So after this, I saved this gender detection model.

183
00:12:20,000 --> 00:12:24,000
So I will just use this gender detection model, which you can see here.

184
00:12:25,000 --> 00:12:25,000
Okay?

185
00:12:25,000 --> 00:12:29,000
So I just save this as gender detection model over here.

186
00:12:29,000 --> 00:12:31,000
Like you can see gender detection model.

187
00:12:31,000 --> 00:12:37,000
The gender detection model is trained on the images of men and woman.

188
00:12:37,000 --> 00:12:41,000
So gender detection model is basically a convolution neural network model, which is trained on the

189
00:12:41,000 --> 00:12:43,000
images of men and women.

190
00:12:43,000 --> 00:12:43,000
Okay.

191
00:12:43,000 --> 00:12:44,000
So.

192
00:12:46,000 --> 00:12:49,000
I'm just downloading have the gender detection model on the drive.

193
00:12:49,000 --> 00:12:54,000
So I'm just downloading this model from the drive into the Google CoLab notebook over here.

194
00:12:55,000 --> 00:12:58,000
Okay, so this might take two seconds.

195
00:12:58,000 --> 00:13:00,000
Okay, so the model is downloaded.

196
00:13:00,000 --> 00:13:01,000
It's around one and a four MB.

197
00:13:01,000 --> 00:13:05,000
So let me now explain you the prediction dot pi script as well.

198
00:13:05,000 --> 00:13:12,000
So I'm just opening the prediction dot pi script over here and let me explain you the whole process

199
00:13:12,000 --> 00:13:12,000
flow.

200
00:13:12,000 --> 00:13:13,000
Okay.

201
00:13:13,000 --> 00:13:18,000
So basically let me download the updated prediction dot pi script so that, so here I will download

202
00:13:18,000 --> 00:13:27,000
some demo videos to test my fine tune V8 model and I'm just download the updated prediction dot pi script

203
00:13:27,000 --> 00:13:31,000
and I will explain you the complete script file as well.

204
00:13:31,000 --> 00:13:31,000
Okay.

205
00:13:33,000 --> 00:13:35,000
So this might take a few seconds.

206
00:13:35,000 --> 00:13:36,000
So let's wait.

207
00:13:36,000 --> 00:13:39,000
And as it gets downloaded, I will explain you the complete process.

208
00:13:39,000 --> 00:13:43,000
So here we have the updated prediction dot pie script.

209
00:13:43,000 --> 00:13:47,000
I have updated this prediction dot pie script as per this project.

210
00:13:47,000 --> 00:13:50,000
So here you can see the prediction dot pie script.

211
00:13:50,000 --> 00:13:53,000
So let me explain you this complete code here as well.

212
00:13:59,000 --> 00:14:00,000
Well, here we have the code.

213
00:14:01,000 --> 00:14:07,000
I will only explain the code that is not a part of the official repository and that which I have added

214
00:14:07,000 --> 00:14:08,000
in the script.

215
00:14:09,000 --> 00:14:11,000
So if we go beyond down over here.

216
00:14:12,000 --> 00:14:18,000
We can see that I have created a dictionary by the name founded dash classes to store the information

217
00:14:18,000 --> 00:14:19,000
about the detected items.

218
00:14:19,000 --> 00:14:22,000
So to store the information about the detected items.

219
00:14:22,000 --> 00:14:26,000
I have created a dictionary by the name founded dash classes.

220
00:14:26,000 --> 00:14:32,000
Then we have a variable and over here the variable n basically contain the total count of data for the

221
00:14:32,000 --> 00:14:34,000
detections per class.

222
00:14:34,000 --> 00:14:37,000
Like here we have only one class which is face like.

223
00:14:37,000 --> 00:14:39,000
I'm only detecting the face.

224
00:14:39,000 --> 00:14:43,000
So in a frame, for example, I have detected five faces.

225
00:14:43,000 --> 00:14:48,000
Okay, so the variable n will contain the total count for the face detected.

226
00:14:48,000 --> 00:14:53,000
So if in a frame five faces are detected, the variable n value will be five.

227
00:14:54,000 --> 00:15:01,000
And here we have the now we have the class index variable, which is equal to an integer C.

228
00:15:01,000 --> 00:15:06,000
So the class basically this C represents the class ID, okay?

229
00:15:06,000 --> 00:15:12,000
In this C variable, we have the class ID, So in this case we have only one class as we are detecting

230
00:15:12,000 --> 00:15:13,000
only face.

231
00:15:13,000 --> 00:15:16,000
So face is the only class and its class ID will be zero.

232
00:15:16,000 --> 00:15:17,000
Okay.

233
00:15:17,000 --> 00:15:22,000
So the class index contain the class ID of the detected object.

234
00:15:22,000 --> 00:15:24,000
Or you can say the the class ID of the detected object.

235
00:15:24,000 --> 00:15:27,000
So here we have only one class which is face.

236
00:15:27,000 --> 00:15:33,000
So the class ID will be zero and the class ID is saved in the variable class index.

237
00:15:34,000 --> 00:15:40,000
Then we have the variable name count of object object, count of object in is equal to integer.

238
00:15:40,000 --> 00:15:45,000
And so the total count is saved as an integer called count of object.

239
00:15:45,000 --> 00:15:49,000
So the variable n contain the total count of the detected object.

240
00:15:49,000 --> 00:15:54,000
So here we have only one object object which we are detecting, which is face.

241
00:15:54,000 --> 00:16:00,000
So the if we have detected five faces in a frame, then the count of object will be five.

242
00:16:00,000 --> 00:16:05,000
If we have detected ten faces in a frame, then the count of object will be is equal to five.

243
00:16:05,000 --> 00:16:08,000
Okay, So we have already explained this to you over here.

244
00:16:08,000 --> 00:16:13,000
And so we have the total count is saved in an integer called count of object.

245
00:16:13,000 --> 00:16:18,000
So in this variable count of object, we are saving the total count of the detected object in a frame.

246
00:16:18,000 --> 00:16:18,000
Okay.

247
00:16:19,000 --> 00:16:21,000
So then we have the founded class.

248
00:16:21,000 --> 00:16:24,000
We are just calling the founded class dictionary over here.

249
00:16:24,000 --> 00:16:29,000
So in the founded class dictionary I am just saving in the so dictionary contains a key variable and

250
00:16:29,000 --> 00:16:30,000
a value.

251
00:16:30,000 --> 00:16:30,000
Okay.

252
00:16:30,000 --> 00:16:35,000
So in the key variable we have the object name detected object name.

253
00:16:35,000 --> 00:16:37,000
So here we are only detecting the face.

254
00:16:37,000 --> 00:16:43,000
So the key variable will contain the face and in the integer n is basically a total count.

255
00:16:43,000 --> 00:16:44,000
So in the value.

256
00:16:44,000 --> 00:16:49,000
So as the dictionary contains two values, one is the key and other is the value variable.

257
00:16:49,000 --> 00:16:53,000
So in dictionary we have two variables or you can say two things like one is the key and other is the

258
00:16:53,000 --> 00:16:54,000
value.

259
00:16:54,000 --> 00:16:58,000
So key is basically the object name and the value is the total count of the object.

260
00:16:58,000 --> 00:17:05,000
So in the key variable we have the face and in a frame is the face is detected five times, so the value

261
00:17:05,000 --> 00:17:06,000
variable will be five.

262
00:17:06,000 --> 00:17:07,000
Okay.

263
00:17:07,000 --> 00:17:11,000
So then we are using a calling a function by the name count.

264
00:17:11,000 --> 00:17:14,000
So I have created this function over here.

265
00:17:14,000 --> 00:17:20,000
So in the count function I am just setting the like where should be the total count should appear.

266
00:17:20,000 --> 00:17:20,000
Let me show you.

267
00:17:21,000 --> 00:17:27,000
So if we go to this video over here so you can see that here we can see face is equal to 26.

268
00:17:28,000 --> 00:17:34,000
So in in this basically in this count function we are setting the that.

269
00:17:35,000 --> 00:17:36,000
In the top right corner.

270
00:17:37,000 --> 00:17:41,000
And in the top right corner, we will have this a rounded rectangle like this.

271
00:17:41,000 --> 00:17:49,000
And the first item in the rounded rectangle is place then is equal to the number of detected faces in

272
00:17:49,000 --> 00:17:49,000
the frame.

273
00:17:49,000 --> 00:17:55,000
Okay, so we are just setting the in the count variable like where where the total count of faces should

274
00:17:55,000 --> 00:17:57,000
appear in the output video.

275
00:17:57,000 --> 00:17:57,000
Okay.

276
00:17:57,000 --> 00:18:02,000
So in the count function we are just setting the UI.

277
00:18:02,000 --> 00:18:07,000
So in this count function we are just setting the UI like the where in the output video, the total

278
00:18:07,000 --> 00:18:09,000
count will appear.

279
00:18:09,000 --> 00:18:09,000
Okay.

280
00:18:09,000 --> 00:18:10,000
So.

281
00:18:11,000 --> 00:18:15,000
So I'm just using the count function to set that like in the.

282
00:18:17,000 --> 00:18:22,000
Output video where showed the total count of like face and this total count will appear.

283
00:18:22,000 --> 00:18:24,000
So let me go back to the script as well.

284
00:18:24,000 --> 00:18:26,000
So here you can see the count function.

285
00:18:26,000 --> 00:18:28,000
And in this count function, we are just.

286
00:18:29,000 --> 00:18:33,000
Setting the UI like the total count of the detected object.

287
00:18:33,000 --> 00:18:35,000
Where should it appear on the output video?

288
00:18:35,000 --> 00:18:40,000
Okay, so here I've just created a class by the name gender classifier.

289
00:18:40,000 --> 00:18:46,000
Okay, so here I'm just pre-processing the image because we are reading the video frame by frame.

290
00:18:46,000 --> 00:18:51,000
So here I'm just processing the first frame and then I'm just loading the weights of the model, like

291
00:18:51,000 --> 00:18:52,000
gender classification dot model.

292
00:18:52,000 --> 00:18:57,000
So I'm just loading this model with gender detection dot model over here.

293
00:18:57,000 --> 00:19:01,000
And then I'm doing the prediction over here where there is a man or woman face.

294
00:19:01,000 --> 00:19:01,000
Okay.

295
00:19:03,000 --> 00:19:09,000
The other thing which have done over here is if the count of the object like if the like here we have

296
00:19:09,000 --> 00:19:12,000
the total count of the object in each of the frames.

297
00:19:12,000 --> 00:19:17,000
So if in a frame more than five phases are detected, then the text will appear as overcrowded.

298
00:19:17,000 --> 00:19:21,000
And here I'm just setting the UI like where the overcrowded will appear.

299
00:19:21,000 --> 00:19:22,000
Let me show you.

300
00:19:22,000 --> 00:19:26,000
So if I go to the video again so you can see here.

301
00:19:28,000 --> 00:19:32,000
So here I'm just setting the, like, overcrowded, appearing over here.

302
00:19:32,000 --> 00:19:35,000
And if you can see that currently we have 26 spaces.

303
00:19:35,000 --> 00:19:38,000
So it's, uh, so here it is appearing that it's overcrowded, so.

304
00:19:38,000 --> 00:19:41,000
Okay, so you can set it as per your requirement.

305
00:19:41,000 --> 00:19:44,000
Like if they are more than 100 faces, then you can set that it is overcrowded.

306
00:19:44,000 --> 00:19:45,000
Okay.

307
00:19:45,000 --> 00:19:51,000
But I'm saying that if they are more than five detected faces in a class in a frame, sorry if more

308
00:19:51,000 --> 00:19:56,000
than five faces are detected in a single frame, then the text like overcrowded should appear and it

309
00:19:56,000 --> 00:19:58,000
should appear in the center like I'm showing over here.

310
00:19:58,000 --> 00:19:59,000
Okay.

311
00:19:59,000 --> 00:20:04,000
So you can set it like 111 50 faces appear in a frame in a single frame.

312
00:20:04,000 --> 00:20:06,000
Then you can set the text as overcrowded.

313
00:20:06,000 --> 00:20:11,000
And here I'm just setting the UI like where should the text will be appear in the output video.

314
00:20:12,000 --> 00:20:14,000
Okay, so here we have the output video.

315
00:20:15,000 --> 00:20:18,000
So basically, let me run this script now.

316
00:20:18,000 --> 00:20:19,000
Okay.

317
00:20:19,000 --> 00:20:22,000
So if you can run this script on any demo video as well.

318
00:20:22,000 --> 00:20:25,000
So let me run this script on some demo video.

319
00:20:25,000 --> 00:20:30,000
So let me run the script on this sample one demo video and show you the results.

320
00:20:30,000 --> 00:20:31,000
What results do we get?

321
00:20:32,000 --> 00:20:33,000
Okay, so.

322
00:20:34,000 --> 00:20:37,000
This might take some time for the script to execute over here.

323
00:20:37,000 --> 00:20:44,000
So as it starts, I will just pause the video and when this processing completes, I will then just

324
00:20:44,000 --> 00:20:44,000
be back.

325
00:20:44,000 --> 00:20:50,000
Okay, so now you can see that we are detecting three, two, three, two face.

326
00:20:50,000 --> 00:20:52,000
So it might take some time.

327
00:20:52,000 --> 00:20:59,000
So let me just run this script and complete the processing of this on this video and just get back when

328
00:20:59,000 --> 00:21:00,000
this is done.

329
00:21:00,000 --> 00:21:01,000
Okay?

330
00:21:03,000 --> 00:21:05,000
The processing on the video is done.

331
00:21:05,000 --> 00:21:07,000
And here is our output demo video.

332
00:21:07,000 --> 00:21:11,000
Let me download this video and see what results do we get.

333
00:21:11,000 --> 00:21:17,000
So I'm just downloading this video and then will like me get my screen to watch this video and show

334
00:21:17,000 --> 00:21:18,000
you what results we are getting.

335
00:21:18,000 --> 00:21:19,000
Okay.

336
00:21:19,000 --> 00:21:25,000
So just to navigate, let me navigate my screen towards this video which I have opened over here.

337
00:21:25,000 --> 00:21:26,000
Just give me a minute.

338
00:21:27,000 --> 00:21:28,000
Just a minute, please.

339
00:21:29,000 --> 00:21:29,000
Okay.

340
00:21:29,000 --> 00:21:33,000
So just navigating my screen to watch this video at.

341
00:21:33,000 --> 00:21:34,000
So here is the output video.

342
00:21:34,000 --> 00:21:36,000
You can see you on your screen.

343
00:21:36,000 --> 00:21:41,000
Let me play it so you can see that the face count is less around 5 to 3.

344
00:21:41,000 --> 00:21:46,000
So as it goes to five, we will see that our coded.

345
00:21:46,000 --> 00:21:48,000
So you can see over here.

346
00:21:48,000 --> 00:21:49,000
So let me show you as well.

347
00:21:49,000 --> 00:21:55,000
Again, you can see that as it reaches five, we have this.

348
00:21:57,000 --> 00:21:57,000
Okay.

349
00:21:57,000 --> 00:22:00,000
So you can see that as the face count increases five.

350
00:22:00,000 --> 00:22:03,000
So we have the signal or the arm as overcrowded.

351
00:22:03,000 --> 00:22:04,000
Okay.

352
00:22:04,000 --> 00:22:07,000
So you can see the signal as the face count increases.

353
00:22:07,000 --> 00:22:08,000
Why?

354
00:22:08,000 --> 00:22:11,000
We have the signal as the overcrowded over here, you can see.

355
00:22:12,000 --> 00:22:12,000
Okay.

356
00:22:12,000 --> 00:22:13,000
So.

357
00:22:14,000 --> 00:22:15,000
This is all.

358
00:22:15,000 --> 00:22:17,000
So let's test on some other demo video as well.

359
00:22:18,000 --> 00:22:24,000
Let me just go back and okay, so I'm done doing processing on other the demo video as well.

360
00:22:25,000 --> 00:22:30,000
Demo Video three So as it completed, I will share my screen and see what results do we get.

361
00:22:30,000 --> 00:22:37,000
Okay, so it's currently 198 out of 355 so it might take a few seconds more.

362
00:22:37,000 --> 00:22:39,000
So let me get back as it is complete.

363
00:22:41,000 --> 00:22:44,000
Bioprocessing on the demo video three is also done.

364
00:22:44,000 --> 00:22:49,000
Let me just download this video and show you what results do we get over here.

365
00:22:49,000 --> 00:22:51,000
So here we have the output video.

366
00:22:51,000 --> 00:22:56,000
Let me just download it and show you what results we are actually getting.

367
00:22:56,000 --> 00:22:57,000
So the video is downloaded.

368
00:22:57,000 --> 00:23:04,000
Let me just navigate my screen towards this output video and show you so you can see that this is our

369
00:23:04,000 --> 00:23:05,000
output video.

370
00:23:05,000 --> 00:23:11,000
You can see that as the count increases, the quantity increases to five from five.

371
00:23:11,000 --> 00:23:13,000
So we can see the signal as overcrowded.

372
00:23:13,000 --> 00:23:17,000
But if they are less than five, so we don't have the alert of overcrowded.

373
00:23:17,000 --> 00:23:24,000
But as the phase count increases from five, we have the signal as overcrowded, which you can see over

374
00:23:24,000 --> 00:23:24,000
here.

375
00:23:24,000 --> 00:23:27,000
So this is all from this video tutorial.

376
00:23:27,000 --> 00:23:29,000
I hope you have learned a lot from this video tutorial.

377
00:23:29,000 --> 00:23:31,000
See you all in the next video tutorial.

378
00:23:31,000 --> 00:23:32,000
Till then, bye bye.

