1
00:00:02,800 --> 00:00:10,930
In this video tutorial, we will look at how we can fine tune the YOLO model on a custom dataset for

2
00:00:10,930 --> 00:00:13,510
personal protective equipment detection.

3
00:00:14,420 --> 00:00:19,370
We will be using the Personal Protective Equipment data set available on Roboflow.

4
00:00:19,850 --> 00:00:26,150
We will we will download the Personal Protective Equipment data set from Roboflow into this Google Colab

5
00:00:26,150 --> 00:00:26,810
notebook.

6
00:00:26,810 --> 00:00:32,330
And then we will fine tune the YOLO v9 model on this Personal Protective Equipment data set.

7
00:00:32,720 --> 00:00:39,170
As now you can see the demo of our output videos, which we have got after doing Personal Protective

8
00:00:39,170 --> 00:00:40,100
equipment detection.

9
00:00:40,100 --> 00:00:45,590
On these videos, we will also see how we can do personal protective equipment detection on images and

10
00:00:45,590 --> 00:00:46,850
on videos.

11
00:00:48,020 --> 00:00:55,070
I have already prepared a complete notebook for this tutorial, and we will be using YOLO v9 Extended

12
00:00:55,070 --> 00:00:56,660
model in this tutorial.

13
00:00:57,260 --> 00:00:58,790
So let's get started.

14
00:00:58,790 --> 00:01:02,120
So now here you can see the complete notebook over here.

15
00:01:02,120 --> 00:01:07,580
So I have written all the code and all the added all the required explanation as well.

16
00:01:07,580 --> 00:01:13,640
And this will provide you a step by step guide how you can fine tune the YOLO v9 model on any custom

17
00:01:13,640 --> 00:01:14,120
data set.

18
00:01:14,120 --> 00:01:20,330
But in this tutorial we will be fine tuning the V9 model on Personal Protective Equipment data set,

19
00:01:20,330 --> 00:01:22,010
which is available on Roboflow.

20
00:01:22,040 --> 00:01:27,110
You can get that, uh, you can get the data from any other sources as well, but I will be using the

21
00:01:27,110 --> 00:01:28,520
personal protective data.

22
00:01:30,140 --> 00:01:32,630
Roboflow and I will show you the dataset as well.

23
00:01:32,630 --> 00:01:36,110
So, uh, the dataset consists of seven different classes.

24
00:01:36,110 --> 00:01:38,690
As we go on we will discuss that as well.

25
00:01:38,690 --> 00:01:40,220
So let's get started with it.

26
00:01:43,120 --> 00:01:47,620
But before you run the script, please make sure that we have selected a runtime asset for GPU.

27
00:01:47,650 --> 00:01:50,920
Google Colab offers free GPU and we can use this as well.

28
00:01:51,070 --> 00:01:53,650
So here you can see we have the yolo v9 GitHub repo.

29
00:01:53,650 --> 00:01:55,750
And over here you just the first step.

30
00:01:55,750 --> 00:01:57,400
You need to clone this GitHub repo.

31
00:01:57,400 --> 00:01:59,410
So you can just copy the link from here.

32
00:01:59,830 --> 00:02:00,220
Okay.

33
00:02:00,220 --> 00:02:04,150
And you can simply add this link over here.

34
00:02:06,080 --> 00:02:07,850
After editing this link, you will.

35
00:02:07,850 --> 00:02:11,960
We will clone this GitHub repo or in this Google Colab notebook over here.

36
00:02:12,230 --> 00:02:12,860
So now.

37
00:02:13,640 --> 00:02:14,690
You can see here.

38
00:02:14,690 --> 00:02:20,090
If I just refresh this now, you can see the, uh, this completed GitHub repo, which we have cloned,

39
00:02:20,090 --> 00:02:22,730
and we have all the required files over here as well.

40
00:02:22,730 --> 00:02:29,300
So now I will just start this, uh, yellow benign folder as my current directory.

41
00:02:29,300 --> 00:02:33,830
So to set any folder as your current directory you will write CD.

42
00:02:33,920 --> 00:02:39,710
And now if I just run this cell this yellow benign folder is being set as my current directory.

43
00:02:40,130 --> 00:02:45,170
So if you want to do object detection on images or video, or if you want to point to the yellow benign

44
00:02:45,170 --> 00:02:49,760
model or any custom data set, we need to first, uh, install all the required packages.

45
00:02:49,760 --> 00:02:54,680
So over here, if you just open the requirements dot txt file, you will find all the packages that

46
00:02:54,680 --> 00:02:58,670
are required to train detection or run the validation script.

47
00:02:58,670 --> 00:03:01,760
So you can install these packages one by one.

48
00:03:01,760 --> 00:03:08,060
Or if you just write pip install minus r requirements dot txt, it will install all the packages that

49
00:03:08,060 --> 00:03:08,990
are mentioned.

50
00:03:08,990 --> 00:03:11,210
This requirements dot txt file.

51
00:03:11,510 --> 00:03:16,280
So now I will just run this and it will install all the packages that are mentioned in the requirements

52
00:03:16,280 --> 00:03:17,510
dot txt file.

53
00:03:17,510 --> 00:03:21,350
So this will take two seconds before all the packages get stored.

54
00:03:22,800 --> 00:03:27,360
So it takes around 1 to 2 minutes for all these packages to get installed.

55
00:03:27,360 --> 00:03:31,470
And it also depends on the, uh, speed of your internet as well.

56
00:03:32,250 --> 00:03:36,360
So now you can see over here I think two more packages are left.

57
00:03:36,360 --> 00:03:40,290
And, uh, they will take a few more seconds to go.

58
00:03:44,160 --> 00:03:44,790
Okay.

59
00:03:45,030 --> 00:03:47,490
So you can see this is in progress currently.

60
00:03:48,200 --> 00:03:51,110
So let's wait for a few seconds for it to get complete.

61
00:03:57,270 --> 00:03:57,690
Okay.

62
00:03:57,690 --> 00:04:02,250
So like you can see that these are the size of different packages.

63
00:04:05,910 --> 00:04:11,790
So after we install all the required packages, then I will download a model weights from the yolo v9

64
00:04:11,790 --> 00:04:15,210
GitHub repo into this Google Colab notebook.

65
00:04:15,210 --> 00:04:19,050
So if you just show you the yolo v9 GitHub repo over here.

66
00:04:21,220 --> 00:04:24,730
Okay, so if you just, uh, go to releases from here.

67
00:04:25,120 --> 00:04:27,730
Here you will find the Yolov5 model.

68
00:04:27,730 --> 00:04:31,570
So Golovnin comes with, uh, four different, uh, models.

69
00:04:31,570 --> 00:04:36,760
Yolo v9, small, yolo v9 medium, YOLO v9 compact, and YOLO v9 extended.

70
00:04:36,760 --> 00:04:42,340
What are currently the weights of YOLO v9 Compact and Extended are currently available, so if you want

71
00:04:42,340 --> 00:04:46,750
to download this model to your Google Colab notebook, you can simply copy link address from here.

72
00:04:46,750 --> 00:04:52,960
And if you just see over here, uh, we currently we only have available a YOLO v9 model weights for

73
00:04:52,960 --> 00:04:56,800
Compact and extended model or the other model weights are not available.

74
00:04:56,800 --> 00:04:57,700
So.

75
00:04:58,440 --> 00:05:02,340
I will just add this link over here, which I have copied and.

76
00:05:03,560 --> 00:05:09,950
Before we go ahead with this, uh, we will set, uh, this, uh, yolo v nine folder as our current

77
00:05:09,950 --> 00:05:10,370
directory.

78
00:05:10,370 --> 00:05:17,000
We have all those already set this, but we will, uh, save this, uh, directory name into our variable,

79
00:05:17,000 --> 00:05:17,750
which is home.

80
00:05:18,410 --> 00:05:18,770
Okay.

81
00:05:18,770 --> 00:05:19,460
So.

82
00:05:21,560 --> 00:05:23,360
So now inside this we will create.

83
00:05:23,480 --> 00:05:27,440
So using mkdir we will create a new directory by.

84
00:05:27,440 --> 00:05:29,750
The name bears inside this line.

85
00:05:30,140 --> 00:05:34,340
So inside this yolo v nine folder we will create another directory by.

86
00:05:34,340 --> 00:05:35,060
The name bears.

87
00:05:35,060 --> 00:05:38,150
Inside this weights are folder or directory.

88
00:05:38,150 --> 00:05:43,190
We will save our uh YOLO nine compact and extracted model weights.

89
00:05:43,190 --> 00:05:45,740
We will not be using the compact model weight.

90
00:05:45,740 --> 00:05:49,250
We will only fine tune the YOLO nine extended model.

91
00:05:51,020 --> 00:05:52,910
So now if I just run this cell.

92
00:05:52,910 --> 00:05:57,470
So over here you will see we have created a weird spreadsheets.

93
00:05:57,470 --> 00:05:58,310
It's empty.

94
00:05:58,460 --> 00:06:04,520
So now we will, uh, download the YOLO v nine compact and YOLO in an extended model weights into this

95
00:06:05,030 --> 00:06:05,720
directory.

96
00:06:06,870 --> 00:06:08,850
If I just run this cell over here.

97
00:06:10,590 --> 00:06:16,800
So now if you can see over here I have downloaded the Yolo B9 Compact and Extended model weights you

98
00:06:16,800 --> 00:06:18,240
can find over here.

99
00:06:20,510 --> 00:06:28,130
Or you can simply see what different folders you have or what different files you have inside this weights

100
00:06:28,130 --> 00:06:28,730
folder.

101
00:06:28,730 --> 00:06:33,770
So we have Gallery nine which is Gallery nine compact model and YOLO v nine extended model.

102
00:06:33,770 --> 00:06:36,560
I already told you YOLO v nine comes with four different models.

103
00:06:36,560 --> 00:06:40,490
Gallery nine small Gallery nine medium Gallery nine compact and extended.

104
00:06:40,490 --> 00:06:44,900
But currently the weights for Gallery nine Compact and extended model are available.

105
00:06:44,900 --> 00:06:46,370
So we are just using that.

106
00:06:46,730 --> 00:06:50,900
So now I will download the data set from Roboflow into the Google Colab notebook.

107
00:06:50,900 --> 00:06:55,490
As I already told you that we will fine tuning the YOLO benign model on Personal Protective equipment

108
00:06:55,490 --> 00:06:56,150
data set.

109
00:06:56,600 --> 00:07:03,050
So if I just open this, uh, let me just open the data set over here and show you how our dataset looks

110
00:07:03,050 --> 00:07:03,410
like.

111
00:07:07,650 --> 00:07:10,410
And the dataset is available on roboflow.

112
00:07:10,410 --> 00:07:16,710
And you can see that I have written this own dataset, and the dataset consists of 311 training images,

113
00:07:16,710 --> 00:07:22,350
652 images are for the validation and 327 images are for the test set.

114
00:07:22,350 --> 00:07:27,840
So we are taking 70% of our data for the training purpose, 20% of the data for the validation purpose,

115
00:07:27,840 --> 00:07:30,510
and 10% of the data for the testing purpose.

116
00:07:30,510 --> 00:07:38,160
And here my dataset consist of seven different classes which include dust masks, gloves, protective

117
00:07:38,160 --> 00:07:42,270
boots, protective helmet, i-we're, safety vest, and shields.

118
00:07:42,270 --> 00:07:46,980
So these are, uh, these are the seven different classes which we have in our dataset.

119
00:07:46,980 --> 00:07:53,160
And over here, if I just open this data set, you can see over here, uh, these are the protective

120
00:07:53,160 --> 00:07:53,610
ports.

121
00:07:53,610 --> 00:07:54,870
This is the safety vest.

122
00:07:54,870 --> 00:07:56,880
These are the, uh, safety vest.

123
00:07:56,880 --> 00:07:58,380
This is the protective helmet.

124
00:07:58,680 --> 00:07:59,130
Okay.

125
00:07:59,130 --> 00:07:59,850
So.

126
00:08:01,940 --> 00:08:04,280
And if I just see the health check over here.

127
00:08:04,610 --> 00:08:11,120
So in the health check, we can find that, uh, uh, if our data is completely balanced or not.

128
00:08:11,120 --> 00:08:17,780
So we can see that, uh, out of seven or the classes are balanced while three classes are not balanced.

129
00:08:17,780 --> 00:08:19,580
So you can see over here.

130
00:08:20,120 --> 00:08:23,450
So this is how a data set looks like.

131
00:08:23,840 --> 00:08:24,110
Okay.

132
00:08:29,740 --> 00:08:36,130
So now you can see a no augmentations were applied in our data set because we usually apply a, uh,

133
00:08:36,130 --> 00:08:39,850
augmentation at that time when we don't have enough images in our training data.

134
00:08:39,850 --> 00:08:43,450
So to increase the size of our training data, we usually apply augmentation.

135
00:08:43,450 --> 00:08:48,460
But in that in this case, we have already a 2311 images in our training data.

136
00:08:48,460 --> 00:08:50,860
So we don't need to apply augmentation.

137
00:08:51,250 --> 00:08:56,740
So now I will just download this data set so you can simply, uh, create an account on Roboflow.

138
00:08:56,740 --> 00:09:01,330
So if you just try it over here I already have an account on Roboflow.

139
00:09:01,330 --> 00:09:08,200
So but you can simply, uh, sign in with Google or if you already have an account, or you can enter

140
00:09:08,200 --> 00:09:08,980
the credentials.

141
00:09:08,980 --> 00:09:10,630
So now you can see I've just logged in.

142
00:09:10,630 --> 00:09:13,840
It's very simple to create an account on Roboflow, you can simply create.

143
00:09:13,840 --> 00:09:18,010
And if you want to download this data set you can simply select the format.

144
00:09:18,010 --> 00:09:21,760
I will select YOLO v9 format and click on show Download code.

145
00:09:21,760 --> 00:09:26,950
And if you are using uh, Jupyter Notebook or Google Colab notebook, then you will simply copy this

146
00:09:26,950 --> 00:09:28,030
code from here.

147
00:09:28,240 --> 00:09:33,160
Uh, but if you are using Visual Studio or PyCharm ID, then you will just copy this code and paste

148
00:09:33,160 --> 00:09:33,910
in the terminal.

149
00:09:33,910 --> 00:09:38,110
It will download the data set from Roboflow into your IDE.

150
00:09:39,380 --> 00:09:41,630
So I will simply copy this code from here.

151
00:09:41,630 --> 00:09:44,480
And I will just add this code over here.

152
00:09:44,480 --> 00:09:51,320
And uh, so now it will download a data set from Roboflow into this Google Colab notebook.

153
00:09:54,130 --> 00:09:58,840
So this might take a few more seconds before we are able to download the data set.

154
00:09:59,230 --> 00:10:05,470
Okay, so now you can see that warning the following packages were previously imported in the runtime.

155
00:10:05,470 --> 00:10:12,100
You must restart the runtime in order to use newly installed versions, so I will just wait for the

156
00:10:12,100 --> 00:10:13,720
data set to download complete.

157
00:10:13,720 --> 00:10:15,670
Then I will just restart.

158
00:10:15,670 --> 00:10:18,100
Okay, so now you can see the tick mark over here.

159
00:10:18,100 --> 00:10:19,750
It means the data set is downloaded.

160
00:10:19,750 --> 00:10:24,640
So I will just restart the session so the package installation can be completely done.

161
00:10:28,050 --> 00:10:33,510
So now if I just restart a session, then I just need to select uh, this V9 folder as my current directory

162
00:10:33,510 --> 00:10:33,990
again.

163
00:10:34,500 --> 00:10:35,040
Okay.

164
00:10:35,640 --> 00:10:38,250
So now you can see over here.

165
00:10:38,280 --> 00:10:41,160
So now if now we need to train our custom model.

166
00:10:41,160 --> 00:10:44,610
So if I just open the YOLO like GitHub repo over here.

167
00:10:45,510 --> 00:10:49,200
So you will find all the steps for the training are written over here.

168
00:10:49,200 --> 00:10:51,540
So you just see over here.

169
00:10:52,290 --> 00:10:58,560
So now you can see that if you want to train a a, so if you want to train your over nine models you

170
00:10:58,560 --> 00:11:00,810
will run that train, dash your.py step.

171
00:11:00,810 --> 00:11:05,070
And if you want to train a grand model you can run the train.py script.

172
00:11:05,070 --> 00:11:08,760
But here I am going to train the yolo v9 extended model.

173
00:11:08,760 --> 00:11:12,210
So I will just run the python train that.py script.

174
00:11:12,210 --> 00:11:17,970
So you can simply copy this line of code from here, and you can just add this line of code over here

175
00:11:17,970 --> 00:11:19,020
and over here.

176
00:11:19,020 --> 00:11:20,010
I have made few changes.

177
00:11:20,010 --> 00:11:26,610
I have just uh, left made the batch size as eight and I am just train using uh GPUs website that device

178
00:11:26,610 --> 00:11:27,090
zero.

179
00:11:27,300 --> 00:11:30,600
The image size is being set to 640, which is by default.

180
00:11:30,600 --> 00:11:36,270
And I you know that in the start I have downloaded the weights from the GitHub repo into this Google

181
00:11:36,270 --> 00:11:37,440
Colab notebook.

182
00:11:37,440 --> 00:11:38,010
So.

183
00:11:39,200 --> 00:11:42,590
Over here in the weights folder you will find the weights over here.

184
00:11:42,590 --> 00:11:45,440
So I will run YOLO Renai EPD.

185
00:11:45,770 --> 00:11:47,960
So yolo B9 extended model weights.

186
00:11:47,960 --> 00:11:54,410
And I have just uh, my fine tuned model weights will be saved in the folder Yolo v9.

187
00:11:55,640 --> 00:11:56,210
Fine tuning.

188
00:11:56,210 --> 00:12:00,830
So by this by this name of folder will be created inside this folder directory.

189
00:12:00,830 --> 00:12:05,000
And inside this our fine tuned model weights will be saved as well.

190
00:12:05,450 --> 00:12:09,800
So and plus I am fine tuning the YOLO v9 model on for 30 epochs.

191
00:12:09,800 --> 00:12:15,800
You can fine tune the model for 80 or 100 epochs, which is well suited, but in this tutorial I am

192
00:12:15,800 --> 00:12:20,600
just fine tuning the YOLO v9 model for 30 bucks and it gives me good results as well.

193
00:12:21,890 --> 00:12:27,170
Thus here I will just in the data path, I will just pass the name of data dot yml file.

194
00:12:27,170 --> 00:12:30,500
So if you just see this, the this is the data set which I have downloaded.

195
00:12:30,500 --> 00:12:32,870
And here we have the data dot yml file.

196
00:12:32,870 --> 00:12:38,510
So you can see that we have seven different classes in our data set we have which include dust mask

197
00:12:38,510 --> 00:12:43,970
IVR glove, protective boots, protective helmets, safety vest and shield.

198
00:12:43,970 --> 00:12:50,180
And here you can see that training valid learning data set path validation data set uh images path and

199
00:12:50,180 --> 00:12:51,410
test images path.

200
00:12:51,410 --> 00:12:52,760
You can see over here.

201
00:12:55,730 --> 00:13:00,890
Well you just need to add this data dot yml file path over here which I've already added.

202
00:13:00,890 --> 00:13:01,880
And plus.

203
00:13:01,880 --> 00:13:05,240
So we just as we have restart the session.

204
00:13:05,240 --> 00:13:11,750
So you just need to run this cell again over here so that we can set this as our.

205
00:13:13,560 --> 00:13:14,850
Just need to run this cell once.

206
00:13:15,090 --> 00:13:15,270
Okay.

207
00:13:15,270 --> 00:13:16,020
That's fine.

208
00:13:16,380 --> 00:13:20,790
And if you just run this cell now, this will restart the training over here.

209
00:13:20,790 --> 00:13:22,890
It will start the training over here.

210
00:13:22,890 --> 00:13:29,670
So it will, uh, train or fine tune the Yolo v9 model on personal protective equipment data set over

211
00:13:30,240 --> 00:13:32,610
30 epochs, which you have mentioned over here.

212
00:13:32,610 --> 00:13:38,580
I have already done that training, or I have already fine tuned the YOLO v9 extended model with 30

213
00:13:38,580 --> 00:13:42,240
epochs on Personal Protective Equipment data set, which I have shown you.

214
00:13:42,240 --> 00:13:45,990
So now you can see over here and then let me just pull down.

215
00:13:45,990 --> 00:13:48,030
So the training takes a lot of time.

216
00:13:48,030 --> 00:13:49,710
So I'm not going to train again.

217
00:13:49,710 --> 00:13:52,200
Like previously it has taken over 30 epochs.

218
00:13:52,200 --> 00:13:57,750
It has taken 2.6 to 1 hours like it has taken around one 60 minutes.

219
00:13:58,110 --> 00:14:03,360
Uh, to fine tune the YOLO v9 model on personal protective equipment data set for 30 epochs.

220
00:14:03,360 --> 00:14:08,820
And in the end, we got the best model weights and the last model weights model weights on the last

221
00:14:08,820 --> 00:14:09,330
epoch.

222
00:14:09,330 --> 00:14:13,950
And the best model weights represents, uh, the epoch on which the model gives the best mean average

223
00:14:13,950 --> 00:14:14,940
precision scores.

224
00:14:14,940 --> 00:14:16,200
And they did.

225
00:14:16,200 --> 00:14:21,030
The last part basically are the model weights on the last epoch, which is the 30th epoch.

226
00:14:22,700 --> 00:14:23,060
Okay.

227
00:14:23,060 --> 00:14:29,000
And from here you can see, uh, if you just see mean, average precision, uh, like you can see here,

228
00:14:29,000 --> 00:14:34,670
class wise, the mean average precision with the IOU 0.5 and the mean average precision when IOU varies

229
00:14:34,670 --> 00:14:36,950
from 0.5 to 0.95.

230
00:14:36,950 --> 00:14:42,620
So now you can see over here we have the mean average precision for the dust mask i-we're glove, protective

231
00:14:42,620 --> 00:14:45,980
boots, protective helmet safety vest and shield class.

232
00:14:45,980 --> 00:14:51,320
So from here you can see that, uh, the mean average scores are very good, like we have for all the,

233
00:14:51,380 --> 00:15:00,380
uh, two classes we have mean average precision score above 90% for I use 0.5, and for only one, uh,

234
00:15:00,380 --> 00:15:07,220
for only one class, two classes, we have, uh, mean average precision with I use 0.4 scores below

235
00:15:07,490 --> 00:15:10,880
90%, one is 0.845 for IVR.

236
00:15:10,880 --> 00:15:19,580
And for the shield class we have the mean average precision score with IOU 0.5 0.761 or 76.1%, while

237
00:15:19,580 --> 00:15:26,330
the mean average for average precision score when IOU varies from 0.5 to 0.95 are pretty good as well,

238
00:15:26,330 --> 00:15:28,160
which you can see over the values over here.

239
00:15:28,160 --> 00:15:30,290
So the results are very promising for now.

240
00:15:32,290 --> 00:15:38,410
Okay, so I have already fine tuned the okay, just let me just save these changes.

241
00:15:38,410 --> 00:15:43,090
So as I already told you, I've already fine tuned the yellow benign model for the Personal Protective

242
00:15:43,120 --> 00:15:44,200
equipment data set.

243
00:15:44,620 --> 00:15:49,030
Uh, so I after finding running this, I have saved the best model weights into my right.

244
00:15:49,030 --> 00:15:53,410
So I will directly download the best model weights from right into this Google Colab notebook.

245
00:15:53,410 --> 00:15:59,560
And then we will do inference on images and on videos on this best model weights.

246
00:16:00,620 --> 00:16:05,000
So here we have the results which you usually get after training.

247
00:16:05,030 --> 00:16:09,230
So now you can see the mean average precision score is continuously increasing.

248
00:16:09,230 --> 00:16:12,170
And it goes up till zero above 90%.

249
00:16:12,170 --> 00:16:18,350
While you can see that mean average precision score when you varies from 0.5 to 0.95, is also increasing

250
00:16:18,350 --> 00:16:23,240
and goes up to 65% as well, while the loss is continuously decreasing.

251
00:16:23,240 --> 00:16:24,470
So this is very good.

252
00:16:25,040 --> 00:16:27,290
Okay so here we have the confusion matrix.

253
00:16:27,290 --> 00:16:32,840
So the confusion matrix basically tells us how our models handle our model handles different classes.

254
00:16:32,840 --> 00:16:36,710
So over here like you can see this is the confusion matrix chart.

255
00:16:36,710 --> 00:16:39,950
And here you can see we have all our seven different classes.

256
00:16:39,950 --> 00:16:46,550
The mask I-we're glove protective goods, protective uh helmet safety vest, shield and a background.

257
00:16:46,550 --> 00:16:51,320
When the thing is detected and we have the all these class names mentioned over here as well.

258
00:16:51,320 --> 00:16:54,380
So if we just see from the dust mask.

259
00:16:54,380 --> 00:17:01,910
So 94% of the times when there is a dust mask or when the person is wearing the dust mask, 94% of the

260
00:17:01,940 --> 00:17:06,800
times our model correctly detected that the person is wearing the dust mask.

261
00:17:07,220 --> 00:17:12,950
So 0.94 means, uh, 94% of the times when the person is wearing a dust mask.

262
00:17:13,130 --> 00:17:19,220
Our fine tuned YOLO benign model correctly detects that the person is wearing a dust mask.

263
00:17:20,990 --> 00:17:28,250
While 6% of the times when the person is wearing a dust mask, our model is unable to detect anything.

264
00:17:28,250 --> 00:17:30,050
So here you can see 0.06.

265
00:17:30,050 --> 00:17:36,740
So 6% of the times when the person is wearing a dust mask, our model is unable to detect anything.

266
00:17:37,040 --> 00:17:38,720
So next is I-we're.

267
00:17:39,230 --> 00:17:44,510
So it is 6% of the times when the person is wearing the Ibrd's.

268
00:17:44,660 --> 00:17:52,130
Our model correctly detects that the person is wearing the Ivrs while one person died when the person

269
00:17:52,130 --> 00:17:59,570
is wearing dust mask or model incorrectly when the person is so, one person died when the person is

270
00:17:59,570 --> 00:18:00,800
wearing I-we're.

271
00:18:00,950 --> 00:18:07,400
Our model incorrectly classified it as dust mask, so 86% of times when the person is wearing IVR,

272
00:18:07,400 --> 00:18:12,920
our model, correctly classified, detects that the person is wearing I-we're, while 1% of the times

273
00:18:12,920 --> 00:18:20,000
when the person is wearing I-we're, our model incorrectly detects it as dust mask.

274
00:18:21,110 --> 00:18:27,500
While 14% of times when the person is wearing i-we're or model is unable to detect any thing.

275
00:18:28,040 --> 00:18:28,430
Okay.

276
00:18:28,430 --> 00:18:34,220
And again, like you can see over here, cheat code, the shield is 76% of the times when the person

277
00:18:34,220 --> 00:18:41,360
is wearing shield or model correctly detects that the person is wearing a shield, while 4% of the times

278
00:18:41,360 --> 00:18:48,080
when the person is wearing a shield or model correctly, uh, detect it in our model incorrectly detected

279
00:18:48,080 --> 00:18:49,190
as protective helmet.

280
00:18:49,190 --> 00:18:57,020
So 4% of the times when the person is wearing a shield, our model incorrectly detect it as protective

281
00:18:57,020 --> 00:19:04,490
helmet, while 20% of time when the person is wearing a shield, our model, uh, does not detect anything.

282
00:19:04,490 --> 00:19:06,620
Okay, so this is our confusion matrix.

283
00:19:06,620 --> 00:19:09,410
So these are the model predictions for the validation batch.

284
00:19:09,410 --> 00:19:11,720
We have not used these images for training.

285
00:19:11,720 --> 00:19:15,080
So it's always better to take a look and see how our model performs.

286
00:19:15,080 --> 00:19:19,880
So from here you can see we have i-we're shear protective helmet.

287
00:19:19,880 --> 00:19:21,440
And so on so forth.

288
00:19:23,000 --> 00:19:24,950
So the results from here are very promising.

289
00:19:25,340 --> 00:19:26,930
So now we will do model.

290
00:19:27,110 --> 00:19:33,590
Uh, so now we will uh, just evaluate our model on the validation set images and see, uh, how our

291
00:19:33,590 --> 00:19:34,310
model performs.

292
00:19:34,310 --> 00:19:38,540
So now we are just evaluating our model on the validation data set images.

293
00:19:38,540 --> 00:19:41,660
And over here you can see that the results are quite promising.

294
00:19:41,660 --> 00:19:47,510
And you can see over here, uh, we have got very good mean average precision score with IOU 0.5 and

295
00:19:47,510 --> 00:19:52,040
very good mean average precision score when IOU varies from 0.5 to 0.95.

296
00:19:52,040 --> 00:19:55,940
So now we will be doing inference on images and videos over here.

297
00:19:55,940 --> 00:19:58,490
So you can download these two videos.

298
00:19:58,490 --> 00:20:02,780
I have already placed those videos into my drives or will directly download those videos from drive

299
00:20:02,900 --> 00:20:05,240
into this Google Colab notebook.

300
00:20:06,530 --> 00:20:08,420
So I'm downloading these videos.

301
00:20:08,420 --> 00:20:14,720
So now, first of all, uh, if you just see over here, uh, so now to do inference with your model.

302
00:20:14,720 --> 00:20:17,480
So you will just Python detects that your.py.

303
00:20:17,480 --> 00:20:20,690
And if you want to do inference with Glenn model you will run to detect.

304
00:20:21,530 --> 00:20:24,950
So as I want to do inference with yolo v nine model on image.

305
00:20:24,950 --> 00:20:27,800
So I will just run detect-dual.py.

306
00:20:27,800 --> 00:20:31,040
And if I want to do inference on videos I will run the same script.

307
00:20:31,040 --> 00:20:36,650
And here I've just passed the source image and I'll just pass the best model weights which I have downloaded

308
00:20:36,650 --> 00:20:37,370
from drive.

309
00:20:37,460 --> 00:20:42,050
And I've selected the devices GPUs and GPU.

310
00:20:42,050 --> 00:20:46,250
And if you decide you want to use CPU, you can simply write CPU over here.

311
00:20:56,250 --> 00:20:59,760
Okay, so now, uh, our output image is saved in this folder.

312
00:20:59,760 --> 00:21:05,940
So you just see over here runs a Dag, and in this folder we have the output image.

313
00:21:05,940 --> 00:21:08,730
So I've already added this path over here.

314
00:21:08,940 --> 00:21:12,960
So let me just display this output image over here okay.

315
00:21:14,770 --> 00:21:16,870
So I think, uh, there's an error.

316
00:21:16,870 --> 00:21:24,970
So I think I've just, uh, I just copy this from here and see where I have placed my image library.

317
00:21:26,860 --> 00:21:29,710
Here again?

318
00:21:31,870 --> 00:21:33,670
I think I have just, uh.

319
00:21:35,040 --> 00:21:36,150
Just give me a minute.

320
00:21:36,150 --> 00:21:37,530
Let me see where we have.

321
00:21:37,530 --> 00:21:41,160
Or we can just, uh, initialize this library again.

322
00:21:42,360 --> 00:21:44,730
Okay, so here you can see we have the library.

323
00:21:44,910 --> 00:21:50,670
So this, uh, image library allows us to display an image into our Google Colab notebook.

324
00:21:50,880 --> 00:21:53,640
So now it will display the output image over here.

325
00:21:53,640 --> 00:21:56,040
So let's plot this cell again.

326
00:21:56,040 --> 00:21:59,640
So now you can see, uh, we have tested on this random image.

327
00:21:59,640 --> 00:22:04,860
And we are able to detect a protective helmet and the safety vest that this person that this person

328
00:22:04,860 --> 00:22:05,460
is wearing.

329
00:22:05,850 --> 00:22:10,080
So now we will just do the inference on the videos, two videos which we have downloaded.

330
00:22:12,360 --> 00:22:14,880
So now you can see the inference has started.

331
00:22:14,880 --> 00:22:17,490
So let's see the how it goes.

332
00:22:17,490 --> 00:22:19,230
So we are using the best model weights.

333
00:22:19,230 --> 00:22:22,350
So our complete video is being divided into three and ten frames.

334
00:22:22,350 --> 00:22:25,920
And we will be doing uh detections on each of the frame one by one.

335
00:22:25,920 --> 00:22:27,120
Like you can see over here.

336
00:22:27,120 --> 00:22:32,820
We are able to detect the protective helmet, safety vest, protective boots and so on.

337
00:22:32,820 --> 00:22:34,530
And the results look quite good.

338
00:22:34,530 --> 00:22:40,770
Like, uh, six protective boots, three protective helmets, six safety vests, five safety vests,

339
00:22:40,770 --> 00:22:42,780
vests the person are wearing.

340
00:22:43,290 --> 00:22:43,620
So.

341
00:22:45,470 --> 00:22:45,920
Okay.

342
00:22:45,920 --> 00:22:52,880
So now you can see over here and let's display the output video into this Google Colab notebook over

343
00:22:52,880 --> 00:22:53,840
here as well.

344
00:23:01,560 --> 00:23:04,590
So this might take a few more seconds before we have the results.

345
00:23:08,430 --> 00:23:10,440
So let's wait and see.

346
00:23:10,440 --> 00:23:12,480
How does it goes over here?

347
00:23:12,840 --> 00:23:19,770
So after this we will be doing detections on this part two videos as we have already two videos.

348
00:23:20,100 --> 00:23:22,530
So now we are doing inference on this video.

349
00:23:22,530 --> 00:23:26,790
After this we will do perform inference on this second video as well.

350
00:23:27,300 --> 00:23:27,870
Okay.

351
00:23:29,100 --> 00:23:32,310
So this might take few more seconds before it gets completed.

352
00:23:36,020 --> 00:23:38,150
Look it is our output video.

353
00:23:38,150 --> 00:23:43,130
So let me download this video first and let's see how does it goes.

354
00:23:43,550 --> 00:23:51,890
So over here, if I just open this video now and let me just uh, navigate my screen towards the output

355
00:23:51,890 --> 00:23:52,610
video.

356
00:23:52,940 --> 00:23:58,100
So over here you can see that we are able to detect a safety vest, protective helmets, protective

357
00:23:58,100 --> 00:23:58,820
boots.

358
00:23:58,820 --> 00:24:03,020
So now you can see the results look very promising from here.

359
00:24:03,590 --> 00:24:04,070
Okay.

360
00:24:04,430 --> 00:24:09,410
And if I just go again over here okay.

361
00:24:09,800 --> 00:24:11,150
And now we will, uh.

362
00:24:12,380 --> 00:24:12,650
It.

363
00:24:16,200 --> 00:24:17,580
And just give me a second.

364
00:24:19,730 --> 00:24:27,890
Now we will load inference on the second video of using the fine tuned YOLO v9 model on personal image,

365
00:24:27,890 --> 00:24:30,680
we have fine tuned on the Personal Protective equipment data set.

366
00:24:30,680 --> 00:24:34,220
So now we are doing inference on the second video over here.

367
00:24:36,910 --> 00:24:40,900
So this might take a few more seconds before it gets, uh.

368
00:24:41,590 --> 00:24:45,190
So the complete video is being divided into 267 frames.

369
00:24:45,340 --> 00:24:45,700
Okay.

370
00:24:45,700 --> 00:24:46,300
Over here.

371
00:24:46,300 --> 00:24:48,400
And like you can see over here.

372
00:24:50,480 --> 00:24:53,180
We are doing detection on each of the frame one by one.

373
00:24:53,730 --> 00:24:56,280
So what's whiteboard.

374
00:24:56,280 --> 00:24:58,260
And it's going quite good.

375
00:24:58,710 --> 00:25:00,840
So it will be finished soon.

376
00:25:00,840 --> 00:25:03,360
So now you can see the processing is done.

377
00:25:03,900 --> 00:25:06,960
So let me display this output video over here.

378
00:25:07,620 --> 00:25:07,920
It.

379
00:25:12,400 --> 00:25:16,510
So this might take a few seconds before we have the output video over here.

380
00:25:19,890 --> 00:25:23,160
Well, here is our output video and let me just download this first.

381
00:25:24,020 --> 00:25:25,880
And let me just open this.

382
00:25:25,880 --> 00:25:28,130
So let me first navigate my screen towards it.

383
00:25:30,690 --> 00:25:37,590
So over here you can see that we are already able to detect the safety wears, protective boots, helmet

384
00:25:37,590 --> 00:25:38,310
as well.

385
00:25:38,310 --> 00:25:40,860
And the results look very promising as well.

386
00:25:40,860 --> 00:25:46,830
So in this tutorial we have learned that how we can do personal protective equipment detection on images

387
00:25:46,830 --> 00:25:47,520
and videos.

388
00:25:47,520 --> 00:25:53,820
And we have also learned that how we can fine tune the YOLO v9 model or any custom data set like you

389
00:25:53,820 --> 00:25:59,280
can also find on the YOLO v9 model, on helmets, data set, or on any cars data set.

390
00:25:59,280 --> 00:26:02,490
Or you can also do on any other data set.

391
00:26:02,490 --> 00:26:08,130
You can also fine tune the YOLO benign model on license plate data set pins and books, data set, potholes,

392
00:26:08,130 --> 00:26:09,720
data set, and so on.

393
00:26:09,870 --> 00:26:16,080
There are so many applications like you can fine tune the benign model on grocery data sets as well.

394
00:26:16,080 --> 00:26:20,970
So there are so many applications that exist, you just need to explore that as well.

395
00:26:20,970 --> 00:26:22,500
So that's all from this tutorial.

396
00:26:22,500 --> 00:26:23,370
Thank you for watching.
