Did you give the challenge at the end of the last video ago.
Here's the solution.
The very first thing I want to do is import the model itself.
So when I go to Caris the applications start Fiji 19 and import Fiji 19.
So up here under my import statements I'll add exactly that from Kerry's dumped applications dot Fiji
19 Fiji 16.
It's just a different model that we're gonna go with 19 and we're going to import Fiji 19 but not only
will we import Fiji 19 we're also gonna have to pre process the data for v g g 19.
So we're going to import from Carrier stance applications thought Fiji 19 import pre process underscore
input.
This one is actually going to be different from this one.
This was the first trick to solving this challenge and in order to not have a duplication with the names
and in order to have a separate name for both of these and when to import this one as pre process underscore
input on a score Fiji 19 out shift enter on this then I'll come down and I'm very very lazily going
to copy the cell and copy this function and add another cell below pasted in.
Change the name of it.
Call it Vejjajiva 19 and then what I'll do is I'll change this target size because the Fiji 19 model
assumes a different default resolution.
Let's check what that is according to the documentation.
And here we see that it's two hundred and twenty four by two hundred and twenty four.
So those are the numbers I want to put in here.
Make our lives easy.
And then the other thing I have to do is I have to not pre process input which was the name for Inception
resonates method I'm going to use pre process underscore input underscore Fiji 19.
So this is what I want to use for this model.
So let's shift enter on this.
Then I'm gonna come down here and I want to load our model so check it out.
Fiji 19 and then the scroll model is equal to Fiji 19 and which arguments rules.
Looking at the documentation I can actually see that the default here is image net.
So even if I leave this completely blank I'm going to get the image net weights.
If I hit shift enter I'll see that it's downloading the data and it's downloading the weights.
This don't H5 file and after it's done it's going to stop spinning here and I can go to the next cell
and make a prediction.
Let's try it out.
Data is equal to format on a image and a score PDG 19 and I'm going to give it the file number three.
Try that then we can write pred is equal to Fiji nineteen underscore model not predict parentheses data.
So this will be our prediction.
Now all we need to do is decode our predictions but we shouldn't actually use decode underscore predictions
here because this function was associated with our resonant model.
So once again we're gonna say from Kerry's thought applications thought Fiji 19 import decode predictions
as decode underscore Fiji 19.
We're going to give it a different name and when to import this function from this module here.
That way we can be sure that the logic matches someone had shift enter on this scroll back down and
I'm going to add one very quick line here to display our image with this play parentheses load underscore
image parentheses file and a score three and then here I can decode and what will I decode.
Well the prediction that we've gotten from our model.
So let's take a very quick look and what we see here are some pretty interesting predictions right.
The top prediction is actually submarine for this picture and that's worth about 17 percent.
The second prediction breakwater with 12 and a half percent is actually what this truly is.
But I can if I squint kind of see the submarine in this picture but it's very interesting that the error
that a human would make looking at this kind of very quickly it's very similar to what the neural network
is actually making here so I hope you were able to solve this challenge.
The idea really was to practice using the documentation practice pre processing the data and making
sure that you're comfortable using a different model as well.
Because if you know how to use the e.g. 19 model and the inception resonant model then none of the others
should really pose a problem as well.
Now I've actually included a couple of images here where I found the models to struggle a little bit
so I could tell you what those are so that you can see this for yourself and I'll just copy and paste
this code here and I'll replace this with single quotes 0 6 feet dot j peg a hand if I take this here.
Copy it pasted down here and hit shift enter.
You'll see what I mean.
So I've got a picture here of two hands holding some baby's feet and are e.g. 19 model predicts that
this is a burrito with close to 36 percent accuracy we can take a look at what Inception Resnick thinks
about this by coming up here adding the single quotes and adding 0 6 feet Doc j peg here.
Let's see what we get in this case.
There's a few more baby related things diaper.
I totally see the diaper but I assume it's there and then it's picking up on this basket and this towel
here which I think is very interesting.
But one thing you'll notice is that the classifier is not really confident on any of these classifications.
If you look at 9 percent 7 percent 5 percent accuracy it's not really sure.
So it's kind of struggling with this one.
Another really interesting one is actually the horse.
So 0 for horse if I put that here and if I put that here as well it looks like so.
So we've got some meadow and a white horse and the image classifier Inception is picking up on this
kind of leaf here sorrel and it also seems to think that the animal in question here is a ram presumably
because it's very very white and it's got these very pointy is at the top.
So this is another good example of the classifier getting things not quite right or presumably so because
I'm not really sure what kind of leaf is in the foreground here but let's see what Eugene 19 thinks
of this.
So 0 four horse 0 for horse let's go for it.
Here we've got ram with 73 percent probability.
So what's our takeaway from this.
Well image classifiers even with the pre trained weights are not going to be 100 percent accurate but
what's a good level of accuracy anyhow.
What's kind of the state of the art level of accuracy on image classification.
Well in 2017 Google actually released a really nice blog piece on its classifier that it used to train
on image net's database.
And this classifier was actually called Nas net which you've got under a crisis available and models
here.
And what Google did was a train this nascent model on approximately a million images and 60000 GP few
hours and in the end on their validation data set.
So when they were testing out their model they got about eighty two and a half percent accuracy for
images that this model hasn't seen before.
Right.
So this is kind of the lay of the land.
We've got very sophisticated models that are around 80 85 percent accurate for these kind of tasks.
Now mind you the task here is actually very hard right.
Because if you imagine we've been classifying things in our spam filter we've just two classes and in
the next project we'll be classifying them on 10 different types of things.
But in this case we've got thousands and thousands of different things that the image classifier is
meant to detect in an image.
And this is a much much harder job.
Of course so I hope in this module you've got a good idea of how to access some pre train models and
how to access their weights.
You should have also got an idea of what it takes to really train a model to classify among thousands
and thousands of different kinds of objects.
And what kind of resources that would entail with that in mind pre train models really are a fantastic
shortcut because it allows us to build on work that others have already done and we've covered in a
bit of detail how specific the neural networks are in how they expect to receive their inputs.
So it's very important to deliver a neural network the input data in a format that it understands and
it expects to receive.
And what we've seen is that different models expect to receive this kind of data in different ways.
And we've also seen how image data is generally represented for a neural network and finally we've also
learned a little bit about tensor flow and carers themselves.
So for example this includes the graph intensive load that groups together the different calculations.
And I think this really leaves a really good spot because we scratched the surface and now we can go
one layer deeper pun intended in the next module we're going to be building our own image classifier
from scratch.
I'm already looking forward to seeing you there.
Take care.