1
00:00:02,000 --> 00:00:04,000
I know everyone in this video tutorial.

2
00:00:04,000 --> 00:00:11,000
We will see how we can train our YOLO V8 model for traffic, light detection and color recognition.

3
00:00:11,000 --> 00:00:16,000
So for this project I will be using that traffic light data set available on Roboflow.

4
00:00:16,000 --> 00:00:21,000
This is a publicly available dataset, so how you can access this dataset.

5
00:00:21,000 --> 00:00:22,000
Let me show you.

6
00:00:22,000 --> 00:00:28,000
You just need to go over here and write Roboflow and just click on the first link which appears over

7
00:00:28,000 --> 00:00:28,000
here.

8
00:00:29,000 --> 00:00:34,000
And if you haven't created your account, you can create your account on roboflow by clicking on sign

9
00:00:34,000 --> 00:00:35,000
up.

10
00:00:35,000 --> 00:00:41,000
So I have already created an account, so I will just click on sign in so it will redirect me to the

11
00:00:41,000 --> 00:00:45,000
side like I want to sign it with my google email.

12
00:00:46,000 --> 00:00:47,000
Okay.

13
00:00:47,000 --> 00:00:49,000
So it might take few seconds.

14
00:00:49,000 --> 00:00:49,000
Okay.

15
00:00:49,000 --> 00:00:51,000
Just sign in with your.

16
00:00:51,000 --> 00:00:54,000
I'm just going to sign in with my Google email.

17
00:00:54,000 --> 00:00:55,000
Okay.

18
00:00:56,000 --> 00:00:57,000
So it might take few seconds.

19
00:00:57,000 --> 00:00:58,000
So let's say.

20
00:00:59,000 --> 00:00:59,000
Okay.

21
00:01:01,000 --> 00:01:03,000
But so I am able to sign in.

22
00:01:03,000 --> 00:01:06,000
So I will just go to Universe over here.

23
00:01:06,000 --> 00:01:07,000
Then I will.

24
00:01:07,000 --> 00:01:07,000
Here.

25
00:01:07,000 --> 00:01:07,000
Right.

26
00:01:08,000 --> 00:01:10,000
Traffic lights.

27
00:01:12,000 --> 00:01:13,000
Better said.

28
00:01:15,000 --> 00:01:16,000
In the.

29
00:01:17,000 --> 00:01:19,000
This the name of the dataset?

30
00:01:19,000 --> 00:01:20,000
We do one.

31
00:01:21,000 --> 00:01:21,000
Okay.

32
00:01:22,000 --> 00:01:23,000
So.

33
00:01:23,000 --> 00:01:24,000
So here is the dataset.

34
00:01:24,000 --> 00:01:30,000
Basically, the the name of the dataset is on Roboflow is Cinta V2 and dash one represents the version

35
00:01:30,000 --> 00:01:31,000
one.

36
00:01:31,000 --> 00:01:32,000
Okay.

37
00:01:32,000 --> 00:01:39,000
So if you click over here, we have around 1000 images in our dataset and we have around three classes.

38
00:01:39,000 --> 00:01:42,000
If we can see over here, let me show you.

39
00:01:43,000 --> 00:01:47,000
So you can see that we have red, green and yellow glass over here.

40
00:01:47,000 --> 00:01:49,000
So we have three classes.

41
00:01:50,000 --> 00:01:53,000
If it is a red signal, it will appear that it is red.

42
00:01:53,000 --> 00:01:55,000
If it is a green signal, it will appear green.

43
00:01:55,000 --> 00:01:59,000
And if it is a yellow signal, the label will appear yellow.

44
00:01:59,000 --> 00:02:00,000
Okay.

45
00:02:00,000 --> 00:02:08,000
So and as far as the health check of the model is concerned, we can see that the yellow class is underrepresented

46
00:02:08,000 --> 00:02:10,000
while all other classes are balanced.

47
00:02:10,000 --> 00:02:11,000
Okay.

48
00:02:11,000 --> 00:02:20,000
And we have around 103 hundred 1320 annotation like each image contains around 1 to 2 annotated annotations.

49
00:02:20,000 --> 00:02:21,000
Okay.

50
00:02:21,000 --> 00:02:23,000
And we have three classes in our dataset.

51
00:02:25,000 --> 00:02:32,000
Okay, so let's export this data set into our Google CoLab notebook and let's implement this project.

52
00:02:35,000 --> 00:02:37,000
Well, guys, here is our code.

53
00:02:37,000 --> 00:02:39,000
In the first step, I am importing the library.

54
00:02:39,000 --> 00:02:47,000
So library basically through library, I will create a helper variable which helps me to navigate between

55
00:02:47,000 --> 00:02:48,000
different file paths.

56
00:02:48,000 --> 00:02:55,000
Okay, so here I have created a helper variable using library, so it helps me navigate between the

57
00:02:55,000 --> 00:02:56,000
different file paths.

58
00:02:56,000 --> 00:02:59,000
In the next step, I am importing the Globe Library.

59
00:02:59,000 --> 00:03:05,000
Okay, so Globe Library basically returns me all file paths that match the specific pattern.

60
00:03:05,000 --> 00:03:14,000
So here I'm using Globe Library when I test my train model on traffic light dataset on some test images

61
00:03:14,000 --> 00:03:18,000
to display the output of the test images I will use on Google CoLab notebook.

62
00:03:18,000 --> 00:03:20,000
I will use Globe Library.

63
00:03:20,000 --> 00:03:24,000
Next, I will have the importing the image and display libraries.

64
00:03:24,000 --> 00:03:30,000
So to display any input, image or output image into the Google CoLab notebook, I require the image

65
00:03:30,000 --> 00:03:31,000
and the display library.

66
00:03:31,000 --> 00:03:37,000
Okay, so in the next step we will check whether we have the access to GPU or not.

67
00:03:37,000 --> 00:03:44,000
So by just running this cell you can check that there is GPU memory usage, which means that you are

68
00:03:44,000 --> 00:03:47,000
using the GPU and you have the access to GPU.

69
00:03:47,000 --> 00:03:48,000
So.

70
00:03:49,000 --> 00:03:53,000
Next we will using using OS library.

71
00:03:53,000 --> 00:03:55,000
I'm checking my path.

72
00:03:55,000 --> 00:03:56,000
Home path.

73
00:03:56,000 --> 00:03:58,000
So it's this path over here.

74
00:03:58,000 --> 00:04:01,000
So in the next step I will install ultralytics.

75
00:04:01,000 --> 00:04:02,000
Okay.

76
00:04:02,000 --> 00:04:06,000
So ultralytics can be installed in two ways from the source or PIP.

77
00:04:06,000 --> 00:04:11,000
So this is the first iteration of the YOLO to have its own official package.

78
00:04:11,000 --> 00:04:15,000
So it is always recommended to use PIP install ultralytics.

79
00:04:15,000 --> 00:04:19,000
But for the development you will need to clone the github repo.

80
00:04:19,000 --> 00:04:23,000
So I'm just cloning the latest GitHub repo over here.

81
00:04:23,000 --> 00:04:24,000
So.

82
00:04:24,000 --> 00:04:27,000
But if you want to simply train, test or validate your model.

83
00:04:27,000 --> 00:04:31,000
So it's always better to use the command line interface and just to PIP install the tragedies.

84
00:04:31,000 --> 00:04:38,000
But in this project I'm going to change the bounding box color so I will be doing some development in

85
00:04:38,000 --> 00:04:39,000
the plotting.py file.

86
00:04:39,000 --> 00:04:45,000
So here I will be using the I will be cloning the github repo in this project.

87
00:04:45,000 --> 00:04:51,000
So I am cloning the github repo ultralytics over in this project over here.

88
00:04:51,000 --> 00:04:57,000
So by just running this cell we will be able to clone the GitHub repo over here and you can see that

89
00:04:57,000 --> 00:05:00,000
the GitHub repo is cloned and it's appearing over here.

90
00:05:00,000 --> 00:05:05,000
So I have just forked the latest GitHub repo into my GitHub account.

91
00:05:05,000 --> 00:05:09,000
So it's just appearing there for here you can see my name, so I've just popped the GitHub repo.

92
00:05:10,000 --> 00:05:10,000
Okay.

93
00:05:10,000 --> 00:05:16,000
So here now I have just uh, here you can see that ultralytics GitHub repo.

94
00:05:16,000 --> 00:05:23,000
So basically my current directory is set at this path now to set the current directory as this folder.

95
00:05:23,000 --> 00:05:30,000
So you just need to go here and just rename folder and copy this and just write over here.

96
00:05:30,000 --> 00:05:33,000
So your current directory will be set to this folder now.

97
00:05:35,000 --> 00:05:40,000
Now, basically we need to install all the requirements or the dependencies so it's necessary that we

98
00:05:40,000 --> 00:05:43,000
install all the required libraries to run our project.

99
00:05:44,000 --> 00:05:44,000
Okay.

100
00:05:44,000 --> 00:05:45,000
So.

101
00:05:45,000 --> 00:05:46,000
With.

102
00:05:46,000 --> 00:05:51,000
So if we don't skip this step or don't install all the dependencies, then you might face the issue

103
00:05:51,000 --> 00:05:52,000
that when you run the training script.

104
00:05:52,000 --> 00:05:57,000
So you might get the error that the following library is not installed or the following library is not

105
00:05:57,000 --> 00:05:58,000
installed.

106
00:05:58,000 --> 00:06:01,000
So like Matplotlib library is not installed.

107
00:06:01,000 --> 00:06:02,000
Library is not installed.

108
00:06:02,000 --> 00:06:07,000
Seaborn library is not installed, so it's always better to install all the dependencies.

109
00:06:07,000 --> 00:06:12,000
So when we run the training prediction or validation script, we don't face this error that the following

110
00:06:12,000 --> 00:06:16,000
library is not installed like matplotlib or anyone.

111
00:06:16,000 --> 00:06:22,000
So if you run install all the dependencies, it will install all the required libraries and you don't

112
00:06:22,000 --> 00:06:25,000
face this issue any later libraries issue later.

113
00:06:25,000 --> 00:06:29,000
So now we just need to check whether Ultralytics is installed and it's working fine.

114
00:06:29,000 --> 00:06:36,000
So just click on import ultralytics and ultralytics checks which will tell us.

115
00:06:36,000 --> 00:06:41,000
Okay, so I'll tell you this, you'll be getting setup is a complete and it's working fine.

116
00:06:41,000 --> 00:06:41,000
Okay.

117
00:06:42,000 --> 00:06:43,000
So next.

118
00:06:44,000 --> 00:06:47,000
Basically we need to go to the ultralytics.

119
00:06:47,000 --> 00:06:49,000
Ultralytics Yolo.

120
00:06:49,000 --> 00:06:53,000
Then when we go to paid and then we go to the detect folder.

121
00:06:53,000 --> 00:06:54,000
Okay.

122
00:06:54,000 --> 00:06:59,000
So basically in this case we are doing the detection, not the segmentation or classification.

123
00:06:59,000 --> 00:07:02,000
So I will set this as my current directory, which you can see over here.

124
00:07:02,000 --> 00:07:07,000
So you just need to go here, copy path and just paste this path over here.

125
00:07:07,000 --> 00:07:10,000
So I'm just setting this folder as my current directory.

126
00:07:10,000 --> 00:07:16,000
In the next step, I will download this data set from Roboflow, which you can see over here.

127
00:07:16,000 --> 00:07:24,000
So just go over here, go to the images or go to the datasets and click on download and select a format

128
00:07:24,000 --> 00:07:31,000
so you can select the V8 or YOLO V5 by just format because YOLO, V8 and YOLO V5 both are released by

129
00:07:31,000 --> 00:07:34,000
the ULTRALYTICS so you can choose any of the format.

130
00:07:34,000 --> 00:07:42,000
So just copy this from here, click on copy and just paste this over here, Ctrl V and just.

131
00:07:44,000 --> 00:07:45,000
Run this now.

132
00:07:45,000 --> 00:07:46,000
So it might take.

133
00:07:48,000 --> 00:07:48,000
Okay.

134
00:07:48,000 --> 00:07:49,000
I made a mistake.

135
00:07:49,000 --> 00:07:50,000
I have not run this cell.

136
00:07:50,000 --> 00:07:55,000
So just run this cell first and then get back and run.

137
00:07:55,000 --> 00:07:58,000
Because I need to download the data set in this folder.

138
00:07:58,000 --> 00:08:01,000
So now the data set will be downloaded over here.

139
00:08:02,000 --> 00:08:02,000
Okay, guys.

140
00:08:04,000 --> 00:08:07,000
So it might take a few seconds for the dataset.

141
00:08:07,000 --> 00:08:14,000
We downloaded it like you can see that it's downloaded in the zip format and after this it will automatically

142
00:08:14,000 --> 00:08:15,000
unzip the dataset.

143
00:08:15,000 --> 00:08:17,000
So first it's downloading the zip format.

144
00:08:17,000 --> 00:08:23,000
You can see that downloading data was set version, zip send out, send out.

145
00:08:23,000 --> 00:08:28,000
We do dash one represents the version one, and this is the name of the dataset which the user, which

146
00:08:28,000 --> 00:08:31,000
user who has uploaded this dataset has named it.

147
00:08:32,000 --> 00:08:32,000
Okay.

148
00:08:32,000 --> 00:08:39,000
So you can see here the dataset is 100% downloaded and will now be able to see the dataset over here.

149
00:08:44,000 --> 00:08:46,000
Let's refresh it and just see.

150
00:08:46,000 --> 00:08:46,000
Okay.

151
00:08:46,000 --> 00:08:51,000
So we can see that we have the data set over here in the V2 version one.

152
00:08:51,000 --> 00:08:57,000
And if we go over here and we have the data dot yml file which contains the training and validation

153
00:08:57,000 --> 00:08:57,000
part.

154
00:08:57,000 --> 00:09:04,000
So just rename this folder, remove that dash one from here because it might create an error when we

155
00:09:04,000 --> 00:09:06,000
run the training script and go to.

156
00:09:07,000 --> 00:09:12,000
Okay, so just click over here now and just go over here.

157
00:09:12,000 --> 00:09:18,000
Just close this now and just reopen the data dot yml file and just go over here.

158
00:09:18,000 --> 00:09:19,000
Click on training.

159
00:09:19,000 --> 00:09:21,000
Copy the images path and just.

160
00:09:23,000 --> 00:09:31,000
Okay, so just control V over here and just then go to the validation folder and just click over here.

161
00:09:31,000 --> 00:09:36,000
Copy path and control C and control V and just save it now.

162
00:09:37,000 --> 00:09:38,000
Okay, that's good.

163
00:09:38,000 --> 00:09:42,000
In the next step, just see what our current directory is.

164
00:09:42,000 --> 00:09:42,000
So.

165
00:09:42,000 --> 00:09:42,000
Okay.

166
00:09:42,000 --> 00:09:45,000
And the data set location we are checking out.

167
00:09:47,000 --> 00:09:47,000
Okay.

168
00:09:51,000 --> 00:09:55,000
Just look over here and write dataset dot location.

169
00:09:56,000 --> 00:09:56,000
Okay.

170
00:09:56,000 --> 00:10:02,000
And just add the columns over here and just copy this path.

171
00:10:03,000 --> 00:10:08,000
And just paste it over here and just run this and now just run this cell over here again.

172
00:10:08,000 --> 00:10:10,000
And now let's set.

173
00:10:10,000 --> 00:10:14,000
So we have set the data set dot location as well.

174
00:10:14,000 --> 00:10:18,000
Our home path is set and everything is fine.

175
00:10:18,000 --> 00:10:25,000
So let's start that training of our YOLO V8 model on traffic, light detection and color recognition

176
00:10:25,000 --> 00:10:26,000
data set.

177
00:10:26,000 --> 00:10:33,000
So first it is downloading YOLO V8 and dot model dot model over here and the training will now start.

178
00:10:33,000 --> 00:10:40,000
We can see that we have around 2100 images for that training and 200 images for the validation.

179
00:10:40,000 --> 00:10:41,000
Okay.

180
00:10:41,000 --> 00:10:46,000
And our results will be saved in that data train folder which is created over here.

181
00:10:46,000 --> 00:10:48,000
We just refresh it.

182
00:10:48,000 --> 00:10:53,000
So here in this folder, our weights file will be saved.

183
00:10:53,000 --> 00:10:56,000
In this folder, our weights file will save.

184
00:10:56,000 --> 00:11:03,000
And here also in the train folder, we can see the confusion matrix validation batch results and the

185
00:11:03,000 --> 00:11:07,000
F1 cars precision recall girls after training completes.

186
00:11:07,000 --> 00:11:09,000
So the training is about to start.

187
00:11:09,000 --> 00:11:16,000
So it might take it will take around 2 to 3 hours for the model trained on this data set.

188
00:11:16,000 --> 00:11:17,000
Okay.

189
00:11:17,000 --> 00:11:23,000
So as the training stop starts, I will pause the video and when the training completes, I will be

190
00:11:23,000 --> 00:11:23,000
back.

191
00:11:24,000 --> 00:11:26,000
So I'm just waiting for the training to start.

192
00:11:29,000 --> 00:11:31,000
Okay, so it might take a few seconds.

193
00:11:35,000 --> 00:11:37,000
Well, guys, it's taking time.

194
00:11:37,000 --> 00:11:43,000
So as the training completes, I will be back and I will explain you the how the complete process flow,

195
00:11:43,000 --> 00:11:47,000
the remaining process flow, and we'll discuss the results as well.

196
00:11:47,000 --> 00:11:49,000
So let's get back when the training completes.

197
00:11:50,000 --> 00:11:55,000
So guys, our YOLO V8 model has completed training on traffic light dataset.

198
00:11:55,000 --> 00:11:57,000
So here are the results.

199
00:11:57,000 --> 00:12:02,000
We have trained our model on 80 epochs and so here are our results.

200
00:12:02,000 --> 00:12:08,000
So it is starting from first epoch and you can see that we have at the first epoch we have a mean average

201
00:12:08,000 --> 00:12:12,000
precision with 50 is 0.535.

202
00:12:12,000 --> 00:12:18,000
While mean average precision with IOU varies from 50 to 95 is 0.252.

203
00:12:18,000 --> 00:12:23,000
So you can see that as the training progresses, the mean average precision begins to improve.

204
00:12:23,000 --> 00:12:25,000
So it's continuously improving.

205
00:12:25,000 --> 00:12:29,000
And when the training lasts on the eight, nine 80th epoch.

206
00:12:29,000 --> 00:12:34,000
So there we get the mean average precision which is given over here.

207
00:12:34,000 --> 00:12:42,000
We have a mean average precision with 50 is 0.983 while mean average precision with IOU 50 to 95 is

208
00:12:42,000 --> 00:12:46,000
0.641%, which are which is very good.

209
00:12:46,000 --> 00:12:52,000
And at the end of the training we got our best players on which our model gives us the best results

210
00:12:52,000 --> 00:12:57,000
and we have the best of on the last epoch, which is eight epoch.

211
00:12:57,000 --> 00:13:03,000
So these are the weights on the last epoch, the last.is the weights on the last epoch, which is on

212
00:13:03,000 --> 00:13:09,000
the 80th epoch, while best dot contains the weight on, on that epoch, on which model gives us the

213
00:13:09,000 --> 00:13:10,000
best results.

214
00:13:10,000 --> 00:13:17,000
So the model took around 2.2 hours and 30 minutes to train, so it took around one 50 minutes for the

215
00:13:17,000 --> 00:13:22,000
training and here are our results final.

216
00:13:22,000 --> 00:13:28,000
And you can see that on each class, like on the green one, the green class, we have a mean average

217
00:13:28,000 --> 00:13:31,000
precision with IOU 50 as 0.976.

218
00:13:31,000 --> 00:13:36,000
On the red class, we have our mean average precision with IOU 50 as 0.988.

219
00:13:36,000 --> 00:13:41,000
And on the yellow class we have a mean average precision with IOU 50 as 0.986.

220
00:13:41,000 --> 00:13:48,000
And similarly, we have a mean average precision where IOU varies from 50 to 95 is given here as well.

221
00:13:48,000 --> 00:13:55,000
So the results are very satisfying and our results are saved in over here we can go to.

222
00:13:55,000 --> 00:13:57,000
Ultralytics Yolo.

223
00:13:57,000 --> 00:14:01,000
Then we will go to V8 and then we go to detect.

224
00:14:01,000 --> 00:14:03,000
And then we go to runs.

225
00:14:03,000 --> 00:14:08,000
And then if we go to the detect and then if we go to the train tool.

226
00:14:08,000 --> 00:14:11,000
So here we can see that our results are saved.

227
00:14:11,000 --> 00:14:17,000
Here we have the weights folder which contains our best and last weights while on the last epoch and

228
00:14:17,000 --> 00:14:22,000
best weights file is on that epoch on which the model gives us the best results.

229
00:14:22,000 --> 00:14:26,000
So here we have the best weights file and the last epoch weights file.

230
00:14:26,000 --> 00:14:29,000
And here we also have the F1 curves curves.

231
00:14:29,000 --> 00:14:35,000
So to display or to see all the files, what different files we have over here.

232
00:14:35,000 --> 00:14:43,000
So I will just write this home path, set the home path and just add the path of this folder.

233
00:14:43,000 --> 00:14:49,000
Like just copy the path and paste it over here and just run this cell so it will show you all the files

234
00:14:49,000 --> 00:14:50,000
which we have over here.

235
00:14:50,000 --> 00:14:55,000
We have the training batch results, we have the predictions on the validation batch which are given.

236
00:14:55,000 --> 00:14:56,000
Over here.

237
00:14:56,000 --> 00:14:58,000
We have the F1 gov.

238
00:14:59,000 --> 00:14:59,000
Gov.

239
00:14:59,000 --> 00:15:01,000
We have the confusion matrix as well.

240
00:15:01,000 --> 00:15:04,000
So the most important thing is the confusion matrix.

241
00:15:04,000 --> 00:15:09,000
So confusion matrix is the chart that shows how our models handles different classes.

242
00:15:09,000 --> 00:15:13,000
So in this case we have three different classes green, red and yellow glass.

243
00:15:13,000 --> 00:15:17,000
So let me see what results do we get with the confusion matrix?

244
00:15:17,000 --> 00:15:24,000
So like you can see that in green we have 96% of the time over here if you see over here.

245
00:15:24,000 --> 00:15:26,000
So 96% are dying.

246
00:15:26,000 --> 00:15:31,000
The model detected correctly that currently the green light is on or the traffic signal is on the green

247
00:15:31,000 --> 00:15:34,000
light while 2% were dying.

248
00:15:34,000 --> 00:15:41,000
We get the bounding box, but the green light over here is incorrectly classified as the red light,

249
00:15:41,000 --> 00:15:43,000
while 1%.

250
00:15:43,000 --> 00:15:45,000
Over time we also get the bounding box.

251
00:15:45,000 --> 00:15:52,000
But the green light is incorrectly classified as the yellow light, while 1% of the remaining 1% of

252
00:15:52,000 --> 00:15:54,000
time when the green light is on.

253
00:15:54,000 --> 00:15:57,000
But our model is unable to detect anything.

254
00:15:57,000 --> 00:16:03,000
Okay, so this is a very detailed example of how we can look, what we can judge from the confusion

255
00:16:03,000 --> 00:16:04,000
matrix.

256
00:16:04,000 --> 00:16:05,000
So our results are very good.

257
00:16:05,000 --> 00:16:11,000
Like 96 of the percent of the time our model has detected correctly that the green light is on, while

258
00:16:11,000 --> 00:16:17,000
2% of the time our model incorrectly classified the green light as the red light, while 1% of the time

259
00:16:17,000 --> 00:16:23,000
the green light is incorrectly classified as the yellow light while remaining 1% of the time, our model

260
00:16:23,000 --> 00:16:25,000
is unable to detect anything.

261
00:16:25,000 --> 00:16:26,000
Okay.

262
00:16:27,000 --> 00:16:33,000
So here are the training and validation loss results so you can see that the loss is being converging.

263
00:16:33,000 --> 00:16:39,000
So if we train our model to 250 or 300 epochs, we can say that the result will further improve.

264
00:16:39,000 --> 00:16:45,000
While you can see that mean average precision is a bit increasing, you can see over here, okay, so

265
00:16:45,000 --> 00:16:48,000
these are the model predictions on the validation batch.

266
00:16:48,000 --> 00:16:53,000
So as the validation batch is not used in the training, so it's always better to have a look at the

267
00:16:53,000 --> 00:16:55,000
predictions on the validation batch.

268
00:16:55,000 --> 00:17:00,000
So you can see that the model is detecting correctly that the red light is on here, the yellow and

269
00:17:00,000 --> 00:17:00,000
here is the green.

270
00:17:00,000 --> 00:17:05,000
But you can see that when the green light is on the bounding box, color is also red.

271
00:17:05,000 --> 00:17:06,000
Okay?

272
00:17:06,000 --> 00:17:12,000
So you can see that here we also have the when we have the green light, you can see that over here,

273
00:17:12,000 --> 00:17:16,000
the bounding box color and the label color is also red.

274
00:17:16,000 --> 00:17:22,000
But think when the green light is on the bounding box color and the label color should be green.

275
00:17:22,000 --> 00:17:27,000
And when like here, when the yellow light is on, it shouldn't be the bounding box.

276
00:17:27,000 --> 00:17:30,000
Color shouldn't be orange, it should be yellow.

277
00:17:30,000 --> 00:17:30,000
Okay.

278
00:17:30,000 --> 00:17:34,000
And when the red light is on, it should the color should not be light pink, which you can see over

279
00:17:34,000 --> 00:17:36,000
here, it should be red.

280
00:17:36,000 --> 00:17:38,000
So we need to make these changes.

281
00:17:38,000 --> 00:17:42,000
So to make this changes, I will go to the.

282
00:17:43,000 --> 00:17:48,000
I would just go click over here and just will go to the predict.py file.

283
00:17:50,000 --> 00:17:51,000
Let's me go to first.

284
00:17:51,000 --> 00:17:52,000
I will go to.

285
00:17:55,000 --> 00:18:03,000
I need to make a change on the utils and from here I will go to the plotting.py file and here I will

286
00:18:03,000 --> 00:18:05,000
set the colors over here.

287
00:18:05,000 --> 00:18:07,000
I have already set the colors, but let me explain you.

288
00:18:07,000 --> 00:18:09,000
So set the colors first.

289
00:18:09,000 --> 00:18:11,000
You need to go to the a data set.

290
00:18:11,000 --> 00:18:16,000
So here we have the data set and set open the data dot yml file.

291
00:18:16,000 --> 00:18:22,000
So you just see over here the first class is green, the second class is red and the third class is

292
00:18:22,000 --> 00:18:23,000
yellow.

293
00:18:23,000 --> 00:18:25,000
Okay, so just copy green.

294
00:18:25,000 --> 00:18:30,000
So green coloring hacks just type on Google, green color on hacks.

295
00:18:30,000 --> 00:18:36,000
So just copy this from here, Ctrl C and just open the plotting dot pie.

296
00:18:36,000 --> 00:18:36,000
Okay.

297
00:18:38,000 --> 00:18:43,000
And just paste this color over here because it is taking the input as the color, as the it is, taking

298
00:18:43,000 --> 00:18:45,000
the color in the form of hex.

299
00:18:45,000 --> 00:18:47,000
Then go to the second color, which is red.

300
00:18:47,000 --> 00:18:51,000
So just copy this and write red color in hex.

301
00:18:51,000 --> 00:18:58,000
So just copy this from here and just paste this over here.

302
00:18:59,000 --> 00:19:03,000
And I'll just go over here and see yellow.

303
00:19:03,000 --> 00:19:07,000
So now you write yellow color in Hex, so you will go class by class.

304
00:19:07,000 --> 00:19:09,000
You will add the color class by class.

305
00:19:09,000 --> 00:19:15,000
So just copy this from here and in the plotting.py just paste this over here.

306
00:19:15,000 --> 00:19:17,000
So you need to add colors class by class.

307
00:19:17,000 --> 00:19:18,000
Like first the green.

308
00:19:18,000 --> 00:19:21,000
There is a green label over here in the data dot.

309
00:19:22,000 --> 00:19:24,000
So first we will add the x color of the green.

310
00:19:25,000 --> 00:19:27,000
Then we have the yellow red color over here.

311
00:19:27,000 --> 00:19:31,000
So then we will add the hex form of the red.

312
00:19:32,000 --> 00:19:34,000
Or we have the red color over here.

313
00:19:34,000 --> 00:19:36,000
Then in last we have the yellow color.

314
00:19:36,000 --> 00:19:38,000
So we'll add the hex form of the yellow color in the last.

315
00:19:39,000 --> 00:19:39,000
Okay.

316
00:19:39,000 --> 00:19:42,000
So just save this and close this from here.

317
00:19:43,000 --> 00:19:43,000
Okay.

318
00:19:43,000 --> 00:19:46,000
So you don't need to make any further change.

319
00:19:46,000 --> 00:19:49,000
So just here we are doing the predictions.

320
00:19:49,000 --> 00:19:55,000
Or you can say that we are validating our model on the validation images.

321
00:19:55,000 --> 00:19:55,000
Okay.

322
00:19:56,000 --> 00:19:57,000
So.

323
00:19:58,000 --> 00:20:04,000
Here we are just varied, so I'm just running the validation.py script and we are taking the best weights

324
00:20:04,000 --> 00:20:11,000
and we are taking the validation sets of images and see how our model performs on those images.

325
00:20:11,000 --> 00:20:15,000
So here we will get the performance with respect to each of the class.

326
00:20:15,000 --> 00:20:22,000
So you can see that within the green class we have a mean average precision with 50 as 0.976.

327
00:20:22,000 --> 00:20:26,000
With the red class, we have a mean average precision with 50 as 0.988.

328
00:20:26,000 --> 00:20:32,000
And with the yellow class we have a mean average precision with 50 as 0.986.

329
00:20:32,000 --> 00:20:38,000
And we have also mean average precision when varies from 50 to 95 is also given over here.

330
00:20:39,000 --> 00:20:42,000
So you can see that the results are very impressive of our model.

331
00:20:42,000 --> 00:20:47,000
So now we will test our model on test data, set images, which is here.

332
00:20:47,000 --> 00:20:51,000
So we will evaluate our model on the test data, set images.

333
00:20:51,000 --> 00:20:53,000
So just copy path over here.

334
00:20:54,000 --> 00:20:57,000
And just paste this path over here and here.

335
00:20:57,000 --> 00:20:59,000
We have passed the best weights of our model.

336
00:20:59,000 --> 00:21:02,000
And here I'm just running the prediction.py script.

337
00:21:02,000 --> 00:21:08,000
So just run this cell now so it might take few moments to completely run.

338
00:21:08,000 --> 00:21:10,000
So it might take some time.

339
00:21:10,000 --> 00:21:10,000
So let's see.

340
00:21:10,000 --> 00:21:13,000
But it will not take very much time as we are using the GPU.

341
00:21:13,000 --> 00:21:18,000
So you can see that processing the image is very fast and we are done.

342
00:21:18,000 --> 00:21:21,000
Okay, so now our results are saved in.

343
00:21:21,000 --> 00:21:22,000
Let me go to.

344
00:21:25,000 --> 00:21:25,000
Okay.

345
00:21:25,000 --> 00:21:28,000
Our results are saved in YOLO V8.

346
00:21:29,000 --> 00:21:30,000
And detect.

347
00:21:31,000 --> 00:21:32,000
Runs.

348
00:21:33,000 --> 00:21:34,000
You tanked.

349
00:21:35,000 --> 00:21:37,000
And train 11.

350
00:21:37,000 --> 00:21:39,000
So here our output images are saved.

351
00:21:39,000 --> 00:21:41,000
So just copy this path.

352
00:21:42,000 --> 00:21:43,000
Okay.

353
00:21:43,000 --> 00:21:44,000
And just.

354
00:21:45,000 --> 00:21:47,000
Paste this part over here.

355
00:21:47,000 --> 00:21:47,000
Okay.

356
00:21:47,000 --> 00:21:53,000
And we just want to see the results of the top five images because we have 100 images and it will not

357
00:21:53,000 --> 00:21:56,000
be possible to display all the 100 output images over here.

358
00:21:56,000 --> 00:21:59,000
So just see the output on the first five images.

359
00:21:59,000 --> 00:22:03,000
You can see the output on the last five images from 5 to 10 images.

360
00:22:03,000 --> 00:22:09,000
So you can just set the sequence on which sort of images you want to see the output and just run this

361
00:22:09,000 --> 00:22:09,000
cell now.

362
00:22:13,000 --> 00:22:13,000
Okay.

363
00:22:13,000 --> 00:22:15,000
So here you can see that.

364
00:22:15,000 --> 00:22:16,000
And now if we.

365
00:22:17,000 --> 00:22:19,000
Okay, So you can see here we have the green light.

366
00:22:19,000 --> 00:22:22,000
So the moderator correctly that there is a green light.

367
00:22:22,000 --> 00:22:26,000
Plus you can see that we have the bounding box of the color green as well.

368
00:22:26,000 --> 00:22:27,000
Okay.

369
00:22:27,000 --> 00:22:30,000
So here you can see that we have a red light.

370
00:22:30,000 --> 00:22:34,000
So bounding box color is also red and the model detected as red.

371
00:22:34,000 --> 00:22:35,000
And here we also have a green light.

372
00:22:35,000 --> 00:22:38,000
So you can see that bounding box color is green.

373
00:22:38,000 --> 00:22:41,000
And the model directory bracket that this is a green light.

374
00:22:41,000 --> 00:22:44,000
In this case the there is a red light.

375
00:22:44,000 --> 00:22:46,000
So model detected correctly that there is a red light.

376
00:22:46,000 --> 00:22:51,000
In this case there was no yellow light, but in this case the model make the wrong prediction.

377
00:22:51,000 --> 00:22:58,000
But by on all other four images, the model made the right prediction and the as per the If there is

378
00:22:58,000 --> 00:23:02,000
a red color the of the light the bounding box color you can see is also red.

379
00:23:02,000 --> 00:23:06,000
Okay, so now we will test our model on some demo images.

380
00:23:06,000 --> 00:23:13,000
So I have placed this demo videos on my Google Drive, so I'm just downloading those images from that

381
00:23:13,000 --> 00:23:20,000
drive and just running the script on those images and see what results do we get on these images, on

382
00:23:20,000 --> 00:23:21,000
these videos.

383
00:23:21,000 --> 00:23:26,000
Okay, so I'm just downloading some demo videos from the drive and testing my model on those demo videos

384
00:23:26,000 --> 00:23:30,000
and seeing what results do we get on those demo videos?

385
00:23:31,000 --> 00:23:32,000
So it might take some time.

386
00:23:33,000 --> 00:23:33,000
Okay.

387
00:23:34,000 --> 00:23:41,000
And this model has run on the demo video and it has done the predictions frame by frame.

388
00:23:41,000 --> 00:23:41,000
Okay.

389
00:23:41,000 --> 00:23:43,000
The predictions are being done frame by frame.

390
00:23:43,000 --> 00:23:47,000
Please remember this, that all the predictions are done frame by frame.

391
00:23:48,000 --> 00:23:50,000
So this is important.

392
00:23:50,000 --> 00:23:56,000
We can see that the model has divided the video in out in 183 frames and it has processed each of the

393
00:23:56,000 --> 00:23:58,000
frames separately.

394
00:23:58,000 --> 00:24:02,000
So now we are just displaying our output demo video in the Google CoLab notebook.

395
00:24:02,000 --> 00:24:07,000
So it might take few seconds to display the demo output video over here.

396
00:24:07,000 --> 00:24:13,000
So let's see, we will have the demo output video over here very soon.

397
00:24:13,000 --> 00:24:15,000
It will not take very much time.

398
00:24:15,000 --> 00:24:16,000
Then we will see.

399
00:24:16,000 --> 00:24:18,000
What results do we get over here?

400
00:24:19,000 --> 00:24:23,000
We will also test our model on two other demo videos as well.

401
00:24:23,000 --> 00:24:25,000
So we will validate our model.

402
00:24:26,000 --> 00:24:27,000
Completely.

403
00:24:34,000 --> 00:24:37,000
Well, here is the output video, so let me download it first.

404
00:24:38,000 --> 00:24:40,000
So just click on download and.

405
00:24:40,000 --> 00:24:43,000
And let me open this video for you.

406
00:24:45,000 --> 00:24:46,000
Okay.

407
00:24:47,000 --> 00:24:50,000
So now you can see that video.

408
00:24:50,000 --> 00:24:52,000
So let me play it from start.

409
00:24:52,000 --> 00:24:57,000
So you can see over here in the start there was model was not able to detect correctly very perfectly.

410
00:24:57,000 --> 00:25:01,000
But later on it detects that the red light is on.

411
00:25:02,000 --> 00:25:08,000
Okay, so let's test our model on some other demo videos and see what results do we get on them.

412
00:25:08,000 --> 00:25:10,000
Okay, so this is the.

413
00:25:12,000 --> 00:25:14,000
Demo video to first download it from the drive.

414
00:25:14,000 --> 00:25:19,000
So I've just placed the videos on the drive so I can easily download into my Google CoLab notebook.

415
00:25:19,000 --> 00:25:22,000
Okay, so just run this cell.

416
00:25:22,000 --> 00:25:28,000
I've already placed the video to MP4 path over here, so just doing the prediction on the demo video

417
00:25:28,000 --> 00:25:29,000
too.

418
00:25:29,000 --> 00:25:32,000
So it might take a few seconds.

419
00:25:32,000 --> 00:25:33,000
So let's wait and see.

420
00:25:33,000 --> 00:25:35,000
What results do we get?

421
00:25:38,000 --> 00:25:44,000
So it has divided the whole video into 20 frames and it is doing the predictions frame by frame.

422
00:25:44,000 --> 00:25:47,000
So the prediction is done.

423
00:25:47,000 --> 00:25:49,000
Let's display the output demo video over here.

424
00:25:49,000 --> 00:25:54,000
Just change it to 13 and just run this cell now.

425
00:25:56,000 --> 00:26:00,000
So it might take a few seconds to display the demo output video here.

426
00:26:00,000 --> 00:26:06,000
So I'm just pausing the video and as we get the demo output video, I will resume this video and show

427
00:26:06,000 --> 00:26:08,000
you what the results do we get.

428
00:26:11,000 --> 00:26:11,000
Guys.

429
00:26:11,000 --> 00:26:15,000
The water has run on the demo video too, and here are the results.

430
00:26:15,000 --> 00:26:20,000
So let me download this video and show you what results do we got over here?

431
00:26:20,000 --> 00:26:25,000
So the video is downloading and let me open it and show you the results.

432
00:26:26,000 --> 00:26:27,000
Okay.

433
00:26:27,000 --> 00:26:27,000
So.

434
00:26:29,000 --> 00:26:34,000
So you can see here the model is able to detect correctly the red light over here.

435
00:26:34,000 --> 00:26:38,000
So the model is working fine, very good.

436
00:26:38,000 --> 00:26:43,000
And the model is giving very good results in this case on the demo video to it, as it detects correctly

437
00:26:43,000 --> 00:26:44,000
that there is a red light.

438
00:26:44,000 --> 00:26:47,000
Now test our model on the demo video three.

439
00:26:47,000 --> 00:26:49,000
So just click on yes over here.

440
00:26:49,000 --> 00:26:52,000
And I have placed the demo video three on the drive as well.

441
00:26:52,000 --> 00:26:57,000
So I will just download the video from the drive and just run this.

442
00:26:58,000 --> 00:27:03,000
Okay, so the video has been downloaded from the drive and let me test on the demo video three.

443
00:27:04,000 --> 00:27:06,000
Okay, so it might take few seconds.

444
00:27:06,000 --> 00:27:08,000
So let me pause the video.

445
00:27:08,000 --> 00:27:15,000
And as the video processing completes, like you can see here, the model has the okay, So the model

446
00:27:15,000 --> 00:27:22,000
has divided this complete video into 412 frames and it is processing each frame, each frame by frame.

447
00:27:22,000 --> 00:27:25,000
It is processing the complete video frame by frame.

448
00:27:25,000 --> 00:27:27,000
So as this processing completed.

449
00:27:27,000 --> 00:27:31,000
Let me get back and show you the output demo video.

450
00:27:33,000 --> 00:27:39,000
Well, the processing or the predictions on the demo video three has been completed and here you can

451
00:27:39,000 --> 00:27:44,000
see that the model has is able to detect the lights one red, two reds, one red.

452
00:27:44,000 --> 00:27:46,000
And now I'm trying to just play the demo video over here.

453
00:27:46,000 --> 00:27:51,000
So as the demo video is ready to display over here, I will show you the results.

454
00:27:51,000 --> 00:27:56,000
So just pausing the video until the demo output video is ready to display over here.

455
00:27:59,000 --> 00:28:06,000
I guess due to the large pie sign, the model was I was unable to display the output demo video over

456
00:28:06,000 --> 00:28:08,000
here into the Google CoLab notebook.

457
00:28:08,000 --> 00:28:14,000
So I've just downloaded the output demo video and let me show you the, uh, the results.

458
00:28:14,000 --> 00:28:15,000
Let me share my screen.

459
00:28:15,000 --> 00:28:16,000
Just give me a minute.

460
00:28:19,000 --> 00:28:20,000
Okay, So now you can see the results.

461
00:28:21,000 --> 00:28:26,000
So you can see that the model is able to detect correctly that the green light is there.

462
00:28:26,000 --> 00:28:32,000
Like you can see that we have a green bounding bounding box with a green color around the line.

463
00:28:32,000 --> 00:28:36,000
And now when there is a yellow color, the model was able to detect correctly.

464
00:28:37,000 --> 00:28:44,000
But you can see over here, like when the traffic light blinks to yellow, the model was able to detect

465
00:28:44,000 --> 00:28:50,000
correctly that the yellow signal is on and when the red signal is on, the model was also able to detect

466
00:28:50,000 --> 00:28:52,000
correctly that there is the red signal is on.

467
00:28:52,000 --> 00:28:55,000
So I hope you have learned a lot from this video.

468
00:28:55,000 --> 00:28:59,000
See you all in the next video tutorial with some new amazing projects.

469
00:29:00,000 --> 00:29:01,000
Till then, bye bye.

