And welcome back in this section, we'll take a look at loading a deep love diffusion tree model in
PyTorch and running some inferences on it.
So let's get started.
So firstly, just make sure you're using the GPU.
You can always check that if you use selected here in notebook settings.
Now what we're going to do, we're going to load a deep love for each and every model.
It offers many different backbones and in one we're going to use is your resonant 50 resonant 50 would
probably give us some good results.
However, inferencing will be much faster with mobile.
That we tree but definitely slower would resonate one to one because that's a deeper network by double,
actually because it's hundred and one layers versus 50 layers.
So we're going to look to pre-trained model here.
All right.
And you can always retrain this model using similar methodology that we looked at in previous PyTorch
lessons.
But transfer learning, however, we're not going to do that here.
So what do we do?
We load the network here by running this line, and we unfortunately, we have to use this watch hub
setting to hear this.
Remember, just take a note of that.
It's not too important that you understand what that does.
I've already run this, but didn't need to do it again.
But you know, either way, it prints out the deep lab network structure, which is quite deep and quite
confusing a bit.
But actually, it's not that confusing, to be fair.
But anyway, it's here now what we'll do with a loaded test image here.
So we just download this from the deep love from the Pie Torch Test Image Library.
So to that, no, actually, I didn't need to do it because I've run it before.
And next what we're going to do, we're going to pre-processed that image and convert it into a tensor
and so that we can run inferences on it.
So remember, we have to use our transforms, we have to load it and complete the two R.G. before we
do that and we run it through the pre-processed function here.
So we apply our transforms.
This is this image net normalization criteria to mean and standard deviation for the RGV channels.
And then we have to create a mini batch as expected by the model.
So we just unscrew is the format the data correctly?
And if could is available, meaning if there's a GPU available, we move that to the GPU.
That means that being the terms of the image and then now we can run inferences here.
So we just would torch no bread.
We just put the input batch in and get OK, but predictions.
So this takes about nine seconds to run.
And in the end, we get actually, let's run it again and we can this we can print out the output predictions,
even though it's not going to make much sense.
It's because the image looks.
Around that line, a room or a school.
OK, so you see you get a tensor output, basically an image, isn't it?
So I didn't find a ship, but you can you kind of can see that it's a big array.
And that bigger it means that we're getting pixel level class predictions.
So this was the original image here, but it's a large image.
You can see it's a woman with some sheep and a sheep dog as well.
So what we do to display the jubilee, the predictions for overlaying the predictions, we're just going
to view the predictions.
We need to create a color palette here.
So this isn't a code that creates a color palette for our predictions.
And then we just take we will just do.
This should add that there are 21 classes in this free 20 plus model.
So we just actually know we put the palette onto the predictions.
That was the output predictions that we generated previously, and then we could use MATLAB to visualize
it.
So you can see this is what type lab predictions that clock zero being the background class.
So that's black in this case, then you can see the ship being predicted accurately here, all in one
color.
The lady here, she's totally correctly labeled as well.
However, if you remember correctly, there was a ship dock right here and he is no longer there.
He's of the same class as a ship, so I'm not entirely sure if Doug is a class in the steeply operating
model.
Maybe it is.
Maybe it isn't.
And either way, they're going to it wrong.
Maybe.
Maybe if it was one class, maybe it would have gotten it in two different classes.
Maybe it would have gotten it correct.
Maybe it's one class in the dataset.
Now you can see here some notes that you should see what the different Pixel accuracy's and I'll use
for the different backbones in mobile and deep love.
You can see the resonant one on one, as expected, gets the best results, but not by a lot.
So you can see the 50 is probably a good compromise.
If you need to lower speed limits of mobile or embedded system, then you can use this vision here.
So that's it for this deep love vision tree in PyTorch implementation.
Next, we'll take a look at some CNN NASCAR season, and I should say I should relabel that demo.
Basically going to load Hamas are CNN and run this.
So stay tuned for that lesson.
Thank you for watching.
Will see you in the next cross section by.