So now let's take a look at how we see of models with curves.
It's actually quite simple.
All we have to do is just take model, the model object that we trend above here.
Remember, we just use models that fit that scroll up just to remind you guys of that right here.
Model not fit.
Remember, that was the object we created with model to compile after we created all these layers in
it.
So to save it all, we have to do it as a see function built into it where we just do model of save
and we give the name.
We want to save.
So let's see if this model, if we just created.
And you can see see if there's a dot each file right here.
And you can download this as well as download or model for sentimental reasons, because it's probably
a first car CNN model that you've dreamed.
While we wait for that.
Let's move on to the lesson.
So how do we look at models that we save?
Well, it's actually quite easy again.
There's a camera's function called load model that's followed into TensorFlow.
That character models.
Part of that library.
And to do that, you just enter the path, which is here, which is a name we give it before I use 10
here because it was tiny box, but actually it's 25 in reality.
So make that change on your own.
It's a good practice to see in models like this.
Save it with the dataset name.
Maybe a description if you want.
How many epochs, if that's important for you.
Also, did you train that?
Just a good, good practice as well.
So when you load a model, you load the model and we can give it any name we want.
Previously, we were calling its model.
I tend to call it classifiers sometimes if I just want to get confused with a loaded model as opposed
to one up in training.
But it doesn't matter what name you give it, because when you we're going to use classify, I know
the loaded model that's load on model that we saved.
So now let's continue getting predictions using a, well, loaded model.
So we load the model here by running this block of code and that created that puts a model into this
classifier variable, which is basically the same as the model we used before the model object.
But now it's called classifier just because I wanted to use a different name and we used that here.
Actually, let's use let's put it in here classifier to predict, and let's show.
Let me show you what's happening.
You may have noticed it could change because I just added something here, because in Keros, the predict
classes function was deprecated, so we had to make some changes.
So we used it petered out, max.
This gives us the map, the the index of for the class name of the output that that corresponded to
the maximum probability.
So this gives us here.
So we by running classifier that predict or test, remember we'll get 10 probabilities.
Each probability is going to be the probability of that class of input.
Class B belonging to either zero one two three four five six seven.
So what the NPL AMAX function does?
It basically just tells us which of those probabilities was a maximum and returned to class.
So if it thinks it's a five, if it involved predicted that it's going to rise from probability for
five, then it's this is going to be 10 five here in infrared.
So we're running this X, which is an array that has 10000 samples.
Remember that prediction 10000 test images?
So we're going to now predict we're going to have no input, 10000 samples into our model and get the
outputs afterward.
So let's do that.
And look, we just did 10000 predictions in less than a second.
That's extremely, extremely fast inference, and that shows you how powerful the CPU's are that we
were using.
And these are low energy use that are freely available on Google Cloud.
So you can see this is the output area here.
We don't print doesn't put the entire thing.
But if you wanted to verify the length length of is 10000 as well.
Now let's see how we can actually predict an individual test image.
So we grab a test image here by indexing on the first image.
In the test datasets, we print the dimensions.
It's twenty eight by twenty one.
Remember, for us, we need to reshape that.
So we use to reshape function so we know we should put it in this year.
This is the shape we know it once we want it to be and it's one twenty or twenty one, just have the
one dimension here.
This is to signify that is just one element, one input.
And then we just run to predict here.
However, I didn't update this line of code.
So let me just changed us.
To hear and put in is no input.
And there we go.
Let's run this prediction and we get the prediction out.
The prediction for our first class that we should see, we're printing a few things here.
We first print input ship two.
Here, we print the input ship as a movie or ship it, we print a prediction, which is seven.
So we think the first test is it because we think it's a seven?
Well, not we, but the model we trained thinks it's a seven.
We printed type type as an umpire.
Just so you know and linked because it's one input we printed, it's going to have a length of one.
Unlike this one, which was 10000 known, this is something cooler and fancy.
Now, I'm not going to go through all of this code in detail.
This is an open TV could if you want to understand it, to go through the open TV section in creating
images, and you can see how we actually created this here.
In fact, actually, I'll go through it a bit for you guys just because I don't want to leave out things
in this course.
So here's what we're doing for the first 10 images in our test dataset.
We're going to this will not for the first 10 images.
We're going to grab 10 random images using a random function, and we're going to just take that input.
Then we're going to put it into open TV, which we resize it.
That's how we're going to do split.
The only reason we will say that we don't actually need to resize is here.
This was, um, could I was using autopen open TV?
We could also resize that using my lib.
But that's well, let's leave it like this for now.
All right.
So this is a resize.
We just took the image.
Make it bigger by four times using this interpolation method.
Then we reshape it into the shape.
The original image shows we we shape it into the shape we wanted to input into into Paris.
Then we have to change this line because that is deprecated now.
So you see how fast things change in the deep learning world.
So let's just make sure this is correct and we have rows here is a result.
I believe this retuned an array so we could just need to get the first value out of it and we need to
convert it into a string as well, just to be sure so that you can use it in the open TV function.
And then we create this function here.
Call the protests draw.
This simply takes the result as a string and input large image that we received here and then places
the class name next to it.
So it's a pretty cool function.
Let's see how we create this.
So we just create a color block.
That's all background we used to copy, make border function and open TV to basically create a black
border around this image since an expanded image, and we can put it to color image as well.
And then we just put the text from a prediction here.
It's pretty.
That's a result.
Yeah, we put this into the text with cleaved to protect function, specify the color and size and where
we want it.
And then we just use the image of a function which we created previously at the beginning of this section,
and we just should display the image here.
So let's run this.
Let's see if it works like we think it would.
Yeah, we could.
It's it's working as we expected it.
All right.
So we got our ten predictions there.
So let's take a look at them.
So we have the first one which doesn't even look like a six to me.
Looks like some sort of oddly bent u.
But it is a six.
I'm pretty sure it's a sloppily written six.
And it got it right.
Got to seven right.
Got another seven right.
Got the one right eight to five four.
Trigger all of these, right?
So that's pretty cool.
Very impressive results so far.
Let's run this again.
Get 10 more random images and you can see our performance later on in the next sections.
I'll talk about how you can analyze results and take a look and see get the get the classes at your
CNN is not performing too well, but so let's see if we got anything wrong here.
No, we didn't.
Although this could be a two.
Also, it could be a six, but I think it's a six.
So you can see here, so you've got everything right again.
OK, so we'll sub there for now.
I hope you enjoyed this lesson with using carrots.
Carrots is definitely simpler to use and by touch.
However, it's such a valuable skill in understanding how to use both carrots and by touch.
It will be very powerful, and you'll be able to create and reduce so much like reason our research
projects you see online.
So I hope this lesson was was an informative for you again.
Also, if you have any questions, feel free to ask me on the Udemy support forums and I'll try to get
back.
To you as soon as possible, thank you, and we'll close if A..
But the next lesson we'll take, take a look at is misclassification, so we'll go straight into it
doing it with Keros just because we want to carry our speeds or beard right now and we'll go back into
into paid afterward, tell it to do some performance analysis, understand misclassification.
And then later on, we'll take a look at regularization and would pay to watch and care us, then take
a look at visualization of what CNN has learned and a lot more.
So stay tuned for more lessons with carrots and pay to watch.
I'll see you in the next section.
Thank you.