1
00:00:00,180 --> 00:00:03,180
So now let's take a look at how we see of models with curves.

2
00:00:03,600 --> 00:00:04,800
It's actually quite simple.

3
00:00:05,220 --> 00:00:09,210
All we have to do is just take model, the model object that we trend above here.

4
00:00:09,750 --> 00:00:16,230
Remember, we just use models that fit that scroll up just to remind you guys of that right here.

5
00:00:16,260 --> 00:00:17,060
Model not fit.

6
00:00:17,100 --> 00:00:21,810
Remember, that was the object we created with model to compile after we created all these layers in

7
00:00:21,810 --> 00:00:22,080
it.

8
00:00:22,680 --> 00:00:27,960
So to save it all, we have to do it as a see function built into it where we just do model of save

9
00:00:27,960 --> 00:00:28,840
and we give the name.

10
00:00:28,920 --> 00:00:29,640
We want to save.

11
00:00:29,850 --> 00:00:32,280
So let's see if this model, if we just created.

12
00:00:32,970 --> 00:00:36,150
And you can see see if there's a dot each file right here.

13
00:00:37,050 --> 00:00:41,790
And you can download this as well as download or model for sentimental reasons, because it's probably

14
00:00:41,790 --> 00:00:44,580
a first car CNN model that you've dreamed.

15
00:00:45,120 --> 00:00:46,080
While we wait for that.

16
00:00:46,620 --> 00:00:47,790
Let's move on to the lesson.

17
00:00:47,820 --> 00:00:50,160
So how do we look at models that we save?

18
00:00:50,730 --> 00:00:52,230
Well, it's actually quite easy again.

19
00:00:52,710 --> 00:00:56,730
There's a camera's function called load model that's followed into TensorFlow.

20
00:00:56,730 --> 00:00:58,080
That character models.

21
00:00:58,200 --> 00:00:59,160
Part of that library.

22
00:00:59,760 --> 00:01:06,390
And to do that, you just enter the path, which is here, which is a name we give it before I use 10

23
00:01:06,390 --> 00:01:09,900
here because it was tiny box, but actually it's 25 in reality.

24
00:01:09,900 --> 00:01:12,140
So make that change on your own.

25
00:01:12,150 --> 00:01:15,020
It's a good practice to see in models like this.

26
00:01:15,020 --> 00:01:16,500
Save it with the dataset name.

27
00:01:17,040 --> 00:01:18,680
Maybe a description if you want.

28
00:01:18,690 --> 00:01:21,120
How many epochs, if that's important for you.

29
00:01:21,510 --> 00:01:23,460
Also, did you train that?

30
00:01:23,520 --> 00:01:25,290
Just a good, good practice as well.

31
00:01:26,040 --> 00:01:30,450
So when you load a model, you load the model and we can give it any name we want.

32
00:01:30,960 --> 00:01:32,520
Previously, we were calling its model.

33
00:01:33,030 --> 00:01:38,250
I tend to call it classifiers sometimes if I just want to get confused with a loaded model as opposed

34
00:01:38,250 --> 00:01:39,390
to one up in training.

35
00:01:40,320 --> 00:01:45,180
But it doesn't matter what name you give it, because when you we're going to use classify, I know

36
00:01:45,390 --> 00:01:48,240
the loaded model that's load on model that we saved.

37
00:01:48,660 --> 00:01:51,970
So now let's continue getting predictions using a, well, loaded model.

38
00:01:52,380 --> 00:01:57,570
So we load the model here by running this block of code and that created that puts a model into this

39
00:01:57,570 --> 00:02:01,920
classifier variable, which is basically the same as the model we used before the model object.

40
00:02:01,920 --> 00:02:07,140
But now it's called classifier just because I wanted to use a different name and we used that here.

41
00:02:07,530 --> 00:02:13,260
Actually, let's use let's put it in here classifier to predict, and let's show.

42
00:02:13,440 --> 00:02:14,270
Let me show you what's happening.

43
00:02:14,340 --> 00:02:19,770
You may have noticed it could change because I just added something here, because in Keros, the predict

44
00:02:19,770 --> 00:02:23,100
classes function was deprecated, so we had to make some changes.

45
00:02:23,100 --> 00:02:26,080
So we used it petered out, max.

46
00:02:26,130 --> 00:02:34,050
This gives us the map, the the index of for the class name of the output that that corresponded to

47
00:02:34,050 --> 00:02:35,250
the maximum probability.

48
00:02:35,910 --> 00:02:38,210
So this gives us here.

49
00:02:38,220 --> 00:02:43,220
So we by running classifier that predict or test, remember we'll get 10 probabilities.

50
00:02:43,230 --> 00:02:48,750
Each probability is going to be the probability of that class of input.

51
00:02:48,750 --> 00:02:53,490
Class B belonging to either zero one two three four five six seven.

52
00:02:53,910 --> 00:02:56,250
So what the NPL AMAX function does?

53
00:02:56,250 --> 00:03:02,240
It basically just tells us which of those probabilities was a maximum and returned to class.

54
00:03:02,250 --> 00:03:08,310
So if it thinks it's a five, if it involved predicted that it's going to rise from probability for

55
00:03:08,340 --> 00:03:12,170
five, then it's this is going to be 10 five here in infrared.

56
00:03:12,900 --> 00:03:18,120
So we're running this X, which is an array that has 10000 samples.

57
00:03:18,220 --> 00:03:21,030
Remember that prediction 10000 test images?

58
00:03:21,510 --> 00:03:27,900
So we're going to now predict we're going to have no input, 10000 samples into our model and get the

59
00:03:27,900 --> 00:03:28,820
outputs afterward.

60
00:03:28,830 --> 00:03:29,730
So let's do that.

61
00:03:30,990 --> 00:03:35,370
And look, we just did 10000 predictions in less than a second.

62
00:03:35,820 --> 00:03:41,280
That's extremely, extremely fast inference, and that shows you how powerful the CPU's are that we

63
00:03:41,280 --> 00:03:41,680
were using.

64
00:03:41,730 --> 00:03:45,450
And these are low energy use that are freely available on Google Cloud.

65
00:03:46,080 --> 00:03:47,940
So you can see this is the output area here.

66
00:03:47,940 --> 00:03:49,950
We don't print doesn't put the entire thing.

67
00:03:50,280 --> 00:03:53,910
But if you wanted to verify the length length of is 10000 as well.

68
00:03:54,630 --> 00:03:58,800
Now let's see how we can actually predict an individual test image.

69
00:03:58,950 --> 00:04:02,820
So we grab a test image here by indexing on the first image.

70
00:04:02,820 --> 00:04:05,760
In the test datasets, we print the dimensions.

71
00:04:06,360 --> 00:04:07,770
It's twenty eight by twenty one.

72
00:04:08,070 --> 00:04:11,940
Remember, for us, we need to reshape that.

73
00:04:12,330 --> 00:04:15,290
So we use to reshape function so we know we should put it in this year.

74
00:04:15,300 --> 00:04:21,540
This is the shape we know it once we want it to be and it's one twenty or twenty one, just have the

75
00:04:21,540 --> 00:04:22,290
one dimension here.

76
00:04:22,620 --> 00:04:26,760
This is to signify that is just one element, one input.

77
00:04:27,780 --> 00:04:29,430
And then we just run to predict here.

78
00:04:29,550 --> 00:04:32,160
However, I didn't update this line of code.

79
00:04:32,700 --> 00:04:34,230
So let me just changed us.

80
00:04:36,620 --> 00:04:43,640
To hear and put in is no input.

81
00:04:45,230 --> 00:04:46,040
And there we go.

82
00:04:46,250 --> 00:04:50,000
Let's run this prediction and we get the prediction out.

83
00:04:50,650 --> 00:04:54,770
The prediction for our first class that we should see, we're printing a few things here.

84
00:04:55,160 --> 00:04:57,530
We first print input ship two.

85
00:04:57,530 --> 00:05:02,620
Here, we print the input ship as a movie or ship it, we print a prediction, which is seven.

86
00:05:02,630 --> 00:05:07,250
So we think the first test is it because we think it's a seven?

87
00:05:07,580 --> 00:05:11,210
Well, not we, but the model we trained thinks it's a seven.

88
00:05:11,850 --> 00:05:14,140
We printed type type as an umpire.

89
00:05:14,870 --> 00:05:20,010
Just so you know and linked because it's one input we printed, it's going to have a length of one.

90
00:05:20,030 --> 00:05:24,410
Unlike this one, which was 10000 known, this is something cooler and fancy.

91
00:05:24,980 --> 00:05:27,800
Now, I'm not going to go through all of this code in detail.

92
00:05:28,130 --> 00:05:33,590
This is an open TV could if you want to understand it, to go through the open TV section in creating

93
00:05:33,590 --> 00:05:37,430
images, and you can see how we actually created this here.

94
00:05:38,120 --> 00:05:41,750
In fact, actually, I'll go through it a bit for you guys just because I don't want to leave out things

95
00:05:41,750 --> 00:05:42,380
in this course.

96
00:05:42,950 --> 00:05:47,840
So here's what we're doing for the first 10 images in our test dataset.

97
00:05:48,410 --> 00:05:50,720
We're going to this will not for the first 10 images.

98
00:05:51,020 --> 00:05:56,480
We're going to grab 10 random images using a random function, and we're going to just take that input.

99
00:05:57,050 --> 00:05:59,930
Then we're going to put it into open TV, which we resize it.

100
00:05:59,940 --> 00:06:01,280
That's how we're going to do split.

101
00:06:01,820 --> 00:06:04,640
The only reason we will say that we don't actually need to resize is here.

102
00:06:04,790 --> 00:06:07,730
This was, um, could I was using autopen open TV?

103
00:06:08,150 --> 00:06:10,430
We could also resize that using my lib.

104
00:06:10,790 --> 00:06:14,150
But that's well, let's leave it like this for now.

105
00:06:14,840 --> 00:06:15,170
All right.

106
00:06:15,170 --> 00:06:16,640
So this is a resize.

107
00:06:16,640 --> 00:06:17,660
We just took the image.

108
00:06:17,660 --> 00:06:22,010
Make it bigger by four times using this interpolation method.

109
00:06:22,670 --> 00:06:24,320
Then we reshape it into the shape.

110
00:06:24,470 --> 00:06:30,310
The original image shows we we shape it into the shape we wanted to input into into Paris.

111
00:06:30,860 --> 00:06:36,050
Then we have to change this line because that is deprecated now.

112
00:06:37,730 --> 00:06:40,370
So you see how fast things change in the deep learning world.

113
00:06:41,330 --> 00:06:50,930
So let's just make sure this is correct and we have rows here is a result.

114
00:06:52,070 --> 00:06:58,580
I believe this retuned an array so we could just need to get the first value out of it and we need to

115
00:06:58,580 --> 00:07:05,360
convert it into a string as well, just to be sure so that you can use it in the open TV function.

116
00:07:06,380 --> 00:07:07,850
And then we create this function here.

117
00:07:07,850 --> 00:07:09,590
Call the protests draw.

118
00:07:09,590 --> 00:07:17,420
This simply takes the result as a string and input large image that we received here and then places

119
00:07:17,510 --> 00:07:19,160
the class name next to it.

120
00:07:19,700 --> 00:07:20,900
So it's a pretty cool function.

121
00:07:21,350 --> 00:07:22,490
Let's see how we create this.

122
00:07:22,880 --> 00:07:25,010
So we just create a color block.

123
00:07:25,250 --> 00:07:32,750
That's all background we used to copy, make border function and open TV to basically create a black

124
00:07:32,750 --> 00:07:41,150
border around this image since an expanded image, and we can put it to color image as well.

125
00:07:41,690 --> 00:07:44,600
And then we just put the text from a prediction here.

126
00:07:44,660 --> 00:07:45,200
It's pretty.

127
00:07:46,010 --> 00:07:46,880
That's a result.

128
00:07:47,180 --> 00:07:54,170
Yeah, we put this into the text with cleaved to protect function, specify the color and size and where

129
00:07:54,170 --> 00:07:54,800
we want it.

130
00:07:55,250 --> 00:08:00,230
And then we just use the image of a function which we created previously at the beginning of this section,

131
00:08:00,890 --> 00:08:03,020
and we just should display the image here.

132
00:08:03,170 --> 00:08:04,250
So let's run this.

133
00:08:05,330 --> 00:08:06,830
Let's see if it works like we think it would.

134
00:08:07,430 --> 00:08:07,880
Yeah, we could.

135
00:08:07,880 --> 00:08:09,260
It's it's working as we expected it.

136
00:08:11,090 --> 00:08:11,420
All right.

137
00:08:11,420 --> 00:08:13,070
So we got our ten predictions there.

138
00:08:13,580 --> 00:08:14,600
So let's take a look at them.

139
00:08:14,720 --> 00:08:19,910
So we have the first one which doesn't even look like a six to me.

140
00:08:19,970 --> 00:08:22,630
Looks like some sort of oddly bent u.

141
00:08:23,210 --> 00:08:24,470
But it is a six.

142
00:08:24,470 --> 00:08:27,210
I'm pretty sure it's a sloppily written six.

143
00:08:27,230 --> 00:08:28,400
And it got it right.

144
00:08:28,880 --> 00:08:29,930
Got to seven right.

145
00:08:29,930 --> 00:08:31,070
Got another seven right.

146
00:08:31,190 --> 00:08:33,800
Got the one right eight to five four.

147
00:08:34,190 --> 00:08:35,420
Trigger all of these, right?

148
00:08:35,420 --> 00:08:36,320
So that's pretty cool.

149
00:08:36,980 --> 00:08:38,510
Very impressive results so far.

150
00:08:38,660 --> 00:08:39,650
Let's run this again.

151
00:08:39,680 --> 00:08:45,470
Get 10 more random images and you can see our performance later on in the next sections.

152
00:08:45,860 --> 00:08:51,080
I'll talk about how you can analyze results and take a look and see get the get the classes at your

153
00:08:51,080 --> 00:08:55,730
CNN is not performing too well, but so let's see if we got anything wrong here.

154
00:08:56,390 --> 00:08:57,530
No, we didn't.

155
00:08:57,530 --> 00:08:59,480
Although this could be a two.

156
00:08:59,480 --> 00:09:01,490
Also, it could be a six, but I think it's a six.

157
00:09:02,540 --> 00:09:04,640
So you can see here, so you've got everything right again.

158
00:09:05,540 --> 00:09:07,580
OK, so we'll sub there for now.

159
00:09:07,910 --> 00:09:10,280
I hope you enjoyed this lesson with using carrots.

160
00:09:10,280 --> 00:09:12,760
Carrots is definitely simpler to use and by touch.

161
00:09:13,160 --> 00:09:18,500
However, it's such a valuable skill in understanding how to use both carrots and by touch.

162
00:09:18,560 --> 00:09:24,020
It will be very powerful, and you'll be able to create and reduce so much like reason our research

163
00:09:24,020 --> 00:09:25,070
projects you see online.

164
00:09:25,670 --> 00:09:29,510
So I hope this lesson was was an informative for you again.

165
00:09:29,750 --> 00:09:35,270
Also, if you have any questions, feel free to ask me on the Udemy support forums and I'll try to get

166
00:09:35,270 --> 00:09:35,450
back.

167
00:09:35,530 --> 00:09:39,610
To you as soon as possible, thank you, and we'll close if A..

168
00:09:39,730 --> 00:09:44,800
But the next lesson we'll take, take a look at is misclassification, so we'll go straight into it

169
00:09:44,830 --> 00:09:49,570
doing it with Keros just because we want to carry our speeds or beard right now and we'll go back into

170
00:09:49,810 --> 00:09:56,020
into paid afterward, tell it to do some performance analysis, understand misclassification.

171
00:09:56,020 --> 00:10:01,810
And then later on, we'll take a look at regularization and would pay to watch and care us, then take

172
00:10:01,810 --> 00:10:05,470
a look at visualization of what CNN has learned and a lot more.

173
00:10:05,830 --> 00:10:09,640
So stay tuned for more lessons with carrots and pay to watch.

174
00:10:09,880 --> 00:10:11,110
I'll see you in the next section.

175
00:10:11,230 --> 00:10:11,650
Thank you.
