what's going on everybody welcome to
part 8 of the unconventional neural
network series in this part I'm just
gonna be running through the code that
I've used to create frame by frame the
frames of a deep dream so with that
let's go hang you started I'm going to
just take the code from the text base
version on the right up really none of
this code I think is necessary for us to
be writing it out so I'm not gonna do
that
also I think there's a lot of
improvements that could be made so which
I'll be asking you for momentarily so
I'm just gonna make a new file I'm gonna
call it dream on dot pi yes sir let's
edit with sublime I'm gonna close oh
this is still running that let's see how
do I stop this thing from running cancel
Biddle's good day let me just close it I
just want that's a good way for now okay
and then I'm going to copy and paste
from my sample code my code and then I
think I'll just kind of run through it
real quickly like I said this pretty
rudimentary Python so there's really no
reason to make you guys write this one
out so basically we're yeah we're
importing things just like we did before
we grab we're just gonna specify which
layer we want to work with we're gonna
call it something because yeah here
basically the dream goes into this dream
directory and then at least in dreams
start I've kind of named everything and
it should be good to go
and then in there is an image 0 now if
you're gonna work on your own dream
which again I highly recommend you do
this just makes it more interesting just
go into the dream directory make a new
one call it whatever the heck you want
and then inside it put your image which
should be a JPEG and then just call it
image underscore 0 and in my case this
image is 450 all right I'm sorry
800 wide by 450 tall image just take
note of whatever size image you have the
larger the image you have the longer is
going to take to process but the cooler
it is when it's actually done so
let's see come back over to dream on
actually it's just right in here we can
see some of my lovely lovely code
basically it right away I just specify
this size I'm there's plenty of
functions you could write to get the
image size I'm just gonna write the
freaking numbers in there but you could
dynamically grab the sizes then what
this does is it just kind of tracks how
far we are so if you let the dream go on
and on and on and on eventually it
usually gets too bright or too dark or
something goes wrong so usually you kind
of want to check on it after so many
frames you don't have to I've easily
gone thousands of frames without needing
to mess with anything it just really
kind of depends on on you and and what
your dream kind of randomly does so you
feel free to set this to whatever you
want and then this is just a for loop I
just want to grab an eye from it so this
is the way I've done it I'm sure there's
a better way this is just what I kind of
hacked together because I just really
wanted to see the results so basically
all it's going to do is it's gonna go
into the dream directory and then it
basically just looks and says okay in
this dream directory how many images do
we have all it's trying to do is figure
out what was the latest image and that's
the image we're gonna drain upon dream
upon and man lately I can't talk anyway
that's the dream image that we're gonna
start with and we're gonna let it dream
on so lovely planes going over the house
so it'll just keep going through I until
we figure out what the latest I could be
and then we're gonna load in that image
and then we're going to specify a trim
to that image now one thing I do not
like about how I'm doing this right now
is if you'll give me a moment let me
pull up the other one it's the the one
I've been working on so far it starts
with starry night but as you can see it
actually when it starts to zoom in it's
actually zooming in right to this point
I'd really like a center zoom I'd like
to be able to do that the other thing I
noticed is like it stretches out
everything except for around this point
so it's not quite what I was hoping for
so hopefully someone can come up with a
better zoom function I just wanted to do
some
to keep things moving moving along
someone get exit that I'll show the full
one pride somewhere towards the end or
I'll just upload it or something as this
one's a pretty cool one going very
specifically through the layers at a
time so anyways that's how much I want
to trim by then basically what we do is
we trim each size I believe let me just
make sure I've done that - the white
trim all the way to something - so
somewhere in there my logic is wrong I
just like I'd like to zoom into the
center someone's gonna figure that out
next as you probably noticed the when
you deep dream on an image for whatever
reason it's somewhere in that deep dream
code probably the image gets a little
darker just a little bit darker probably
because we are clipping so like if maybe
we did some sort of I don't know how
you'd do it better but it does seem to
get a little darker so each time here we
modify the are the G the B you can just
add a couple to each one all you know
all of them use a little bit more so
this would make the the image get
overall a little brighter
you could also alternatively add like
like if you wanted the image to turn
more red over time you could do
something like this that would produce a
lot of reds
if you really like the color purple you
could do reds and blues together you get
more purples probably stuff like that so
you kind of have to find the sweet spot
there I'm gonna leave it where it is for
now then you do pretty much all the
things that you've already seen before
like none of this is anything different
which is why I didn't want to write it
up and yeah the main thing here to keep
in mind is at least when you first start
number of iterations shouldn't be 15 it
probably should be 1 honestly as you get
further into the the new design you
might want to do more iterations but to
start for the first few frames you
should keep it low 1 2 3 something like
that number of repeats should always be
one you can basically each frame is a
repeat so there's no need for you to be
doing many repeats because like I said
yeah each
is the effect is effectively a repeat so
cool everything looks good
we're on layer three so I think we're
good enough to we could probably at
least a few images here I'm gonna keep
Noam iterations to three I think we're
good let's Rumble let's just run this
thing I have no idea actually I should
have checked the last video how the
video did when I ran deep dream and was
recording I have no idea if it's
screwing me up or not hopefully not I'll
find out so as that runs and his
prospects processing the image we can
start to see results are already coming
in as you get deeper as you change the
number of iterations you're gonna it's
going to take much much longer than this
and if you use a bigger image it's going
to take much much longer but what we can
do is we can begin to zoom in and as you
can already see the image is kind of
changing and really quickly actually we
can see the squares are forming so
that's pretty cool so let me see how far
at least on Windows if you're on Linux
you I think you can actually just keep
going but as you can see so this is one
way we can very slowly begin to morph
this image into into whatever we're
trying to dream about
so after you've gotten this far you know
you can probably just okay let's make
the iterations I don't know you could
probably just keep doubling it up I
would just keep going until about 20 but
all of this stuff you really could you
really could write the program to handle
for you including like brightness random
color changes the layer changes all the
stuff you can write a program to just
automatically do for you but I kind of
find it's it's kind of fun to manually
mold the model but by all means you can
definitely control overall brightness
and all that stuff and just kind of like
let a model run for a long time but
everything is so slow to make a real
true dream like the 1080p dream that
I've been working on that's been taking
like days and days and days it's just
been running and running and running so
it just takes a long long time now with
the images as small as the ones that
we've been working with it wouldn't take
necessarily as long but anyway as you
can see that's just a good way to make a
nice smooth transition from the image
into
into our little squares basically so
that's how you can make frames now in
the next tutorial I will show you all
how you can go from frames to an actual
video obviously there's a ton of
different ways that you can do it we're
going to be using Python to do it but
there's like a million ways you could
take frames and convert to videos so
anyways that's we're going to do in the
next one and then I'll show you at least
in part well I've already showed a
little bit of it but I'll show you the
rest of it probably in the or maybe not
the rest of it I don't know it's kind of
long anyways I'll show you at least how
to make videos in the next tutorial
questions comments concerns whatever
feel free to leave them below otherwise
see you in the next video