1
00:00:02,000 --> 00:00:03,000
Hello everyone.

2
00:00:03,000 --> 00:00:10,000
In this video tutorial we will see how we can use YOLO V8 for license plate detection and recognition.

3
00:00:10,000 --> 00:00:16,000
So as you can see in this output demo video, we will not only detect the license plate, but we will

4
00:00:16,000 --> 00:00:19,000
also read the text on the license plate as well.

5
00:00:19,000 --> 00:00:24,000
So we will do the detection of the license plate, but also we will read the text of the license plate

6
00:00:24,000 --> 00:00:25,000
as well.

7
00:00:25,000 --> 00:00:32,000
So in this video tutorial we will see how we can detect the license plate using the V8 and also how

8
00:00:32,000 --> 00:00:40,000
we can read the text on the license plate using easy OCR so we can fine tune the YOLO V8 model for license

9
00:00:40,000 --> 00:00:41,000
plate detection.

10
00:00:41,000 --> 00:00:46,000
And then we will use OCR to read the text on the license plate.

11
00:00:46,000 --> 00:00:51,000
So this is a complete end to end tutorial, so don't skip any part of the video and do watch the complete

12
00:00:51,000 --> 00:00:52,000
video.

13
00:00:52,000 --> 00:00:54,000
So let's get started.

14
00:00:56,000 --> 00:01:03,000
So first of all, I will just go to the script file over here and I will explain you the complete code.

15
00:01:03,000 --> 00:01:08,000
So let me move move towards the script file and then we will proceed further and I will explain you

16
00:01:08,000 --> 00:01:10,000
the complete code step by step.

17
00:01:11,000 --> 00:01:11,000
Okay.

18
00:01:11,000 --> 00:01:18,000
So so here in front of you, you can see the CoLab notebook file, Google CoLab notebook file over here.

19
00:01:18,000 --> 00:01:23,000
So before running the script, please make sure that you have selected the runtime as GPU.

20
00:01:24,000 --> 00:01:24,000
Okay.

21
00:01:24,000 --> 00:01:29,000
And click on Save then for this project I will be using this license plate dataset.

22
00:01:29,000 --> 00:01:35,000
The dataset is publicly available in Roboflow, so I will share this dataset link with you as well.

23
00:01:35,000 --> 00:01:40,000
So you just need to create an account on roboflow and it's you can assess this dataset for free.

24
00:01:40,000 --> 00:01:43,000
You just don't need to pay anything to assess this dataset.

25
00:01:43,000 --> 00:01:46,000
So the dataset consist of about 300 images.

26
00:01:46,000 --> 00:01:48,000
We have the train validation and test images.

27
00:01:48,000 --> 00:01:51,000
The author of this dataset has applied augmentation.

28
00:01:51,000 --> 00:01:57,000
So after the data augmentation, the training set is of the images increased to 6 to 18 images.

29
00:01:57,000 --> 00:02:03,000
Now we have after applying augmentation that augmentation, we have 618 images in the training set,

30
00:02:03,000 --> 00:02:08,000
64 images in the validation set and 30 images the test set.

31
00:02:08,000 --> 00:02:08,000
Okay.

32
00:02:08,000 --> 00:02:12,000
So if we go to the health check as well, we can see that.

33
00:02:13,000 --> 00:02:18,000
So it here we don't have the issue of class balance because if we have multi classes, then we check

34
00:02:18,000 --> 00:02:20,000
whether the class is balanced or not.

35
00:02:20,000 --> 00:02:22,000
So here we don't have such issue.

36
00:02:22,000 --> 00:02:29,000
So we will export this dataset from Roboflow into our Google CoLab notebook to export the dataset,

37
00:02:29,000 --> 00:02:33,000
click on, download the dataset, and then select the model model.

38
00:02:33,000 --> 00:02:39,000
So as YOLO, V5 and YOLO V8, both were released by Ultralytics so we can select any of the model format

39
00:02:39,000 --> 00:02:47,000
here for implementing YOLO V8 to train the YOLO V8 or fine tune the V8 model on display dataset, then

40
00:02:47,000 --> 00:02:53,000
export the dataset in any format like you can select the V5 PyTorch format or YOLO V8 format.

41
00:02:53,000 --> 00:02:57,000
So I'll select the Yolov5 PyTorch format and click on Continue.

42
00:02:58,000 --> 00:03:04,000
Then in the next step, I will just copy this, all this code from here and paste into the Google CoLab

43
00:03:04,000 --> 00:03:04,000
notebook.

44
00:03:04,000 --> 00:03:12,000
But if you are doing in any other like I mean, if you are doing in PyCharm or if you are doing in Anaconda

45
00:03:12,000 --> 00:03:17,000
Navigator or if you are doing in or doing in Visual Studio, then you just need to copy this terminal

46
00:03:17,000 --> 00:03:17,000
command.

47
00:03:17,000 --> 00:03:23,000
But if you are doing in the Google CoLab notebook or Jupyter Notebook, just copy this from here and

48
00:03:23,000 --> 00:03:25,000
paste it in the Google CoLab notebook.

49
00:03:25,000 --> 00:03:27,000
So let's move towards the code part.

50
00:03:27,000 --> 00:03:34,000
So first of all, I will download the license plate automatic number, plate detection recognition required

51
00:03:34,000 --> 00:03:37,000
files from the Google Drive into my Google CoLab notebook.

52
00:03:37,000 --> 00:03:39,000
So these are the eight required files.

53
00:03:39,000 --> 00:03:45,000
It contain the plots, files or the V8 Pre-trained model files and the Ultralytics YOLO V8 required

54
00:03:45,000 --> 00:03:46,000
files over here.

55
00:03:46,000 --> 00:03:50,000
So you can see over here we have all these files currently using the zip format.

56
00:03:50,000 --> 00:03:56,000
So I will unzip all this file by just running this cell so it will unzip all the files and you can see

57
00:03:56,000 --> 00:03:59,000
over here we have all the files in the unzipped format.

58
00:03:59,000 --> 00:04:02,000
So it contains the file requirements file.

59
00:04:03,000 --> 00:04:03,000
Okay.

60
00:04:03,000 --> 00:04:08,000
So now I will import this required library from ipython dot display import in which.

61
00:04:08,000 --> 00:04:10,000
So why we need this libraries.

62
00:04:10,000 --> 00:04:14,000
If you want to display any input or output image into the Google colab notebook, then we need this

63
00:04:14,000 --> 00:04:16,000
import image library over here.

64
00:04:17,000 --> 00:04:17,000
Okay.

65
00:04:17,000 --> 00:04:19,000
So I have unzipped this folder.

66
00:04:19,000 --> 00:04:22,000
Now I need to set this folder as my current directory.

67
00:04:22,000 --> 00:04:24,000
So I'm just setting this folder as my current directory.

68
00:04:24,000 --> 00:04:30,000
Now in the next step I will install all the dependencies or you can say the requirements so it will

69
00:04:30,000 --> 00:04:34,000
install all the required libraries that are required to run this project successfully.

70
00:04:34,000 --> 00:04:39,000
If you don't install the dependencies, then when you run the training validation or the prediction

71
00:04:39,000 --> 00:04:44,000
step, then you will face the error that the following library is not installed or the Hydra library

72
00:04:44,000 --> 00:04:45,000
is not installed.

73
00:04:45,000 --> 00:04:47,000
Seaborn library is not installed.

74
00:04:47,000 --> 00:04:48,000
Matplotlib library is not installed.

75
00:04:48,000 --> 00:04:52,000
So it is important to install all the required libraries.

76
00:04:53,000 --> 00:04:56,000
So to install all the required libraries you just need to run the.

77
00:04:57,000 --> 00:05:03,000
A setup.py file, so it will install all the required libraries that are required to run this project.

78
00:05:03,000 --> 00:05:07,000
Some libraries are by default installed in the Google CoLab, but which are not installed.

79
00:05:07,000 --> 00:05:13,000
You can see here these are being installed, so if you miss this step, you can then you will face this

80
00:05:13,000 --> 00:05:16,000
error that the following library is not installed when you run the training script.

81
00:05:16,000 --> 00:05:17,000
So you need to install.

82
00:05:17,000 --> 00:05:19,000
Then you will need to install all the required libraries.

83
00:05:19,000 --> 00:05:25,000
So it's always better to run this step and install all the required libraries before running the script.

84
00:05:26,000 --> 00:05:34,000
Okay, so all the required libraries are being installed, so the dependencies are being installed.

85
00:05:34,000 --> 00:05:39,000
So now as we are doing detection over here, so I will go to Ultralytics, YOLO V8.

86
00:05:39,000 --> 00:05:45,000
So as we are doing detection, so we will go towards this folder and select set this folder as my current

87
00:05:45,000 --> 00:05:52,000
directory because it contains the training validation and prediction script and I am using as I, I'm

88
00:05:52,000 --> 00:05:53,000
doing detection over here.

89
00:05:53,000 --> 00:05:57,000
So I will just go to the detect folder which contains all my required scripts.

90
00:05:58,000 --> 00:05:58,000
Okay.

91
00:05:58,000 --> 00:06:01,000
So I will just check this folder as my current directory.

92
00:06:01,000 --> 00:06:07,000
So now I'm just exporting this dataset from roboflow the CoLab notebook.

93
00:06:07,000 --> 00:06:11,000
So just need to go here, click on copy and just paste this over here.

94
00:06:12,000 --> 00:06:12,000
Okay.

95
00:06:12,000 --> 00:06:18,000
And just if you run this, it will install the dataset or it will import the dataset from Roboflow into

96
00:06:18,000 --> 00:06:20,000
your Google CoLab notebook.

97
00:06:20,000 --> 00:06:24,000
So the dataset will be downloaded in this detect folder.

98
00:06:24,000 --> 00:06:29,000
The dataset will be downloaded in zip format, but it will automatically be unzipped when you just run

99
00:06:29,000 --> 00:06:30,000
this cell.

100
00:06:30,000 --> 00:06:31,000
So might take few seconds.

101
00:06:32,000 --> 00:06:38,000
So now you can see that the data set is being downloaded in the zip format, but it will be automatically

102
00:06:38,000 --> 00:06:39,000
unzipped here as well.

103
00:06:39,000 --> 00:06:41,000
So this might take few seconds.

104
00:06:41,000 --> 00:06:42,000
So let's see.

105
00:06:42,000 --> 00:06:45,000
As it completes, we will then proceed further.

106
00:06:45,000 --> 00:06:48,000
Okay, so dataset is downloaded in the zip format.

107
00:06:48,000 --> 00:06:54,000
So it will now automatically unzip over here and we will see this folder over here in the detect folder.

108
00:06:54,000 --> 00:06:57,000
So you can see the car license plate dataset over here.

109
00:06:57,000 --> 00:06:59,000
It's almost done.

110
00:06:59,000 --> 00:07:01,000
We have the train test validation folder.

111
00:07:01,000 --> 00:07:04,000
Each folder contain the images as well as the label.

112
00:07:04,000 --> 00:07:08,000
And then we have a data dot file which contains the class name.

113
00:07:08,000 --> 00:07:13,000
We have only one class, which is license, and here we have the train validation test, which is path,

114
00:07:13,000 --> 00:07:15,000
and this is the link of the dataset.

115
00:07:15,000 --> 00:07:18,000
So if you open this link, the dataset will open.

116
00:07:18,000 --> 00:07:19,000
Okay.

117
00:07:21,000 --> 00:07:27,000
Okay, so it's about to download the dataset and then we will go towards the training and then we will

118
00:07:27,000 --> 00:07:31,000
train our model on this dataset.

119
00:07:31,000 --> 00:07:33,000
So this might take few more seconds.

120
00:07:33,000 --> 00:07:34,000
So I'm just waiting.

121
00:07:34,000 --> 00:07:37,000
So as it gets completes, then I will proceed further.

122
00:07:38,000 --> 00:07:39,000
Okay.

123
00:07:39,000 --> 00:07:41,000
So it's about to download, so.

124
00:07:43,000 --> 00:07:45,000
So let me set the.

125
00:07:45,000 --> 00:07:48,000
Okay, so just run these cells as well.

126
00:07:49,000 --> 00:07:50,000
Okay.

127
00:07:53,000 --> 00:07:57,000
So now basically we need to in the next step, the dataset is downloaded.

128
00:07:57,000 --> 00:08:04,000
Now we need to train our model on this dataset, which is called a sense two dataset over here.

129
00:08:04,000 --> 00:08:08,000
So this is the Python Train.py script and we are using the V8 model.

130
00:08:08,000 --> 00:08:11,000
So there are five different V8 model.

131
00:08:11,000 --> 00:08:16,000
So the V8 end is the smallest, but it is less accurate and it is fast, although.

132
00:08:16,000 --> 00:08:21,000
But YOLO v8 X is the more most accurate and it is less fast.

133
00:08:21,000 --> 00:08:24,000
So we are using a V8 medium model.

134
00:08:24,000 --> 00:08:24,000
Okay.

135
00:08:24,000 --> 00:08:29,000
And we are setting the default image size because if we change the image size then we might compromise

136
00:08:29,000 --> 00:08:32,000
on accuracy and we are training our V8 model.

137
00:08:32,000 --> 00:08:38,000
Or you can say we are fine tuning the YOLO V8 model on license plate dataset and we are training the

138
00:08:39,000 --> 00:08:43,000
YOLO V8 model on license plate dataset for 120 epochs.

139
00:08:43,000 --> 00:08:49,000
Okay, so let's get started and let's train the V8 model on the license plate dataset.

140
00:08:49,000 --> 00:08:51,000
So it's about to start over here.

141
00:08:53,000 --> 00:08:57,000
First of all, it will download the model from official repository.

142
00:08:57,000 --> 00:09:01,000
It's downloading currently, so it might take some time.

143
00:09:01,000 --> 00:09:01,000
Okay.

144
00:09:01,000 --> 00:09:06,000
Then in the next step the training will start and the training will proceed a step by step.

145
00:09:06,000 --> 00:09:12,000
It will first work for one epoch and then for the second epoch.

146
00:09:12,000 --> 00:09:15,000
The training will take around a around two hours.

147
00:09:15,000 --> 00:09:19,000
So as the training start, I will pause the video and when the training completes, I will be back and

148
00:09:19,000 --> 00:09:21,000
I will explain you the rest of the code.

149
00:09:21,000 --> 00:09:23,000
So the training has started.

150
00:09:23,000 --> 00:09:24,000
It will take time.

151
00:09:24,000 --> 00:09:28,000
So I'm going to pause the video and as the training completes, I will be back.

152
00:09:31,000 --> 00:09:37,000
So guys, the training of the Yolo v eight model on the license plate dataset is completed and here

153
00:09:37,000 --> 00:09:38,000
are the results.

154
00:09:38,000 --> 00:09:44,000
We have trained our model on 120 epochs, which explained a year and we have selected the image size

155
00:09:44,000 --> 00:09:46,000
as 640 as YOLO.

156
00:09:46,000 --> 00:09:53,000
V eight model is officially trained on the image size of 640 by 640, so it's always better to set the

157
00:09:53,000 --> 00:09:58,000
image size as 640 when you fine tune your YOLO V8 model on any custom data set.

158
00:09:58,000 --> 00:10:04,000
So here we are fine tuning our YOLO V8 model on the license plate data set, and we have trained the

159
00:10:04,000 --> 00:10:07,000
YOLO V8 model on the license plate data set.

160
00:10:07,000 --> 00:10:08,000
And here are the results.

161
00:10:08,000 --> 00:10:15,000
We have trained our V8 model on 120 epochs and the mean average precision which we obtained is zero

162
00:10:15,000 --> 00:10:18,000
point with mean average precision.

163
00:10:18,000 --> 00:10:30,000
With IOU, 50 is 0.916, which is 91.6% and mean average precision when varies from 50 to 95 is 0.564,

164
00:10:30,000 --> 00:10:32,000
which is 56.4%.

165
00:10:32,000 --> 00:10:36,000
So the mean average precision is fine and the weights are saved.

166
00:10:36,000 --> 00:10:42,000
Over here, if you go to runs, detect, train and here we can see the weights file.

167
00:10:42,000 --> 00:10:44,000
Here we have the best and last weights.

168
00:10:44,000 --> 00:10:49,000
So the best.is updates file on which our model gives us the best results.

169
00:10:49,000 --> 00:10:55,000
And the last output is the weights file on the last epoch on the 1/20 epoch.

170
00:10:55,000 --> 00:11:02,000
So we will use best dot weights file for further validation of our trained YOLO V8 less model on the

171
00:11:02,000 --> 00:11:03,000
license plate dataset.

172
00:11:03,000 --> 00:11:05,000
So here is the model summary.

173
00:11:05,000 --> 00:11:12,000
The mean average precision of the 92.6% with 50 is obtained and mean average precision.

174
00:11:12,000 --> 00:11:17,000
When IOU varies from 50 to 95 is 57.6%.

175
00:11:17,000 --> 00:11:18,000
So the results are what?

176
00:11:19,000 --> 00:11:25,000
So all our after training, all the confusion matrix validation predictions, training, batch predictions,

177
00:11:25,000 --> 00:11:30,000
precision recall curve, F1 curves are saved in this folder.

178
00:11:30,000 --> 00:11:33,000
The train folder where you can see all these files.

179
00:11:33,000 --> 00:11:38,000
So let me check all these files in that train folder and display all these files in the Google CoLab

180
00:11:38,000 --> 00:11:39,000
notebook.

181
00:11:39,000 --> 00:11:45,000
So just if you click over here so it will display all the files which we have in the train folder.

182
00:11:45,000 --> 00:11:50,000
We have the confusion matrix, we have the F1 curve, we have the precision recall curve, we have the

183
00:11:50,000 --> 00:11:52,000
AACR, we have the results dot CSV file.

184
00:11:52,000 --> 00:11:59,000
So if I show you the result dot csv file, it contains the model evaluation or the model performance

185
00:11:59,000 --> 00:12:01,000
evaluation on each epoch after each epoch.

186
00:12:01,000 --> 00:12:05,000
So you can say after zero first, two, three, nine.

187
00:12:05,000 --> 00:12:09,000
So if you go over here, we have ten pages of this CSV file.

188
00:12:09,000 --> 00:12:16,000
So if I go to the last page, we have the on the last epoch 119 epoch, we have the box loss, the loss

189
00:12:16,000 --> 00:12:19,000
DF loss, precision recall.

190
00:12:19,000 --> 00:12:25,000
So we have all these values mean average precision with 50 to 95 mean average precision with 50.

191
00:12:25,000 --> 00:12:33,000
So we have all these basically in the CSV, we on the model performance after each epoch is saved.

192
00:12:33,000 --> 00:12:37,000
Okay, the results dot csv, the model performance after each epoch is saved.

193
00:12:37,000 --> 00:12:40,000
And then we have the confusion matrix over here.

194
00:12:41,000 --> 00:12:46,000
I have just displayed this confusion matrix over here into the Google CoLab notebook over here.

195
00:12:46,000 --> 00:12:52,000
So Confusion Matrix basically tells us how or how our model handles different classes.

196
00:12:52,000 --> 00:12:55,000
So in this case, we have only one class, which is lessons.

197
00:12:55,000 --> 00:13:02,000
So we can see that 84% of the time our model detected correctly that there is a lesson split, while

198
00:13:02,000 --> 00:13:08,000
16% of the times when there was a lesson played, our model was unable to identify it.

199
00:13:08,000 --> 00:13:14,000
So 84% of times our model was trained YOLO model detected correctly that there is a license plate,

200
00:13:14,000 --> 00:13:21,000
while 16% of the time when the license plate was there, our model was unable to detect it.

201
00:13:22,000 --> 00:13:28,000
So here we have the results dot PNG, which can you can see over here I've just displayed in the Google

202
00:13:28,000 --> 00:13:34,000
CoLab notebook so you can see that the Los loss box logs are decreasing, okay?

203
00:13:34,000 --> 00:13:37,000
They are decreasing and the mean average precision is on the rise.

204
00:13:37,000 --> 00:13:44,000
Mean average precision of 50 mean average precision when the varies from 50 to 95 is on the rise.

205
00:13:44,000 --> 00:13:50,000
So it means that if we train our model on 250 or 300 epochs, the mean average precision will further

206
00:13:50,000 --> 00:13:51,000
improve.

207
00:13:51,000 --> 00:13:55,000
Okay, so here I have the model prediction on the validation batch.

208
00:13:57,000 --> 00:14:02,000
So, uh, so basically these are the model predictions on the validation batch images.

209
00:14:02,000 --> 00:14:08,000
So these images are not used for the training, So it's always better to have a look and see how our

210
00:14:08,000 --> 00:14:11,000
model performs on the validation dataset, batch images.

211
00:14:11,000 --> 00:14:12,000
Okay.

212
00:14:12,000 --> 00:14:16,000
So here are some output examples from the validation batch images.

213
00:14:16,000 --> 00:14:21,000
So you can see that our model is able to detect successfully when there is a number plate and the confidence

214
00:14:21,000 --> 00:14:22,000
is very good as well.

215
00:14:22,000 --> 00:14:26,000
The confidence is most cases is above 0.9 and 0.8.

216
00:14:26,000 --> 00:14:27,000
Okay.

217
00:14:27,000 --> 00:14:32,000
So I have just added this section to just to save your projects into the Google Drive.

218
00:14:32,000 --> 00:14:35,000
And if you want to run this script after some time.

219
00:14:35,000 --> 00:14:39,000
So instead of training the model again, you can directly download the weights from the Google Drive

220
00:14:39,000 --> 00:14:40,000
and test your model.

221
00:14:40,000 --> 00:14:45,000
So I will just place my weights into the Google Drive and I have added the link over here.

222
00:14:45,000 --> 00:14:50,000
So if you want to test this, run the script on my weights, which are this batch stopped.

223
00:14:50,000 --> 00:14:56,000
So you can just download those weights by just running this cell and you can just test the model on

224
00:14:56,000 --> 00:14:56,000
this weights.

225
00:14:56,000 --> 00:14:57,000
Okay.

226
00:14:58,000 --> 00:15:01,000
So I'm just validating the custom model over here.

227
00:15:01,000 --> 00:15:06,000
So on the validation batch images, so on the test batch images, sorry.

228
00:15:06,000 --> 00:15:09,000
So basically these images are not used for the training.

229
00:15:09,000 --> 00:15:09,000
Okay.

230
00:15:09,000 --> 00:15:14,000
So it's always better to have a look and see how our results look like.

231
00:15:14,000 --> 00:15:17,000
So here we are validating our model on the validation batch images.

232
00:15:17,000 --> 00:15:20,000
So here are the validation batch basis.

233
00:15:20,000 --> 00:15:23,000
And on these images we are validating our model.

234
00:15:23,000 --> 00:15:28,000
Okay, so we are not using these images for that training and it's always better to see how our model

235
00:15:28,000 --> 00:15:30,000
performs on these images.

236
00:15:30,000 --> 00:15:30,000
Okay.

237
00:15:30,000 --> 00:15:34,000
So now what we have done is that we have.

238
00:15:36,000 --> 00:15:36,000
Okay.

239
00:15:36,000 --> 00:15:37,000
Let me first.

240
00:15:37,000 --> 00:15:38,000
So.

241
00:15:39,000 --> 00:15:40,000
That.

242
00:15:40,000 --> 00:15:40,000
Give me a minute.

243
00:15:40,000 --> 00:15:44,000
So here I'm just installing PIP install easy OCR.

244
00:15:44,000 --> 00:15:50,000
I'm using PIP install OCR because currently we have detected that there is a license plate like you

245
00:15:50,000 --> 00:15:55,000
can see that we have detected that this is a license plate, but we need to read the read the text inside

246
00:15:55,000 --> 00:15:56,000
the number plate.

247
00:15:56,000 --> 00:15:57,000
Okay.

248
00:15:57,000 --> 00:15:57,000
License plate.

249
00:15:57,000 --> 00:15:58,000
Okay.

250
00:15:58,000 --> 00:16:03,000
Basically we, we want to read the number plate like we want to read WOR516.

251
00:16:03,000 --> 00:16:03,000
Okay.

252
00:16:03,000 --> 00:16:10,000
So to read the text inside the number plate or the text inside the bounding box, which is over here.

253
00:16:10,000 --> 00:16:13,000
So to read the text of the license plate.

254
00:16:13,000 --> 00:16:17,000
Okay, so we use easy OCR to read the text inside the number plate.

255
00:16:18,000 --> 00:16:19,000
There are also other methods as well.

256
00:16:19,000 --> 00:16:26,000
You can use Tesseract OCR as well, but easy OCR gives best results, so we will use easy OCR to read

257
00:16:26,000 --> 00:16:29,000
the text of the number plate or of the license plate.

258
00:16:29,000 --> 00:16:29,000
Okay.

259
00:16:29,000 --> 00:16:33,000
As you can see that this project is license plate detection and recognition.

260
00:16:33,000 --> 00:16:38,000
So we need to detect the license plate and read the text of the license plate as well.

261
00:16:38,000 --> 00:16:41,000
So to read the text I will use first PIP install OCR.

262
00:16:43,000 --> 00:16:45,000
Okay, so it's already installed.

263
00:16:45,000 --> 00:16:46,000
I've run this.

264
00:16:46,000 --> 00:16:51,000
Okay, so here I'm just downloading a demo video in which I want to test my train model on the license

265
00:16:51,000 --> 00:16:55,000
plate dataset and here I have the predict.py script.

266
00:16:55,000 --> 00:16:57,000
So just run this script.

267
00:16:58,000 --> 00:17:00,000
So it might take a few seconds for the execution.

268
00:17:02,000 --> 00:17:05,000
Okay, so let's get started.

269
00:17:05,000 --> 00:17:09,000
So it's about to start and we have the best weights file over here.

270
00:17:09,000 --> 00:17:14,000
We are using the best weights file over here so you can see that the model is able to detect correctly

271
00:17:14,000 --> 00:17:17,000
the license plate, which you can see over here in each frame.

272
00:17:17,000 --> 00:17:23,000
The model is able to detect correctly that there is a license plate and the model has divided the whole

273
00:17:23,000 --> 00:17:28,000
video into 631 frames and currently it's on six 373 frames.

274
00:17:28,000 --> 00:17:34,000
So in this in this when we run this script, predict dot pi script, I'm basically detecting only the

275
00:17:34,000 --> 00:17:35,000
license plate.

276
00:17:35,000 --> 00:17:37,000
I'm not reading the text on the license plate.

277
00:17:37,000 --> 00:17:37,000
Okay.

278
00:17:38,000 --> 00:17:41,000
To read the text on the license plate we will do in the next phase.

279
00:17:41,000 --> 00:17:44,000
So currently I am only detecting the license plate.

280
00:17:44,000 --> 00:17:44,000
Okay.

281
00:17:44,000 --> 00:17:47,000
So here I will just display this demo video over here.

282
00:17:47,000 --> 00:17:52,000
So I have already staged this demo video over here if I run this script again.

283
00:17:52,000 --> 00:17:53,000
So it will take some time.

284
00:17:53,000 --> 00:17:58,000
So let me download this video and see is our model is able to detect the license plate or not.

285
00:17:58,000 --> 00:18:03,000
So just let me play this video and just navigate my screen towards this video.

286
00:18:03,000 --> 00:18:04,000
Okay.

287
00:18:04,000 --> 00:18:06,000
So now you can see the output video.

288
00:18:06,000 --> 00:18:10,000
So you can see that the model is able to check correctly that there is a license plate.

289
00:18:10,000 --> 00:18:15,000
Like, okay, you can see the bounding box and the model is able to read correctly that there is a license

290
00:18:15,000 --> 00:18:15,000
plate.

291
00:18:15,000 --> 00:18:18,000
So in this case, the model is giving us good result.

292
00:18:18,000 --> 00:18:22,000
But our main target is to read the text inside the license plate.

293
00:18:22,000 --> 00:18:25,000
Our main target is to read the text on the license plate.

294
00:18:25,000 --> 00:18:29,000
So let's move towards this and see how we can do this.

295
00:18:30,000 --> 00:18:37,000
So for this I will download the updated predict.py file which I have incorporated the code so I will

296
00:18:37,000 --> 00:18:40,000
download the updated predict.py file from the drive.

297
00:18:40,000 --> 00:18:42,000
So if I click over here.

298
00:18:42,000 --> 00:18:45,000
So this is the updated predict.py file.

299
00:18:47,000 --> 00:18:47,000
Okay.

300
00:18:47,000 --> 00:18:49,000
So if you want to.

301
00:18:49,000 --> 00:18:53,000
Okay, so just let me this line present result over here.

302
00:18:53,000 --> 00:18:54,000
Okay.

303
00:18:55,000 --> 00:18:57,000
You just click on Save now.

304
00:18:57,000 --> 00:19:02,000
Okay, so here you can see that we have created a function by the name of OCR image, and here we are

305
00:19:02,000 --> 00:19:08,000
initializing the OCR and we want to read the text in English, which is and we are using the GPU is

306
00:19:08,000 --> 00:19:14,000
equal to two because we are using GPU and easy OCR reader in means because we are reading the text which

307
00:19:14,000 --> 00:19:15,000
is in English.

308
00:19:15,000 --> 00:19:15,000
Okay.

309
00:19:15,000 --> 00:19:18,000
And here I've created a function OCR image.

310
00:19:18,000 --> 00:19:22,000
Okay, so here we are just choosing the coordinates of the bounding box.

311
00:19:22,000 --> 00:19:27,000
So if let me just open the paint and show you what we are basically doing over here.

312
00:19:30,000 --> 00:19:33,000
Okay, so just let me navigate my screen screen towards the pin.

313
00:19:33,000 --> 00:19:36,000
So if you go over here.

314
00:19:36,000 --> 00:19:41,000
Okay, so if, for example, this is my bounding box, okay, this is the bounding box.

315
00:19:41,000 --> 00:19:41,000
Okay?

316
00:19:41,000 --> 00:19:47,000
So in the bounding box, you these are my X1Y1 coordinates.

317
00:19:47,000 --> 00:19:52,000
These represent the X1Y1 coordinates, and these represent the X2Y2 coordinates.

318
00:19:52,000 --> 00:19:55,000
Okay, So in a bounding box, we have total four points.

319
00:19:55,000 --> 00:19:59,000
One is x, 1Y1, and this is the X2Y2 coordinates.

320
00:19:59,000 --> 00:19:59,000
Okay.

321
00:19:59,000 --> 00:20:05,000
So using these coordinates, we will update our code to read the text.

322
00:20:05,000 --> 00:20:06,000
Okay.

323
00:20:06,000 --> 00:20:08,000
So you can say that x over here.

324
00:20:09,000 --> 00:20:10,000
Let's write me over here.

325
00:20:11,000 --> 00:20:11,000
Okay.

326
00:20:11,000 --> 00:20:13,000
X here represents the x one.

327
00:20:14,000 --> 00:20:15,000
Okay.

328
00:20:15,000 --> 00:20:21,000
So just if I write arrow over here and y over here represents the Y one over here.

329
00:20:21,000 --> 00:20:26,000
So Y represents the Y one and W represents the x two over here.

330
00:20:26,000 --> 00:20:27,000
Okay.

331
00:20:27,000 --> 00:20:30,000
And x represents the y two over here.

332
00:20:30,000 --> 00:20:32,000
Okay, so this is how we have done.

333
00:20:32,000 --> 00:20:37,000
So these are the X1Y1 coordinates and this is the x2 and Y2 coordinates.

334
00:20:37,000 --> 00:20:42,000
Okay, so now what we are doing over here is that if you can see over here.

335
00:20:43,000 --> 00:20:45,000
If I go over here.

336
00:20:45,000 --> 00:20:50,000
Okay, So now from this complete view, reframe Now if you see over here, this is the complete frame.

337
00:20:50,000 --> 00:20:53,000
I'm just selecting the area where we have the bounding box.

338
00:20:53,000 --> 00:20:54,000
Okay?

339
00:20:54,000 --> 00:20:56,000
So if I explain this to you.

340
00:20:57,000 --> 00:21:00,000
Okay, So, okay, just let me go over here.

341
00:21:00,000 --> 00:21:02,000
So now you can see the video.

342
00:21:02,000 --> 00:21:05,000
So from this complete frame, this is the complete frame.

343
00:21:05,000 --> 00:21:08,000
I'm just selecting the area where I have the this bounding box.

344
00:21:08,000 --> 00:21:08,000
Okay.

345
00:21:08,000 --> 00:21:12,000
So I'm just selecting the area where I have this bounding box.

346
00:21:12,000 --> 00:21:12,000
Okay.

347
00:21:12,000 --> 00:21:13,000
Over here.

348
00:21:13,000 --> 00:21:19,000
So in this point, I'm just selecting the area where I have the bounding box where I have the license

349
00:21:19,000 --> 00:21:20,000
plate detected.

350
00:21:20,000 --> 00:21:20,000
Okay.

351
00:21:20,000 --> 00:21:23,000
Then I am converting this area into grayscale.

352
00:21:23,000 --> 00:21:29,000
Okay, so here I'm just converting this a area where I have the bounding box into grayscale and then

353
00:21:29,000 --> 00:21:31,000
I'm using easy OCR.

354
00:21:31,000 --> 00:21:36,000
I am just reading the text in the bounding box using easy OCR.

355
00:21:36,000 --> 00:21:39,000
I am just reading the text in this grayscale image of the bounding box.

356
00:21:39,000 --> 00:21:41,000
Okay, so.

357
00:21:42,000 --> 00:21:49,000
What I am doing is using first have only detected this area where I have this license plate.

358
00:21:49,000 --> 00:21:54,000
Then I have converted this area into grayscale and then I'm reading the text over here.

359
00:21:54,000 --> 00:21:56,000
What I have the text over here.

360
00:21:56,000 --> 00:22:01,000
You can see I'm just reading this text now using OCR, which I have inside this bounding box.

361
00:22:01,000 --> 00:22:02,000
Okay.

362
00:22:02,000 --> 00:22:08,000
So if I go back over here, so I'm just reading the text inside the bounding box which I have over here,

363
00:22:08,000 --> 00:22:09,000
which is over.

364
00:22:09,000 --> 00:22:12,000
You can see that n six, five, six is the text.

365
00:22:12,000 --> 00:22:13,000
Okay, so.

366
00:22:15,000 --> 00:22:19,000
Now, next up, what I'm doing is that I have already run this script so you can see that I have this

367
00:22:19,000 --> 00:22:20,000
printed.

368
00:22:20,000 --> 00:22:20,000
The result over here.

369
00:22:20,000 --> 00:22:22,000
These are the print results.

370
00:22:22,000 --> 00:22:22,000
Okay.

371
00:22:22,000 --> 00:22:26,000
I have already done this script before, so these are the print results.

372
00:22:26,000 --> 00:22:31,000
Okay, so what I'm doing is that you can see that, uh, this is the result.

373
00:22:31,000 --> 00:22:31,000
Okay.

374
00:22:31,000 --> 00:22:33,000
I have printed the result over here.

375
00:22:33,000 --> 00:22:35,000
This is the result after each of the frame.

376
00:22:35,000 --> 00:22:41,000
Okay, So what I'm doing is that so you can see that here I have the list over here.

377
00:22:42,000 --> 00:22:46,000
So if you can see over here, let me just a bit more.

378
00:22:46,000 --> 00:22:48,000
Let me just move it a bit more.

379
00:22:48,000 --> 00:22:48,000
Okay.

380
00:22:48,000 --> 00:22:50,000
So you can see that here.

381
00:22:50,000 --> 00:22:51,000
I have a complete list over here.

382
00:22:51,000 --> 00:22:52,000
Okay.

383
00:22:52,000 --> 00:22:57,000
So in the list, if we see over here, this represents the sub part of the list.

384
00:22:57,000 --> 00:22:57,000
Okay.

385
00:22:57,000 --> 00:23:02,000
So this is one this is the first element of the list, like zero element.

386
00:23:02,000 --> 00:23:04,000
This is the one element and this is the two element.

387
00:23:04,000 --> 00:23:09,000
So this is basically the confidence and this is basically the zero element of the list.

388
00:23:09,000 --> 00:23:09,000
Okay?

389
00:23:09,000 --> 00:23:10,000
This is the zero element.

390
00:23:10,000 --> 00:23:14,000
This is the first element and this is the second element.

391
00:23:14,000 --> 00:23:14,000
Okay.

392
00:23:14,000 --> 00:23:19,000
So I am just going this basically in result we have the list result contains the list.

393
00:23:19,000 --> 00:23:25,000
So I am just going through each, uh, each, each element in the list one by one.

394
00:23:25,000 --> 00:23:25,000
Okay.

395
00:23:25,000 --> 00:23:30,000
So if I'm saying that if the length of the, uh, this result is equal to one.

396
00:23:30,000 --> 00:23:35,000
Okay, but you can see here the length of the this result list is equal to three because this is the

397
00:23:35,000 --> 00:23:36,000
first element of the list.

398
00:23:36,000 --> 00:23:41,000
If we copy this over here, this is the second element of the list, and this is the third element of

399
00:23:41,000 --> 00:23:41,000
the list.

400
00:23:41,000 --> 00:23:46,000
But in that case, if the length of the list is one, then we will read the text in this.

401
00:23:46,000 --> 00:23:47,000
Okay.

402
00:23:47,000 --> 00:23:50,000
This is our basically we want to read this text of the list.

403
00:23:50,000 --> 00:23:51,000
Okay.

404
00:23:51,000 --> 00:23:56,000
But if the length of the result list is greater than one, so currently this length is equal to three

405
00:23:56,000 --> 00:23:57,000
or.

406
00:23:58,000 --> 00:24:00,000
And plus and and length of the result.

407
00:24:00,000 --> 00:24:03,000
One like this is a length of this text is greater than six.

408
00:24:03,000 --> 00:24:08,000
But here you can see that length is equal to four and and the confidence is greater than two.

409
00:24:08,000 --> 00:24:14,000
Then we want to display this text over here, so only we want to display that number plate text we want

410
00:24:14,000 --> 00:24:15,000
don't want this coordinates.

411
00:24:15,000 --> 00:24:20,000
So here we have this coordinates over here, but we don't want this coordinates.

412
00:24:20,000 --> 00:24:24,000
We only want to display that text on the number plate.

413
00:24:24,000 --> 00:24:27,000
We have basically what these coordinates represents.

414
00:24:27,000 --> 00:24:32,000
Okay, Let me tell you, uh, if you can see over here, if I create this bounding box over here, for

415
00:24:32,000 --> 00:24:35,000
example, this is my bounding box, So.

416
00:24:36,000 --> 00:24:37,000
If I just.

417
00:24:37,000 --> 00:24:38,000
Right over here.

418
00:24:38,000 --> 00:24:39,000
Okay, just let me.

419
00:24:39,000 --> 00:24:39,000
Sorry.

420
00:24:39,000 --> 00:24:43,000
I've just will not go on to the paint section, so if you can see over here.

421
00:24:45,000 --> 00:24:50,000
Okay, so if I create a bounding box over here, for example, this is my bounding box over here.

422
00:24:50,000 --> 00:24:52,000
So this represents the one.

423
00:24:52,000 --> 00:24:55,000
Okay, This is the second element of the list.

424
00:24:55,000 --> 00:24:59,000
This is the third element of the list, and this is the fourth element of the list.

425
00:24:59,000 --> 00:25:01,000
So these are the one, two, three, four.

426
00:25:01,000 --> 00:25:02,000
This is one, basically.

427
00:25:02,000 --> 00:25:02,000
Okay.

428
00:25:03,000 --> 00:25:05,000
So if I go back to the code again.

429
00:25:06,000 --> 00:25:07,000
So basically.

430
00:25:09,000 --> 00:25:11,000
If you go if you can see over here.

431
00:25:12,000 --> 00:25:13,000
Okay.

432
00:25:13,000 --> 00:25:18,000
So just let me go back over here so if you can see that this is the first element of the have shown

433
00:25:18,000 --> 00:25:19,000
the bounding box.

434
00:25:19,000 --> 00:25:21,000
This is the second element of the bounding box.

435
00:25:21,000 --> 00:25:23,000
This is the third element of the bounding box.

436
00:25:23,000 --> 00:25:25,000
And this is the fourth element coordinates of the bounding box.

437
00:25:25,000 --> 00:25:27,000
So this is the fourth coordinate.

438
00:25:27,000 --> 00:25:30,000
These are the coordinate points of the bounding box which we have drawn.

439
00:25:30,000 --> 00:25:34,000
Okay, so these are the four corner points of the bounding box.

440
00:25:34,000 --> 00:25:35,000
Okay?

441
00:25:35,000 --> 00:25:39,000
So you can see that over here we have four corner points on the bounding box.

442
00:25:39,000 --> 00:25:40,000
This is the first corner point.

443
00:25:40,000 --> 00:25:42,000
This is the second corner point.

444
00:25:42,000 --> 00:25:45,000
This is the third corner point and this is the fourth corner points.

445
00:25:45,000 --> 00:25:50,000
Okay, So if you can see over here, these are the four corner points on the bounding box.

446
00:25:50,000 --> 00:25:54,000
And this is a text we will just only display this text and this is the confidence.

447
00:25:54,000 --> 00:25:55,000
Okay?

448
00:25:55,000 --> 00:25:58,000
So we will call this function, which we have created over here.

449
00:25:58,000 --> 00:25:59,000
Okay.

450
00:25:59,000 --> 00:26:03,000
So we are saying that we only want to display that in the label section.

451
00:26:03,000 --> 00:26:10,000
We want to display the text inside the bounding box only we want to read the text of the license plate.

452
00:26:10,000 --> 00:26:11,000
So this will be the label.

453
00:26:11,000 --> 00:26:15,000
So if we just display this demo video over here.

454
00:26:16,000 --> 00:26:21,000
So now you can see that our model is able to read the text inside the number plate over here.

455
00:26:21,000 --> 00:26:24,000
Okay, So let me download this video and show you the results as well.

456
00:26:30,000 --> 00:26:33,000
Okay, Just let me navigate my screen over here.

457
00:26:35,000 --> 00:26:38,000
Okay, now, now you can see those results, like we said.

458
00:26:38,000 --> 00:26:42,000
So now you can see that our model is able to read the text inside the number plate.

459
00:26:42,000 --> 00:26:47,000
Okay, So our model is successfully able to read the text inside the number plate.

460
00:26:47,000 --> 00:26:51,000
So it's working completely fine and the results are very good as well.

461
00:26:51,000 --> 00:26:56,000
So that's all from this video tutorial, we are able to detect the license plate.

462
00:26:56,000 --> 00:26:58,000
We have trained our model to detect the license plate.

463
00:26:58,000 --> 00:27:02,000
We have read the text inside the license plate as well using easy OCR.

464
00:27:03,000 --> 00:27:05,000
See you in the next video tutorial.

465
00:27:05,000 --> 00:27:06,000
Till then, bye bye.

