Hi and welcome back.
In this section, we'll take a look at using PyTorch to implement Google Deep Streams algorithm.
So let's get started.
So open notebook tricks here which are already have opened.
And let's take a look at this.
So in this in this vision, we're not going to use the inception network.
We're going to try different networks.
So let's use Figure 16.
So let's load our model and load or libraries, as well as download our test sample image and we'll
wait for that to be completed should be finished very shortly.
OK, so it took a little while because video is quite a quite big network.
So let's see.
So test image to see one we looked at than the previous one.
That picture in Tobago.
So now what we do, we're going to get the outputs of Aleah.
So to do that, we create this classical hook and then we create these functions called get gradients.
This function makes brilliant calculations from the output channels of the target layer.
Then we also have the D normalized normalization of the image transform into a transformer to be using,
as well as we have the dream, which basically combines all the functions above and executes Google's
deep dream algorithm on them.
So like I said in the previous lesson, I'm not going to go into this code in detail because it's quite
confusing sometimes for beginners, and it's a lot going on.
So for now, let's just run this and remember it at a high level how it operated.
Now we're going to run an execute of this Google deep dream here.
So let's take a look.
We're using the dream function that we created up here, and you can see we just generate this image
quite quickly.
And you get some pretty trippy effects already.
You can see some with spirals added, some spikes, it added.
Like, what is that?
Like a tutorial to this rock?
This is quite trippy.
And then that was quite quick.
So this is a pretty nice and quick implementation of the dream.
It's not a high res image by any means, but you can adjust the scaling parameters as well as layer
parameters and octaves to tweak that.
Now let's make some improvements.
So as you can see where the patterns we have to see, we have this, we can see the patterns have the
same skill.
And that's a problem because we want to get different skills in image.
So to do this with updated prior could, but every time we resize image to a different scale.
So that's what this court is doing here.
It's a lot more functions and I mean a lot more lines of code going on to do this.
So let's run this and take a look at the output.
This will take longer, though, because we're doing different skills now.
All right, so that's finished, and now we can visualize it.
Let's take a look at the different octave skills.
All right, finally, here we go.
And you can see we've created a very, very cool, but we're trippy image.
You can definitely see some, some reptile reptilian looking skills, something that looks like octopus
tentacles coming out of it.
These are weird.
Eyes the sky.
Let's take a look at the sky.
Wow, you can see this little face in the background here.
Wow, this really.
This really did create some weird, trippy effects, so I would encourage you to mess with the parameters
here, as well as like the octave scaling and some of the other parameters defined above.
Yeah.
So take a look and try and experiment on your own.
All right, we'll stop there for now.
I did have the code for a targeted deep dream algorithm here.
However, it broke, it doesn't no longer works in color because of some visioning issue.
So maybe I'll leave this code here for you guys, but maybe it would work if you toy with it or mess
with it.
So for now, that's it for this lesson in PI touch with deep dream.
I hope you enjoyed it, and I hope you have fun experimenting on your images and feel free to share
them with the rest of the students in the Udemy forum.
Thank you.