1
00:00:00,150 --> 00:00:03,690
Hello, everyone, and welcome to this new and exciting session.

2
00:00:04,890 --> 00:00:12,540
In this session, we shall be building a system which permits us automatically detect whether an input,

3
00:00:13,170 --> 00:00:20,010
which in this case is an image, is that of an angry, happy or sad person.

4
00:00:20,010 --> 00:00:21,920
So this person may be sad.

5
00:00:21,930 --> 00:00:23,220
As you could see here.

6
00:00:23,220 --> 00:00:25,140
The person may be angry.

7
00:00:25,650 --> 00:00:30,300
I could see here all the person may be happy.

8
00:00:30,870 --> 00:00:36,570
So, in fact, we want to be able to have this kind of input, pass it into our system, which we want

9
00:00:36,570 --> 00:00:42,900
to build, and then automatically infer that this is a happy person.

10
00:00:43,320 --> 00:00:50,430
And so to train the system will be making use of this data set, which has been made available to us

11
00:00:50,430 --> 00:00:54,030
by Mohammad Hanan Asghar.

12
00:00:54,540 --> 00:00:59,400
And since this dataset is available on Kaggle, just anyone could have access to it.

13
00:00:59,400 --> 00:01:02,250
We are now going to take a closer look at this data set.

14
00:01:02,250 --> 00:01:06,600
As you could see here, we have this test and train directories.

15
00:01:06,600 --> 00:01:09,630
You open up the train, open up the test.

16
00:01:09,630 --> 00:01:13,950
You see you have this three different folders angry, happy, sad here for the train.

17
00:01:13,950 --> 00:01:16,200
You have Angry, happy, sad too.

18
00:01:16,200 --> 00:01:23,220
So what we do is generally when trying to create this kind of dataset for classification problems,

19
00:01:23,220 --> 00:01:30,990
what you want to do is make sure that you put each or you put the different images in separate directories.

20
00:01:30,990 --> 00:01:37,890
So all images represent an angry people are in this directory, happy in this directory and sad in this

21
00:01:37,890 --> 00:01:38,580
directory.

22
00:01:38,580 --> 00:01:45,110
Now this way it becomes easy for us to build our model, taking this dataset as input.

23
00:01:45,120 --> 00:01:50,910
Also, on the previous sessions, we explained the reason why it's very important for us to split our

24
00:01:50,910 --> 00:01:58,950
data set in this kind of manner such that while you use part of the data set that the training to actually

25
00:01:58,950 --> 00:02:05,100
train or build your model, you're going to use the auto part to evaluate this model.

26
00:02:05,940 --> 00:02:14,610
So although in this case we've just been given this data, which is very unlike what you have in real

27
00:02:14,610 --> 00:02:22,410
world scenarios, where you will be asked or tasked to build your own dataset like this one thing or

28
00:02:22,410 --> 00:02:27,450
one very important thing you have to note is the fact that if, for example, your building is kind

29
00:02:27,450 --> 00:02:37,800
of data set where say, we want to monitor the usage of an app or better still monitor how the users

30
00:02:37,800 --> 00:02:48,480
of an app react to a certain feature, then it's important to gather data that reflects or is very similar

31
00:02:48,480 --> 00:02:55,170
to what the data are, rather what the model will be seen during inference.

32
00:02:55,440 --> 00:03:02,970
And so this means that if you have this kind of data or if your model is going to be seeing this kind

33
00:03:02,970 --> 00:03:09,000
of data during the inference or when it's going to make use of the model to predict whether there's

34
00:03:09,000 --> 00:03:21,000
a happy image or not, then training on this kind of data isn't a good idea, although this is images

35
00:03:21,000 --> 00:03:23,850
or these are images of happy people.

36
00:03:23,940 --> 00:03:33,030
So you have to ensure that the data you train on is representative of the data or the kinds of inputs.

37
00:03:33,030 --> 00:03:42,570
The model will be seen when it's going to be deployed and left to predict or make predictions from these

38
00:03:42,570 --> 00:03:43,800
kinds of images.

39
00:03:44,640 --> 00:03:51,750
Then, if you have noticed, not all classes we have here have the same number of files.

40
00:03:51,750 --> 00:04:04,440
So here you have a happy a thousand angry 500 sad five 757 for the train is 1525 year 3000.

41
00:04:05,070 --> 00:04:07,230
So sad to to five five.

42
00:04:07,230 --> 00:04:17,190
So this shows us that when solving your real world problems it may happen that some class or it's easier

43
00:04:17,190 --> 00:04:22,230
to gather data from a particular class as compared to the other.

44
00:04:22,230 --> 00:04:32,280
So your maybe the other of this dataset found it easier to gather happy images as compared to angry

45
00:04:32,280 --> 00:04:33,120
images.

46
00:04:33,900 --> 00:04:39,090
Another very important point to note here is the fact that the kind of problem we're trying to solve

47
00:04:39,090 --> 00:04:42,420
is that of multiclass classification.

48
00:04:42,540 --> 00:04:50,850
So unlike previously where we had a model, we had some data which went past in, we would say whether

49
00:04:50,850 --> 00:05:02,010
this is a parasitic or non parasitic input cell, whereas here what our model outputs isn't just either

50
00:05:02,010 --> 00:05:03,630
one class or the other.

51
00:05:04,860 --> 00:05:10,000
A model which outputs a given class out of several options.

52
00:05:10,020 --> 00:05:18,090
Now, those options could be three, four, five, six, seven or even 1000 different possibilities.

53
00:05:18,120 --> 00:05:21,270
Now all the different possibilities are termed classes.

54
00:05:21,270 --> 00:05:24,130
So in this case we have three classes.

55
00:05:24,150 --> 00:05:32,280
The first class is that of the angry person, the next class, happy person, the other class, a third

56
00:05:32,280 --> 00:05:32,960
person.

57
00:05:32,970 --> 00:05:39,990
Now, to be able to download this data, the very first thing we want to do is create this new API token

58
00:05:39,990 --> 00:05:40,590
right here.

59
00:05:40,590 --> 00:05:48,600
So you get to your profile, you click on account and you will have this year, click here and save

60
00:05:48,600 --> 00:05:50,430
this Kaggle, that JSON file.

61
00:05:50,430 --> 00:05:51,990
So we'll get that saved.

62
00:05:52,800 --> 00:05:58,380
Then getting back to the lab notebook, we simply copy this in your okay.

63
00:05:59,130 --> 00:06:00,700
And then we should have this here.

64
00:06:00,720 --> 00:06:06,660
Now, before moving on, it's important to note that you have to sign up for a Kaggle account, and

65
00:06:06,660 --> 00:06:11,550
then the next step will be to install this Kaggle package.

66
00:06:11,550 --> 00:06:16,410
So Pip, install Kaggle, run that sell.

67
00:06:18,040 --> 00:06:19,660
Then we create this directory.

68
00:06:19,660 --> 00:06:24,190
So we make this directory and then we copy this JSON file in this directory.

69
00:06:24,190 --> 00:06:25,810
So again, we run the cell.

70
00:06:26,440 --> 00:06:31,670
Then from here we give the user full rights to read and write into this cargo file right here.

71
00:06:31,690 --> 00:06:38,770
We run the cell, then get back to Kaggle where we are going to copy this API command.

72
00:06:39,160 --> 00:06:43,730
Now, after copying this API command, we're going to paste this just here.

73
00:06:43,750 --> 00:06:47,040
So here we have Kaggle data sets download.

74
00:06:47,050 --> 00:06:50,740
So we're going to download this data, set this human emotions data set.

75
00:06:50,920 --> 00:06:52,600
Let's run the cell.

76
00:06:54,770 --> 00:06:56,440
Our dataset has been downloaded.

77
00:06:56,540 --> 00:07:00,170
Now we're now left to unzip this downloaded file.

78
00:07:00,200 --> 00:07:01,370
Let's click this here.

79
00:07:01,370 --> 00:07:03,900
You see, we have human emotions data set that zip.

80
00:07:03,920 --> 00:07:07,460
We now unzip this and store in this dataset folder.

81
00:07:07,850 --> 00:07:09,830
So you're going to run the cell.

82
00:07:09,980 --> 00:07:13,400
You'll see that it's going to create this folder, this set.

83
00:07:13,400 --> 00:07:17,880
And in this data set you have the emotions data set, which we saw in Kaggle.

84
00:07:17,900 --> 00:07:19,820
Basically, this is the data set right here.

85
00:07:19,970 --> 00:07:27,740
From this point, we'll go on to generate a tensorflow data set based off the images which are found

86
00:07:27,740 --> 00:07:29,270
in the directories.

87
00:07:29,270 --> 00:07:37,730
So we're going to make use of this image data set from directory method, which is in the Keras utils

88
00:07:38,060 --> 00:07:39,610
package right here.

89
00:07:39,620 --> 00:07:43,340
So here we have this description.

90
00:07:43,370 --> 00:07:47,520
So here we have this different arguments directory.

91
00:07:47,540 --> 00:07:49,850
Now the directory let's, let's copy this.

92
00:07:49,850 --> 00:07:52,880
So we see clearly this in the code.

93
00:07:52,880 --> 00:07:54,920
We copy and paste this out here.

94
00:07:54,950 --> 00:07:59,840
This directory is going to be simply one of the directories here.

95
00:07:59,840 --> 00:08:03,380
So your first thing we'll do is we'll create our training data set.

96
00:08:03,380 --> 00:08:06,200
So that's our trained data set, which is a tensorflow data set.

97
00:08:06,230 --> 00:08:07,370
We've seen this already.

98
00:08:07,880 --> 00:08:09,770
We're going to specify the directory.

99
00:08:09,770 --> 00:08:14,330
So let's call this train directory.

100
00:08:14,690 --> 00:08:18,110
And we'll simply copy this path.

101
00:08:18,110 --> 00:08:24,720
So let's copy this path and then paste it out your copy that path, paste it.

102
00:08:24,740 --> 00:08:30,470
Now we have our validation validation directory.

103
00:08:30,500 --> 00:08:31,760
We're going to do the same thing.

104
00:08:31,760 --> 00:08:38,450
So basically, again, we're going to copy this here, copy and paste.

105
00:08:38,480 --> 00:08:43,850
Now, here we're going to use this as our training data set and we're going to use this as our validation

106
00:08:43,850 --> 00:08:44,480
data set.

107
00:08:44,480 --> 00:08:48,210
So here's our train user validation and that's it.

108
00:08:48,230 --> 00:08:51,140
So with this, let's run this cell.

109
00:08:51,410 --> 00:08:52,070
That's it.

110
00:08:52,070 --> 00:08:57,440
We get back here, we change this to train directory.

111
00:08:57,560 --> 00:09:05,030
Now, here the levels are inferred, and this means that the labels will be generated from the directory

112
00:09:05,030 --> 00:09:05,690
structure.

113
00:09:05,690 --> 00:09:12,890
So if you could look at this here, this example lets you have this main directory and you have the

114
00:09:12,890 --> 00:09:13,700
directory structure.

115
00:09:13,700 --> 00:09:19,340
That's why at the beginning we made mention of the fact that it's important to maintain this kind of

116
00:09:19,340 --> 00:09:22,190
directory structure when dealing with classification problems.

117
00:09:22,190 --> 00:09:28,640
So because we have this kind of directory structure where we have a class, we have images, we have

118
00:09:28,670 --> 00:09:34,490
a class, and then it's images like we could see here we have this in the train, we have the class,

119
00:09:34,490 --> 00:09:38,840
we have the images, we have this class and this images, this class and these images.

120
00:09:38,840 --> 00:09:43,820
We are able to automatically create this kind of data set.

121
00:09:45,170 --> 00:09:48,290
And that's the role of this inferred right here.

122
00:09:48,470 --> 00:09:51,540
Then the next one we have is a label mode.

123
00:09:51,560 --> 00:09:59,810
Now, for the label mode, we have several modes here, the default, we have the INT, we have categorical,

124
00:09:59,810 --> 00:10:01,520
we have binary or none.

125
00:10:01,550 --> 00:10:06,050
Now let's explain what these different modes mean for the integer mode.

126
00:10:06,050 --> 00:10:12,290
We simply meaning that when we design all the way we design our data set is such that we have an image

127
00:10:12,680 --> 00:10:15,050
and we have a label.

128
00:10:15,050 --> 00:10:18,110
So let's say we have this image of this person.

129
00:10:18,110 --> 00:10:22,520
The person is happy and we have three different possibilities.

130
00:10:22,520 --> 00:10:28,130
Either the person is angry, happy or sad.

131
00:10:28,910 --> 00:10:32,960
So here what we're going to have is angry, angry.

132
00:10:32,960 --> 00:10:38,290
We're going to give it a value of zero happy, a value of one side, a value of two.

133
00:10:38,300 --> 00:10:40,160
So here are three different possibilities.

134
00:10:40,160 --> 00:10:45,440
And so when designing this data set or when creating this data set, we'll create a sorry that we have

135
00:10:45,440 --> 00:10:52,340
the image and this integer which reflects what that the emotion in that image.

136
00:10:52,490 --> 00:10:57,380
So here in our case, in the case of happy would simply have an output of one.

137
00:10:57,620 --> 00:11:06,260
Now, that said, either we create our dataset in this way or we use a one hard representation of this

138
00:11:06,260 --> 00:11:07,040
labels.

139
00:11:07,040 --> 00:11:14,120
So what this means is instead of having zero, we'll create a vector of size three, which has three

140
00:11:14,120 --> 00:11:23,210
different positions where if we have an angry input, So if the person is angry, we'll put a one in

141
00:11:23,210 --> 00:11:30,860
this position and zero zero here, If the person is happy, we'll put a zero.

142
00:11:30,890 --> 00:11:33,650
You're a one and a zero.

143
00:11:33,650 --> 00:11:36,680
And if the person is sad, we'll put a zero.

144
00:11:36,710 --> 00:11:39,770
You're a zero and a one.

145
00:11:39,770 --> 00:11:46,760
And the way this encoding works is that where we have zero, you see the position is one for the one

146
00:11:47,270 --> 00:11:52,850
representation where we have a one happy person, we put a one under first position.

147
00:11:52,970 --> 00:12:00,440
Well, we have a person who put a tool, We have a tool, and so we put a one at the second position.

148
00:12:01,700 --> 00:12:05,660
And then with this, there'll be some differences in the designing of the loss function, which we are

149
00:12:05,660 --> 00:12:09,410
going to see in subsequent sessions.

150
00:12:09,440 --> 00:12:15,350
Now we have this binary for the binary is like the previous example of the previous project we worked

151
00:12:15,350 --> 00:12:18,350
in where we have two classes.

152
00:12:18,350 --> 00:12:22,240
So where we have two classes, we just have the level mode to be binary.

153
00:12:22,250 --> 00:12:26,810
In our case, we may pick out the integer or the categorical.

154
00:12:27,920 --> 00:12:30,150
Then from here we have the class names.

155
00:12:30,170 --> 00:12:35,270
Now, if you decided to infer directly from the class directory, then it's important to make sure that

156
00:12:35,270 --> 00:12:37,910
this class names match the subdirectories.

157
00:12:37,910 --> 00:12:42,980
So you should ensure that if you're, for example, you have this class names.

158
00:12:42,980 --> 00:12:46,010
Let's put out the class names here.

159
00:12:46,010 --> 00:12:48,680
So you will have class names.

160
00:12:48,770 --> 00:12:53,900
And let's say we want to have angry.

161
00:12:54,170 --> 00:12:55,520
We have angry.

162
00:12:55,520 --> 00:12:57,850
We have happy.

163
00:12:57,860 --> 00:12:59,720
We have sad.

164
00:13:00,020 --> 00:13:01,280
We have sad.

165
00:13:01,730 --> 00:13:04,030
So yours are class names.

166
00:13:04,040 --> 00:13:10,490
Now, if we don't put this exactly as it is here, we should have an error.

167
00:13:10,490 --> 00:13:11,720
So let's run this.

168
00:13:11,720 --> 00:13:13,550
We have class names there.

169
00:13:13,760 --> 00:13:18,800
We get back here and instead of having this year, we're going to specify our class names.

170
00:13:19,100 --> 00:13:22,570
So here we have class names.

171
00:13:22,580 --> 00:13:23,510
There we go.

172
00:13:23,510 --> 00:13:25,250
So we have that.

173
00:13:25,250 --> 00:13:26,720
The next is a color mode.

174
00:13:26,720 --> 00:13:30,590
RGV The batch size by default is 32.

175
00:13:30,620 --> 00:13:33,440
The image size here, the default is 256.

176
00:13:33,440 --> 00:13:34,310
By 256.

177
00:13:34,310 --> 00:13:35,840
We could always modify this.

178
00:13:35,840 --> 00:13:37,700
Shuffling by default is true.

179
00:13:37,700 --> 00:13:44,030
So by default we're going to shuffle our data set to we do not need to explicitly do this shuffling,

180
00:13:44,030 --> 00:13:51,050
so we just have to specify this to be true and that that's done now for reproducibility, we could give

181
00:13:51,050 --> 00:13:55,430
a seed such that we always have the same shuffling.

182
00:13:56,090 --> 00:13:58,340
Then we have this validation split.

183
00:13:58,340 --> 00:14:04,460
So you're in a case where let's say we have just one directory, let's say we just have the dataset

184
00:14:04,460 --> 00:14:06,200
directory, we do not have this test.

185
00:14:06,230 --> 00:14:10,010
We may want to split this directory into the training and validation.

186
00:14:10,010 --> 00:14:18,320
So here we could have your, let's say 0.2 and automatically we're going to have a split of this data

187
00:14:18,530 --> 00:14:21,410
into the and validation data sets.

188
00:14:21,440 --> 00:14:26,510
Now, once you have the split, since you're creating the trained data set, you specify that this is

189
00:14:26,510 --> 00:14:27,200
training.

190
00:14:27,290 --> 00:14:29,960
So training is actually in the documentation.

191
00:14:29,960 --> 00:14:33,950
Here you have your validation split.

192
00:14:34,280 --> 00:14:39,890
So an optional float between zero and one, which is logical since we split in our data set.

193
00:14:39,890 --> 00:14:43,790
And then we'll specify either training or validation.

194
00:14:43,790 --> 00:14:45,740
So let's get back here.

195
00:14:45,740 --> 00:14:50,030
So in this case it will be training the interpolation by linear follow links.

196
00:14:50,030 --> 00:14:52,490
False crop two aspect ratio false.

197
00:14:52,490 --> 00:14:54,260
So these are the default values.

198
00:14:54,260 --> 00:14:56,660
We are going to use this, take this off.

199
00:14:56,660 --> 00:15:02,810
And in this case, in the case where we would have had validation, we just have your validation.

200
00:15:02,810 --> 00:15:05,300
So anyway, we're not going to use this.

201
00:15:05,300 --> 00:15:06,660
Let's take this off.

202
00:15:06,680 --> 00:15:11,390
That said, by default, the validation split is known.

203
00:15:11,390 --> 00:15:15,110
So optional float, there's no we're not going to do any validation.

204
00:15:15,200 --> 00:15:22,310
So that said, let's have this off and let's run this and see what our data set are trained data set

205
00:15:22,310 --> 00:15:22,940
is about.

206
00:15:22,940 --> 00:15:27,610
So here we have 6000 799 files belonging to three classes.

207
00:15:27,620 --> 00:15:31,700
Now let's go ahead and modify this.

208
00:15:31,700 --> 00:15:38,240
Let's add that is that let's run this now and see what we get.

209
00:15:38,990 --> 00:15:43,970
You see, already we have this error because there's no match in the class namespace didn't match the

210
00:15:43,970 --> 00:15:46,460
names of the subdirectories of the target directory.

211
00:15:46,460 --> 00:15:48,980
So I expected this but instead received this.

212
00:15:48,980 --> 00:15:50,900
So let's get back.

213
00:15:50,900 --> 00:15:52,880
Modify it here.

214
00:15:53,840 --> 00:15:55,010
There we go.

215
00:15:55,370 --> 00:15:56,390
That's fine.

216
00:15:57,110 --> 00:16:01,190
We run this here and that's fine.

217
00:16:01,670 --> 00:16:03,200
So that's our training data.

218
00:16:03,200 --> 00:16:06,880
We could do the same for our validation data.

219
00:16:06,890 --> 00:16:08,630
So validation.

220
00:16:08,660 --> 00:16:11,930
Let's see Val and your string.

221
00:16:11,930 --> 00:16:17,390
Okay, so your stranger is Val, and we have the Val directory.

222
00:16:17,780 --> 00:16:19,610
We have the Val directory.

223
00:16:19,610 --> 00:16:22,760
Let's ensure that you call this Val.

224
00:16:23,060 --> 00:16:24,410
Val directory.

225
00:16:25,430 --> 00:16:27,620
We get back and that's it.

226
00:16:27,980 --> 00:16:31,520
Here is inferred level mode int class name same class names.

227
00:16:31,520 --> 00:16:42,410
RGV 32 image size 256 Now let's change this and have configuration and batch size.

228
00:16:42,950 --> 00:16:46,280
Okay, so that's our batch size.

229
00:16:46,670 --> 00:16:49,610
Here we have this image size.

230
00:16:49,610 --> 00:16:52,700
So size, take this.

231
00:16:52,850 --> 00:16:54,570
Off base and out.

232
00:16:54,590 --> 00:16:57,140
You have your size.

233
00:16:57,270 --> 00:17:04,610
Okay, so we have this configurations and then we could create this year configuration.

234
00:17:06,620 --> 00:17:07,820
There we go.

235
00:17:08,060 --> 00:17:13,790
We have the batch size, which will take a value of 32.

236
00:17:13,820 --> 00:17:20,660
We have the image size, which would take a value of 256.

237
00:17:20,960 --> 00:17:22,070
So we have that.

238
00:17:22,070 --> 00:17:23,510
Let's run this.

239
00:17:23,840 --> 00:17:28,900
We get back here just configurations.

240
00:17:28,910 --> 00:17:30,140
Let's copy this here.

241
00:17:30,800 --> 00:17:31,610
And that's fine.

242
00:17:31,610 --> 00:17:37,910
We have our 2278 files belonging to three different classes for our validation data set.

243
00:17:39,380 --> 00:17:42,200
From here, we're going to do we're going to look at our data set.

244
00:17:42,200 --> 00:17:54,610
So let's say for the of our image and label in VAL legislative for for for I in Val data set.

245
00:17:54,620 --> 00:17:57,020
Let's take one let's take one batch.

246
00:17:57,050 --> 00:18:02,510
We're going to print out I so we're on that scroll down.

247
00:18:02,540 --> 00:18:06,200
See we have the images we're interested in looking at the labels for now.

248
00:18:06,200 --> 00:18:11,960
So let's go down scroll up to this year.

249
00:18:11,960 --> 00:18:12,390
Okay.

250
00:18:12,440 --> 00:18:20,000
You see the labels we have 22001 is the label is between zero and one because we have three different

251
00:18:20,000 --> 00:18:20,730
classes.

252
00:18:20,750 --> 00:18:23,750
Now, let's modify this.

253
00:18:24,080 --> 00:18:29,900
Instead of having the label more two inch, let's know this is in already, or let's change it to categorical,

254
00:18:30,170 --> 00:18:34,730
categorical and this year categorical.

255
00:18:34,730 --> 00:18:36,860
Run that, run this.

256
00:18:37,610 --> 00:18:39,680
And okay, so we'll see what we get.

257
00:18:39,680 --> 00:18:46,220
So instead of having two here, instead of having two two, what we have is this one hard representation

258
00:18:46,940 --> 00:18:51,710
here where the everywhere is zero except at the second position.

259
00:18:51,710 --> 00:18:57,260
So here, instead of having zero, we have everywhere zero except at the zero position.

260
00:18:57,440 --> 00:18:58,670
So that's it.

261
00:18:58,910 --> 00:19:01,220
Now we shall go on to visualize this there.

262
00:19:01,220 --> 00:19:07,010
So here we have this figure and then we specify the figure size.

263
00:19:07,010 --> 00:19:13,550
So we have your fixed size and we have this say 12 by 12.

264
00:19:13,880 --> 00:19:15,800
Okay, So we have that.

265
00:19:15,800 --> 00:19:22,250
And then four images and labels in our trained data set.

266
00:19:22,250 --> 00:19:25,670
We have this in our train data set.

267
00:19:25,670 --> 00:19:29,990
You could always change this and put, for example, the validation dataset.

268
00:19:29,990 --> 00:19:32,180
So we have that now trained data set.

269
00:19:32,180 --> 00:19:35,450
We take just one, then we create a subplot.

270
00:19:35,480 --> 00:19:43,460
Your PLT subplot is going to be 4x4, then I plus one.

271
00:19:43,760 --> 00:19:46,880
Okay, so we have that and then we'll do an IM show.

272
00:19:46,880 --> 00:19:49,880
So we show we plot out the image.

273
00:19:50,660 --> 00:19:56,450
Basically this image right here and then we select a given image.

274
00:19:56,450 --> 00:20:03,350
So we have that and then we divide all those pixels values by 255.

275
00:20:03,350 --> 00:20:04,490
So we have that.

276
00:20:04,490 --> 00:20:08,990
And then next one next step is to plot out the title.

277
00:20:08,990 --> 00:20:14,060
So now we plot now the images, then we then go ahead to plot out the different titles.

278
00:20:14,750 --> 00:20:21,950
Then here we have the outputs that the labels basically select the label, so we select the particular

279
00:20:21,950 --> 00:20:24,470
label just as we selected the image.

280
00:20:24,470 --> 00:20:31,670
And then we have let's because, because the labels will be a 100 presentation, then we have to take

281
00:20:31,670 --> 00:20:32,980
the max.

282
00:20:32,990 --> 00:20:38,840
Now, if you're new to this, you could check out the previous sections where we talk about these kinds

283
00:20:38,840 --> 00:20:40,070
of methods here.

284
00:20:40,070 --> 00:20:43,610
So we have the max of this and we have an axis.

285
00:20:43,610 --> 00:20:46,070
Let's specify this axis zero.

286
00:20:46,250 --> 00:20:47,480
That's fine.

287
00:20:48,350 --> 00:20:52,850
I think here we should also just do the plotting, so we should take off the axis.

288
00:20:52,850 --> 00:20:53,150
Sorry.

289
00:20:53,150 --> 00:20:55,700
So axis and off.

290
00:20:55,700 --> 00:20:56,840
So let's run this.

291
00:20:56,840 --> 00:21:00,680
So you see what we get before we have that.

292
00:21:00,680 --> 00:21:04,930
Anyway, here we have non pi, so let's convert this to non pi.

293
00:21:04,940 --> 00:21:06,080
Run that again.

294
00:21:06,320 --> 00:21:08,780
You have this output.

295
00:21:08,780 --> 00:21:09,440
There we go.

296
00:21:09,440 --> 00:21:11,790
You see that we have the image and its class above.

297
00:21:11,810 --> 00:21:16,010
Now to convert this into some words, let's make use of the class names.

298
00:21:16,010 --> 00:21:17,810
So we have class names.

299
00:21:18,830 --> 00:21:24,230
Class names and then you're we have this we run this again.

300
00:21:24,230 --> 00:21:27,740
We now get the different images and your labels.

301
00:21:27,740 --> 00:21:31,460
At this point, our dataset is now ready for training.

302
00:21:31,460 --> 00:21:37,580
We just have to include this pre fetching here for a more efficient usage of our data.

303
00:21:37,580 --> 00:21:44,990
We saw this kind of refreshing or we explained what perfection was all about and some previous sessions.

304
00:21:44,990 --> 00:21:46,730
So here we have the prevention.

305
00:21:46,730 --> 00:21:51,830
We're going to include the batch because you're already, we've included a badge size previously.

306
00:21:52,140 --> 00:22:00,060
So in this data set loading right here, we specify the batch size, so our data is already batched.

307
00:22:00,090 --> 00:22:08,810
Now we have that, we run the solve for the training and then we simply redo this for the validation.

308
00:22:08,820 --> 00:22:13,050
So this is our validation, data validation.

309
00:22:13,950 --> 00:22:16,640
And now we're ready for building our model.

310
00:22:16,650 --> 00:22:22,110
But before going on to build our model, we shall copy out this code here from the previous session

311
00:22:22,110 --> 00:22:24,050
and paste it out here.

312
00:22:24,060 --> 00:22:28,710
So we have this resized skill layers, which we're going to include in the model.

313
00:22:28,740 --> 00:22:34,170
Now recall that we could do this resizing like we have our data set here.

314
00:22:34,170 --> 00:22:40,800
So supposing you have your data set, you could do the resizing and reskilling your this reskilling

315
00:22:40,800 --> 00:22:48,210
and this a resize into the required size before passing this data into the model.

316
00:22:48,390 --> 00:22:56,580
So this could be done before passing into the model such that you could train your model on this resized

317
00:22:56,580 --> 00:22:57,810
and reskilled data.

318
00:22:57,930 --> 00:23:02,970
Now another method will be to pass in your data here.

319
00:23:02,970 --> 00:23:05,730
So let's suppose that we have let's take this off.

320
00:23:06,670 --> 00:23:15,400
We suppose that year we have in this middle we have the resizing and rescaling unit, so we resize and

321
00:23:15,400 --> 00:23:17,290
reskill before passing into the model.

322
00:23:17,320 --> 00:23:24,160
Now, instead of doing this, what we could do is we could pass the data into the model directly and

323
00:23:24,160 --> 00:23:32,020
then carry out the resizing and reskilling in the model as a layer in the model.

324
00:23:32,050 --> 00:23:39,160
Now, we've seen this already, but we'll just explain here again that doing this is great for deployment

325
00:23:39,160 --> 00:23:45,970
because when you have to deploy this kind of system, you no longer want to resize it again.

326
00:23:45,970 --> 00:23:52,270
So your all you do now is just pass in this image and then the model on its own.

327
00:23:52,280 --> 00:23:57,670
There's the model which has been deployed takes care of resizing and reskilling.

328
00:23:57,700 --> 00:24:04,930
Unlike in this kind of system where when you deploy this model, you have to do the resizing and reskilling

329
00:24:04,930 --> 00:24:05,680
on your own.

330
00:24:05,680 --> 00:24:12,040
So this means that if you deploy this model on some cloud solution and then you're calling it from a

331
00:24:12,040 --> 00:24:19,960
JavaScript client, for example, or say some Android client, then you would have to carry out this

332
00:24:19,960 --> 00:24:27,820
resizing and rescaling in JavaScript, unlike here, where you just pass in the image and the model

333
00:24:27,820 --> 00:24:31,570
takes charge of resizing and rescaling.

334
00:24:31,930 --> 00:24:38,080
So that said, let's take this off, get back to our code here.

335
00:24:38,080 --> 00:24:43,630
We're going to have we're going to run this simply and then we start with building our model.

336
00:24:43,660 --> 00:24:46,540
Here we have this error resize not defined.

337
00:24:46,540 --> 00:24:49,270
So simply we have Keras layers here.

338
00:24:49,270 --> 00:24:54,070
So we should just as we did here to the resizing.

339
00:24:54,340 --> 00:25:00,960
So we have resize and that we go run that cell again and then get back to.

340
00:25:02,770 --> 00:25:06,610
At this point our dataset is now ready for training.

341
00:25:06,610 --> 00:25:12,730
We just have to include this pre fetching here for a more efficient usage of our data.

342
00:25:12,730 --> 00:25:20,140
We saw those kinds of prevention or we explained what prevention was all about and some previous sessions.

343
00:25:20,140 --> 00:25:21,880
So here we have the prevention.

344
00:25:21,880 --> 00:25:26,980
We're now going to include the batching because you're already, we've included a batch size previously.

345
00:25:26,980 --> 00:25:32,620
So in this data set loading right here, we specify the batch size.

346
00:25:32,620 --> 00:25:35,200
So our data is already batched.

347
00:25:35,230 --> 00:25:43,960
Now we have that we run the saw for the training and then we simply redo this for the validation.

348
00:25:43,960 --> 00:25:51,790
So this is our validation, data validation, and now we're ready for building our model.

349
00:25:51,790 --> 00:25:57,100
But before going on to build our model, we shall copy out this code here from the previous session

350
00:25:57,100 --> 00:25:58,960
and paste it out here.

351
00:25:58,960 --> 00:26:03,620
So we have this resized three skill layers, which we're going to include in the model.

352
00:26:03,640 --> 00:26:09,070
Now recall that we could do this resizing like we have our dataset here.

353
00:26:09,070 --> 00:26:15,850
So supposing you have your data set, you could do the resizing and rescaling your this reskilling and

354
00:26:15,850 --> 00:26:23,110
this resize into the required size before passing this data into the model.

355
00:26:23,290 --> 00:26:31,480
So this could be done before passing to the model such that you could train your model on this resized

356
00:26:31,480 --> 00:26:32,710
and rescaled data.

357
00:26:32,830 --> 00:26:40,600
Now another method will be to pass in your data your So let's suppose that we have let's take this off.

358
00:26:41,500 --> 00:26:49,240
We suppose that here we have in this model we have the resizing and rescaling unit.

359
00:26:49,240 --> 00:26:52,190
So we resize and reskill before passing into the model.

360
00:26:52,210 --> 00:26:59,050
Now, instead of doing this, what we could do is we could pass the data into the model directly and

361
00:26:59,050 --> 00:27:06,950
then carry out the resizing and reskilling in the model as a layer in the model.

362
00:27:06,970 --> 00:27:14,080
Now, we've seen this already, but we'll just explain your again that doing this is great for deployment

363
00:27:14,080 --> 00:27:20,890
because when you have to deploy this kind of system, you no longer want to resize it again.

364
00:27:20,890 --> 00:27:28,150
So your all you do now is just pass in this image and then the model on its own does the model which

365
00:27:28,150 --> 00:27:32,560
has been deployed takes care of resizing and reskilling.

366
00:27:32,590 --> 00:27:39,850
Unlike in this kind of system where when you deploy this model, you have to do the resizing and reskilling

367
00:27:39,850 --> 00:27:40,600
on your own.

368
00:27:40,600 --> 00:27:48,100
So this means that if you deploy this model on some cloud solution and then you're calling it from a

369
00:27:48,100 --> 00:27:56,020
JavaScript client, for example, or say some Android client, then you would have to carry out this

370
00:27:56,020 --> 00:28:03,880
resizing and rescaling in JavaScript, unlike here, where you just pass in the image and the model

371
00:28:03,880 --> 00:28:06,220
takes charge of resizing.

372
00:28:06,400 --> 00:28:07,690
And reskilling.

373
00:28:07,960 --> 00:28:10,660
So that said, let's take this off.

374
00:28:10,690 --> 00:28:12,130
Get back to our code.

375
00:28:13,800 --> 00:28:16,780
Here we're going to have we're going to run this simply.

376
00:28:16,780 --> 00:28:19,700
And then we start with building our model.

377
00:28:19,720 --> 00:28:22,600
Here we have this error resize not defined.

378
00:28:22,600 --> 00:28:25,320
So simply, we have cross layers here.

379
00:28:25,330 --> 00:28:30,130
So we should just as we did here, do the resizing.

380
00:28:30,400 --> 00:28:36,760
So we have resize and there we go, run that cell again and we're now ready for modeling.
