1
00:00:00,570 --> 00:00:06,780
And welcome back in this section, we'll take a look at loading a deep love diffusion tree model in

2
00:00:06,790 --> 00:00:10,140
PyTorch and running some inferences on it.

3
00:00:10,800 --> 00:00:12,240
So let's get started.

4
00:00:12,450 --> 00:00:15,210
So firstly, just make sure you're using the GPU.

5
00:00:15,270 --> 00:00:19,440
You can always check that if you use selected here in notebook settings.

6
00:00:20,400 --> 00:00:24,960
Now what we're going to do, we're going to load a deep love for each and every model.

7
00:00:25,320 --> 00:00:31,410
It offers many different backbones and in one we're going to use is your resonant 50 resonant 50 would

8
00:00:31,410 --> 00:00:32,930
probably give us some good results.

9
00:00:32,940 --> 00:00:36,430
However, inferencing will be much faster with mobile.

10
00:00:36,450 --> 00:00:43,050
That we tree but definitely slower would resonate one to one because that's a deeper network by double,

11
00:00:43,050 --> 00:00:46,590
actually because it's hundred and one layers versus 50 layers.

12
00:00:47,250 --> 00:00:51,720
So we're going to look to pre-trained model here.

13
00:00:52,260 --> 00:00:52,620
All right.

14
00:00:52,890 --> 00:00:59,580
And you can always retrain this model using similar methodology that we looked at in previous PyTorch

15
00:00:59,580 --> 00:01:00,000
lessons.

16
00:01:00,000 --> 00:01:03,210
But transfer learning, however, we're not going to do that here.

17
00:01:03,810 --> 00:01:05,100
So what do we do?

18
00:01:06,120 --> 00:01:12,150
We load the network here by running this line, and we unfortunately, we have to use this watch hub

19
00:01:12,900 --> 00:01:14,400
setting to hear this.

20
00:01:14,430 --> 00:01:16,140
Remember, just take a note of that.

21
00:01:16,140 --> 00:01:18,750
It's not too important that you understand what that does.

22
00:01:19,560 --> 00:01:22,350
I've already run this, but didn't need to do it again.

23
00:01:22,650 --> 00:01:29,520
But you know, either way, it prints out the deep lab network structure, which is quite deep and quite

24
00:01:29,520 --> 00:01:30,480
confusing a bit.

25
00:01:31,050 --> 00:01:33,240
But actually, it's not that confusing, to be fair.

26
00:01:33,570 --> 00:01:38,730
But anyway, it's here now what we'll do with a loaded test image here.

27
00:01:38,740 --> 00:01:42,840
So we just download this from the deep love from the Pie Torch Test Image Library.

28
00:01:42,990 --> 00:01:47,400
So to that, no, actually, I didn't need to do it because I've run it before.

29
00:01:48,060 --> 00:01:52,950
And next what we're going to do, we're going to pre-processed that image and convert it into a tensor

30
00:01:53,460 --> 00:01:55,440
and so that we can run inferences on it.

31
00:01:55,950 --> 00:02:02,460
So remember, we have to use our transforms, we have to load it and complete the two R.G. before we

32
00:02:02,460 --> 00:02:05,580
do that and we run it through the pre-processed function here.

33
00:02:06,240 --> 00:02:08,160
So we apply our transforms.

34
00:02:08,160 --> 00:02:15,420
This is this image net normalization criteria to mean and standard deviation for the RGV channels.

35
00:02:16,320 --> 00:02:19,440
And then we have to create a mini batch as expected by the model.

36
00:02:19,440 --> 00:02:23,020
So we just unscrew is the format the data correctly?

37
00:02:23,610 --> 00:02:29,820
And if could is available, meaning if there's a GPU available, we move that to the GPU.

38
00:02:29,850 --> 00:02:35,820
That means that being the terms of the image and then now we can run inferences here.

39
00:02:36,360 --> 00:02:38,190
So we just would torch no bread.

40
00:02:38,280 --> 00:02:42,450
We just put the input batch in and get OK, but predictions.

41
00:02:42,930 --> 00:02:45,300
So this takes about nine seconds to run.

42
00:02:45,960 --> 00:02:53,970
And in the end, we get actually, let's run it again and we can this we can print out the output predictions,

43
00:02:53,970 --> 00:02:56,640
even though it's not going to make much sense.

44
00:02:56,820 --> 00:02:59,160
It's because the image looks.

45
00:03:01,280 --> 00:03:05,450
Around that line, a room or a school.

46
00:03:07,400 --> 00:03:13,250
OK, so you see you get a tensor output, basically an image, isn't it?

47
00:03:14,000 --> 00:03:18,180
So I didn't find a ship, but you can you kind of can see that it's a big array.

48
00:03:18,440 --> 00:03:22,400
And that bigger it means that we're getting pixel level class predictions.

49
00:03:22,970 --> 00:03:26,750
So this was the original image here, but it's a large image.

50
00:03:26,870 --> 00:03:31,040
You can see it's a woman with some sheep and a sheep dog as well.

51
00:03:31,940 --> 00:03:38,420
So what we do to display the jubilee, the predictions for overlaying the predictions, we're just going

52
00:03:38,420 --> 00:03:39,530
to view the predictions.

53
00:03:40,070 --> 00:03:42,320
We need to create a color palette here.

54
00:03:42,320 --> 00:03:46,640
So this isn't a code that creates a color palette for our predictions.

55
00:03:46,640 --> 00:03:49,820
And then we just take we will just do.

56
00:03:50,000 --> 00:03:55,430
This should add that there are 21 classes in this free 20 plus model.

57
00:03:56,180 --> 00:04:01,490
So we just actually know we put the palette onto the predictions.

58
00:04:01,490 --> 00:04:07,370
That was the output predictions that we generated previously, and then we could use MATLAB to visualize

59
00:04:07,370 --> 00:04:07,580
it.

60
00:04:07,670 --> 00:04:13,930
So you can see this is what type lab predictions that clock zero being the background class.

61
00:04:13,940 --> 00:04:20,210
So that's black in this case, then you can see the ship being predicted accurately here, all in one

62
00:04:20,210 --> 00:04:20,630
color.

63
00:04:21,110 --> 00:04:24,800
The lady here, she's totally correctly labeled as well.

64
00:04:25,310 --> 00:04:30,690
However, if you remember correctly, there was a ship dock right here and he is no longer there.

65
00:04:30,710 --> 00:04:37,240
He's of the same class as a ship, so I'm not entirely sure if Doug is a class in the steeply operating

66
00:04:37,250 --> 00:04:37,610
model.

67
00:04:38,180 --> 00:04:38,720
Maybe it is.

68
00:04:38,720 --> 00:04:39,440
Maybe it isn't.

69
00:04:39,590 --> 00:04:43,160
And either way, they're going to it wrong.

70
00:04:43,770 --> 00:04:44,200
Maybe.

71
00:04:44,450 --> 00:04:48,110
Maybe if it was one class, maybe it would have gotten it in two different classes.

72
00:04:48,110 --> 00:04:49,870
Maybe it would have gotten it correct.

73
00:04:49,880 --> 00:04:52,100
Maybe it's one class in the dataset.

74
00:04:52,820 --> 00:05:01,490
Now you can see here some notes that you should see what the different Pixel accuracy's and I'll use

75
00:05:01,970 --> 00:05:05,120
for the different backbones in mobile and deep love.

76
00:05:05,600 --> 00:05:10,340
You can see the resonant one on one, as expected, gets the best results, but not by a lot.

77
00:05:10,940 --> 00:05:13,100
So you can see the 50 is probably a good compromise.

78
00:05:13,790 --> 00:05:19,070
If you need to lower speed limits of mobile or embedded system, then you can use this vision here.

79
00:05:19,760 --> 00:05:25,640
So that's it for this deep love vision tree in PyTorch implementation.

80
00:05:25,730 --> 00:05:33,940
Next, we'll take a look at some CNN NASCAR season, and I should say I should relabel that demo.

81
00:05:34,280 --> 00:05:37,580
Basically going to load Hamas are CNN and run this.

82
00:05:38,270 --> 00:05:39,920
So stay tuned for that lesson.

83
00:05:39,920 --> 00:05:40,880
Thank you for watching.

84
00:05:42,020 --> 00:05:44,690
Will see you in the next cross section by.
