1
00:00:02,000 --> 00:00:02,000
Hi guys.

2
00:00:02,000 --> 00:00:09,000
So now I will train my Yolo v eight model on the pen and box dataset which I have created in the previous

3
00:00:09,000 --> 00:00:09,000
lecture.

4
00:00:09,000 --> 00:00:11,000
You can see over here.

5
00:00:11,000 --> 00:00:18,000
So I will just export this dataset into my Google CoLab notebook by just copying this and pasting this

6
00:00:18,000 --> 00:00:24,000
into my Google CoLab notebook, I will be able to export my dataset from Roboflow into my Google CoLab

7
00:00:24,000 --> 00:00:25,000
notebook.

8
00:00:25,000 --> 00:00:31,000
So first of all, before we export the dataset from Roboflow into my Google CoLab notebook, we first

9
00:00:31,000 --> 00:00:39,000
need to have we need to install YOLO v eight so YOLO V8 can be implemented in two ways by installing

10
00:00:39,000 --> 00:00:44,000
the package Ultralytics or by cloning the YOLO V8 GitHub repo by.

11
00:00:44,000 --> 00:00:50,000
So YOLO V8 is the first version of the YOLO to have its own official package, so we will demand YOLO

12
00:00:50,000 --> 00:00:55,000
V8 by using PIP install ultralytics by installing the package by cloning.

13
00:00:55,000 --> 00:01:01,000
The GitHub repo is a bit lengthy process, so I will follow the easy way which is PIP install ultralytics

14
00:01:01,000 --> 00:01:03,000
to install yolo v8 and implement it.

15
00:01:03,000 --> 00:01:09,000
So first of all, I will set my home directory as this path and setting my current directory.

16
00:01:09,000 --> 00:01:16,000
And now I will install Android ethics package to implement YOLO V8 so it will install all the required

17
00:01:16,000 --> 00:01:17,000
libraries as well.

18
00:01:17,000 --> 00:01:22,000
So now we will check whether Ultralytics is imported and it's working fine or not.

19
00:01:23,000 --> 00:01:23,000
Okay.

20
00:01:23,000 --> 00:01:30,000
So until it is imported and it's working fine, so now I'm creating a folder over here by the name dataset,

21
00:01:30,000 --> 00:01:31,000
so I've already created it.

22
00:01:31,000 --> 00:01:35,000
So it's appearing cannot create directory because it's already exists.

23
00:01:35,000 --> 00:01:36,000
You can see over here.

24
00:01:37,000 --> 00:01:40,000
Okay, so I'm just checking what is my present working directory.

25
00:01:40,000 --> 00:01:48,000
So now I am setting my present working directory as this dataset so I can import my dataset from roboflow

26
00:01:48,000 --> 00:01:51,000
into this colab notebook datasets folder.

27
00:01:51,000 --> 00:01:52,000
Okay.

28
00:01:53,000 --> 00:01:59,000
So I will just copy this all from here and just paste it over here.

29
00:01:59,000 --> 00:02:02,000
Just remove this and paste it and run this.

30
00:02:02,000 --> 00:02:09,000
So now all data set will be downloaded from roboflow into my Google CoLab notebook into this datasets

31
00:02:09,000 --> 00:02:10,000
folder.

32
00:02:10,000 --> 00:02:13,000
So it might take some few minutes or few seconds.

33
00:02:13,000 --> 00:02:17,000
So the data stood for the dataset to get downloaded.

34
00:02:17,000 --> 00:02:17,000
Okay.

35
00:02:17,000 --> 00:02:18,000
What's the issue?

36
00:02:18,000 --> 00:02:19,000
Let me see.

37
00:02:19,000 --> 00:02:20,000
Okay.

38
00:02:20,000 --> 00:02:23,000
I think then we can copy it completely.

39
00:02:23,000 --> 00:02:27,000
So just click on export over here, show download and see.

40
00:02:27,000 --> 00:02:29,000
Okay, so now it will be downloaded.

41
00:02:30,000 --> 00:02:31,000
There.

42
00:02:32,000 --> 00:02:36,000
But if you face this error as well, just remove this and just run this.

43
00:02:36,000 --> 00:02:42,000
So now we will be able to export our dataset from Roboflow into our Google CoLab notebook.

44
00:02:43,000 --> 00:02:47,000
So if you ever face this issue, just go here and click on.

45
00:02:49,000 --> 00:02:52,000
Export again and just copy this one as well.

46
00:02:52,000 --> 00:02:53,000
So this error will be fixed.

47
00:02:53,000 --> 00:02:58,000
Okay, so now our dataset is being downloaded and it's completely downloaded.

48
00:02:58,000 --> 00:03:03,000
You can see that 100% downloaded and it's available in the datasets folder.

49
00:03:03,000 --> 00:03:07,000
You can see pan book detection and train test validation.

50
00:03:07,000 --> 00:03:10,000
And this is the data dot yml file.

51
00:03:10,000 --> 00:03:15,000
You can see that we have two classes Pan book and this is the train test validation path.

52
00:03:15,000 --> 00:03:19,000
Okay, so let's see, what is our dataset location?

53
00:03:19,000 --> 00:03:22,000
So we need to make few changes over here.

54
00:03:22,000 --> 00:03:30,000
Let me tell you, just rename this folder and just remove one because it because if there is any numeric

55
00:03:30,000 --> 00:03:31,000
number, dash one.

56
00:03:31,000 --> 00:03:34,000
So our model is unable to assess the dataset path.

57
00:03:34,000 --> 00:03:42,000
Now just go to read data, dot HTML and just go to train and just copy this path.

58
00:03:43,000 --> 00:03:46,000
And just paste it over here.

59
00:03:46,000 --> 00:03:51,000
Similarly, will go over here as well and write test over here.

60
00:03:52,000 --> 00:03:58,000
Okay, so I'm just setting the path for that train test and validation and write validate over here.

61
00:03:59,000 --> 00:03:59,000
Okay.

62
00:03:59,000 --> 00:04:00,000
So just save it.

63
00:04:01,000 --> 00:04:05,000
And now just rerun that training cell and book detection.

64
00:04:05,000 --> 00:04:07,000
Just rename this folder.

65
00:04:08,000 --> 00:04:09,000
Copy and just.

66
00:04:10,000 --> 00:04:16,000
Rename this folder and let's train our model on 70 epochs with image size, which we have set in.

67
00:04:16,000 --> 00:04:23,000
The robot was 640, so we will have the same image size and pen book detection data dot yaml file.

68
00:04:23,000 --> 00:04:23,000
Okay.

69
00:04:23,000 --> 00:04:24,000
Looks good.

70
00:04:24,000 --> 00:04:25,000
So just run this.

71
00:04:25,000 --> 00:04:28,000
So if there is an issue we will definitely fix it.

72
00:04:28,000 --> 00:04:30,000
So it might take some time.

73
00:04:30,000 --> 00:04:34,000
So let's see if this is working fine or if there is an issue.

74
00:04:34,000 --> 00:04:35,000
So we can fix it.

75
00:04:35,000 --> 00:04:37,000
So the training is about to start.

76
00:04:37,000 --> 00:04:39,000
So this training process will have an idea.

77
00:04:39,000 --> 00:04:43,000
It will take around one hour, 15 minutes or 2 hours.

78
00:04:43,000 --> 00:04:48,000
So I will stop the video over here as the training begins and as the training completes, I will be

79
00:04:48,000 --> 00:04:48,000
back.

80
00:04:48,000 --> 00:04:54,000
Then I will explain you the whole training process and how we can validate our model and validation

81
00:04:54,000 --> 00:04:59,000
prediction batches, results and how to test our model on the test images.

82
00:04:59,000 --> 00:05:02,000
Plus we will also see how we can test this model on the webcam as well.

83
00:05:03,000 --> 00:05:06,000
So the training has started, but it will take some time.

84
00:05:06,000 --> 00:05:08,000
So as it completes, I will be back.

85
00:05:08,000 --> 00:05:10,000
So see you as the training complete.

86
00:05:13,000 --> 00:05:15,000
Guys the training has completed.

87
00:05:15,000 --> 00:05:18,000
So it took around 39 minutes for the training to complete.

88
00:05:18,000 --> 00:05:25,000
We have trained our model on 70 epochs and we have the last epoch weights while on the 70th epoch and

89
00:05:25,000 --> 00:05:30,000
the best weights while on which our model gives us the best performance or results.

90
00:05:31,000 --> 00:05:33,000
Okay, so here is the model summary.

91
00:05:33,000 --> 00:05:37,000
Or you can say that the overall performance analysis of the model.

92
00:05:37,000 --> 00:05:47,000
So we have got a mean average precision with IOU 50 as on book is 0.295, which is 29.5%.

93
00:05:47,000 --> 00:05:51,000
On the pen, it is 0.157, which is 15.7%.

94
00:05:51,000 --> 00:06:00,000
While the mean average precision when IOU varies from 50 to 95 is with on book is 60.16 8%, which is

95
00:06:00,000 --> 00:06:02,000
16.8%.

96
00:06:02,000 --> 00:06:09,000
And with pen it is 0.0623, which is a bit low, like it's around 6%.

97
00:06:09,000 --> 00:06:12,000
Okay, so let's see, what are the files?

98
00:06:12,000 --> 00:06:14,000
Do we get in the training folder?

99
00:06:14,000 --> 00:06:20,000
So we have the confusion matrix, we have the F1 curve, we have the precision recall curve and we have

100
00:06:20,000 --> 00:06:27,000
the results dot CSV file, which gives us the performance metrics and the performance analysis or metrics

101
00:06:27,000 --> 00:06:29,000
of the model After every epoch.

102
00:06:29,000 --> 00:06:35,000
The result DOT PNG contains the training and validation losses, while the training batch zero gives

103
00:06:35,000 --> 00:06:37,000
us the model prediction on the training batch.

104
00:06:37,000 --> 00:06:44,000
While the validation batch prediction give us the model predictions on the validation pads.

105
00:06:44,000 --> 00:06:50,000
So let us display the confusion matrix and in the weights folder we have the best and large weights

106
00:06:50,000 --> 00:06:51,000
file.

107
00:06:51,000 --> 00:06:56,000
So let us first display the confusion matrix and see what do we get.

108
00:06:56,000 --> 00:07:02,000
So Confusion Matrix is basically a chart that shows how our model handles different classes.

109
00:07:02,000 --> 00:07:09,000
So like you can see that 33% of the times our model detected correctly that there is a book, while

110
00:07:09,000 --> 00:07:16,000
67%, 66% of the times when there is a book, our model was not able to detect that there is a book.

111
00:07:16,000 --> 00:07:21,000
So our model detected nothing 66% of the time while there was a book.

112
00:07:21,000 --> 00:07:25,000
So only 33% of the times our model detected correctly that there is a book.

113
00:07:25,000 --> 00:07:26,000
Why?

114
00:07:27,000 --> 00:07:35,000
11% of the times our model detected correctly that there is a pan one 1% of the time there was a pan.

115
00:07:35,000 --> 00:07:41,000
But our model detected that this is a book, while 88% of the times when there is a pan, our model

116
00:07:41,000 --> 00:07:44,000
was unable to detect anything.

117
00:07:44,000 --> 00:07:49,000
So here we have the training and validation process so you can see that the loss is decreasing a bit.

118
00:07:49,000 --> 00:07:57,000
So if we train our model on a more number of epochs, like 200, 300, we will can see that the we have

119
00:07:57,000 --> 00:08:00,000
the loss will be decreasing and our accuracy will be improving.

120
00:08:00,000 --> 00:08:06,000
Like you can see that mean average precision is increasing like you can see over here and you can see

121
00:08:06,000 --> 00:08:10,000
over here as well, like mean average precision is increasing plus.

122
00:08:11,000 --> 00:08:14,000
Here we can see the model prediction on the validation batch.

123
00:08:14,000 --> 00:08:19,000
So these images are not used for the training, so it's always better to take a look.

124
00:08:19,000 --> 00:08:25,000
Our model is performing on the validation batches, so now we are validating our custom model on the

125
00:08:25,000 --> 00:08:26,000
test dataset.

126
00:08:26,000 --> 00:08:32,000
So the test dataset is not used in the training, so we can validate our model on the custom test dataset.

127
00:08:32,000 --> 00:08:36,000
So here we have validated our model on the test dataset.

128
00:08:36,000 --> 00:08:39,000
So just one thing we have changed in the training process.

129
00:08:39,000 --> 00:08:45,000
We choose mode as train while in the validation, we choose mode as validation and validation.

130
00:08:45,000 --> 00:08:48,000
So here is the other zones of the model.

131
00:08:48,000 --> 00:08:55,000
When we test our model on on the test dataset images, we date our model on the test data set images.

132
00:08:55,000 --> 00:09:06,000
So here we have a mean average precision of 0.29 5.9% .9. 5% of the book and mean average precision

133
00:09:06,000 --> 00:09:09,000
of with 50 port pen is 15.7%.

134
00:09:11,000 --> 00:09:15,000
So here we are testing our model on the test dataset images.

135
00:09:15,000 --> 00:09:18,000
So let's see what results do we get over here.

136
00:09:18,000 --> 00:09:21,000
So here model is unable to predict anything here.

137
00:09:21,000 --> 00:09:25,000
The model has predicted correctly that there is a pen while here.

138
00:09:25,000 --> 00:09:28,000
Our model has also predicted correctly that there is a pen here.

139
00:09:28,000 --> 00:09:34,000
Also, our model predicts correctly that they are walking the shelves and here also on model is predicting

140
00:09:34,000 --> 00:09:35,000
that there are book in the shelves.

141
00:09:35,000 --> 00:09:43,000
So I will download this model weights at best speed and we will test our model on the live webcam as

142
00:09:43,000 --> 00:09:43,000
well.

143
00:09:43,000 --> 00:09:48,000
So test let's test our model on the live webcam and see what results do we get over there.

