1
00:00:01,230 --> 00:00:02,280
Hi and welcome back.

2
00:00:02,640 --> 00:00:07,500
In this section, we'll take a look at using PyTorch to implement Google Deep Streams algorithm.

3
00:00:08,070 --> 00:00:09,060
So let's get started.

4
00:00:09,090 --> 00:00:12,930
So open notebook tricks here which are already have opened.

5
00:00:13,590 --> 00:00:14,910
And let's take a look at this.

6
00:00:14,920 --> 00:00:19,310
So in this in this vision, we're not going to use the inception network.

7
00:00:19,320 --> 00:00:20,790
We're going to try different networks.

8
00:00:20,790 --> 00:00:22,560
So let's use Figure 16.

9
00:00:23,070 --> 00:00:30,630
So let's load our model and load or libraries, as well as download our test sample image and we'll

10
00:00:30,630 --> 00:00:34,410
wait for that to be completed should be finished very shortly.

11
00:00:43,580 --> 00:00:47,810
OK, so it took a little while because video is quite a quite big network.

12
00:00:48,410 --> 00:00:49,760
So let's see.

13
00:00:49,790 --> 00:00:52,400
So test image to see one we looked at than the previous one.

14
00:00:52,700 --> 00:00:54,050
That picture in Tobago.

15
00:00:54,950 --> 00:00:58,710
So now what we do, we're going to get the outputs of Aleah.

16
00:00:58,730 --> 00:01:04,700
So to do that, we create this classical hook and then we create these functions called get gradients.

17
00:01:05,180 --> 00:01:09,980
This function makes brilliant calculations from the output channels of the target layer.

18
00:01:10,490 --> 00:01:15,980
Then we also have the D normalized normalization of the image transform into a transformer to be using,

19
00:01:16,610 --> 00:01:23,240
as well as we have the dream, which basically combines all the functions above and executes Google's

20
00:01:23,420 --> 00:01:24,860
deep dream algorithm on them.

21
00:01:25,130 --> 00:01:30,410
So like I said in the previous lesson, I'm not going to go into this code in detail because it's quite

22
00:01:30,890 --> 00:01:34,130
confusing sometimes for beginners, and it's a lot going on.

23
00:01:34,520 --> 00:01:40,250
So for now, let's just run this and remember it at a high level how it operated.

24
00:01:40,850 --> 00:01:44,810
Now we're going to run an execute of this Google deep dream here.

25
00:01:44,930 --> 00:01:45,890
So let's take a look.

26
00:01:47,000 --> 00:01:52,730
We're using the dream function that we created up here, and you can see we just generate this image

27
00:01:52,730 --> 00:01:53,540
quite quickly.

28
00:01:54,020 --> 00:01:56,090
And you get some pretty trippy effects already.

29
00:01:56,090 --> 00:02:00,290
You can see some with spirals added, some spikes, it added.

30
00:02:00,290 --> 00:02:01,250
Like, what is that?

31
00:02:01,250 --> 00:02:02,840
Like a tutorial to this rock?

32
00:02:04,550 --> 00:02:05,460
This is quite trippy.

33
00:02:05,690 --> 00:02:06,890
And then that was quite quick.

34
00:02:07,640 --> 00:02:11,120
So this is a pretty nice and quick implementation of the dream.

35
00:02:11,540 --> 00:02:16,530
It's not a high res image by any means, but you can adjust the scaling parameters as well as layer

36
00:02:16,550 --> 00:02:19,370
parameters and octaves to tweak that.

37
00:02:19,550 --> 00:02:21,860
Now let's make some improvements.

38
00:02:22,010 --> 00:02:27,470
So as you can see where the patterns we have to see, we have this, we can see the patterns have the

39
00:02:27,470 --> 00:02:28,250
same skill.

40
00:02:28,880 --> 00:02:32,180
And that's a problem because we want to get different skills in image.

41
00:02:32,600 --> 00:02:38,750
So to do this with updated prior could, but every time we resize image to a different scale.

42
00:02:38,900 --> 00:02:40,850
So that's what this court is doing here.

43
00:02:41,270 --> 00:02:44,780
It's a lot more functions and I mean a lot more lines of code going on to do this.

44
00:02:45,320 --> 00:02:48,350
So let's run this and take a look at the output.

45
00:02:50,820 --> 00:02:54,390
This will take longer, though, because we're doing different skills now.

46
00:03:03,310 --> 00:03:06,130
All right, so that's finished, and now we can visualize it.

47
00:03:06,160 --> 00:03:08,830
Let's take a look at the different octave skills.

48
00:03:23,340 --> 00:03:24,840
All right, finally, here we go.

49
00:03:24,990 --> 00:03:29,400
And you can see we've created a very, very cool, but we're trippy image.

50
00:03:29,880 --> 00:03:36,420
You can definitely see some, some reptile reptilian looking skills, something that looks like octopus

51
00:03:36,420 --> 00:03:37,950
tentacles coming out of it.

52
00:03:38,580 --> 00:03:39,300
These are weird.

53
00:03:39,300 --> 00:03:40,840
Eyes the sky.

54
00:03:40,860 --> 00:03:42,030
Let's take a look at the sky.

55
00:03:42,690 --> 00:03:45,450
Wow, you can see this little face in the background here.

56
00:03:46,290 --> 00:03:47,240
Wow, this really.

57
00:03:47,250 --> 00:03:52,320
This really did create some weird, trippy effects, so I would encourage you to mess with the parameters

58
00:03:52,320 --> 00:03:57,690
here, as well as like the octave scaling and some of the other parameters defined above.

59
00:03:58,620 --> 00:03:58,890
Yeah.

60
00:03:59,250 --> 00:04:02,520
So take a look and try and experiment on your own.

61
00:04:03,330 --> 00:04:04,950
All right, we'll stop there for now.

62
00:04:05,370 --> 00:04:09,210
I did have the code for a targeted deep dream algorithm here.

63
00:04:09,600 --> 00:04:14,340
However, it broke, it doesn't no longer works in color because of some visioning issue.

64
00:04:14,760 --> 00:04:19,830
So maybe I'll leave this code here for you guys, but maybe it would work if you toy with it or mess

65
00:04:19,830 --> 00:04:20,160
with it.

66
00:04:20,790 --> 00:04:24,000
So for now, that's it for this lesson in PI touch with deep dream.

67
00:04:24,000 --> 00:04:29,970
I hope you enjoyed it, and I hope you have fun experimenting on your images and feel free to share

68
00:04:29,970 --> 00:04:33,510
them with the rest of the students in the Udemy forum.

69
00:04:33,930 --> 00:04:34,340
Thank you.
