Hi, this is Jeff Heaton. This is a quick video to show you how you can generate
very realistic-looking human faces using nVidia style GANs. Now you don't need a
fancy GPU, you just need to be able to log into Google CoLab and use your
Google Drive. I'm going to show you the process to do this and it won't take
very long. These faces that you see flashing before you are all created
using pre-trained weights that you can download from nVidia and if you'd like
to see other videos like this on topics such as artificial intelligence please
subscribe to my YouTube channel by clicking the SUBSCRIBE button and the
BELL that will notify you of every video that comes out, thank you. Normally when
you build a GAN, completely from scratch, you have to train them and they
slowly learn to build images over time, unless you've got serious compute power
this can take a long time to really get something that will create
photorealistic faces for you. By downloading these pre-trained neural
networks, you're able to quickly create these kind of faces. Let's see how to do
this. So you can find your way into Google CoLab, just by searching for it with
Google. They give you a variety of options here. Probably the quickest way
to do this is just to download my Jupiter Notebook from GitHub so if you
click on github here so if you click on github type Jeff Heaton which is my name
and search it should find me it gives you several of my repositories here I've
got a number of these the one that you want is Jeff Dean present because that's
from my presentations click on that and you can scroll down and find YouTube
YouTube style gain so click on that one and this shows you how to generate
high-res faces using google Colette let's go ahead and click on run time and
do change run time type make sure that you've got the GPU this is an Nvidia
project so naturally you've got to use a GPU or it it simply won't work now what
you need to do I've got all the steps here you can mostly just run these but
I'm gonna explain what they actually do if you run this part that is going to
mount your G Drive all you're going to really do with your G Drive is store the
generated images that you create to their so I'm gonna click run and run
that yeah we know it's not authored by Google but hey it was authored by me so
run anyway and yes that little spinning thing there tells you the Google Drive
is starting to be connected now they do want an authorization code if you click
on the URL that they provide you here you'll have to pick the account that you
want link to this and give it the permissions that it requests then you
copy this little code go back to your notebook paste this into here and now
your G Drive is connected it's mounted at a Content Drive now we're going to
clone style gaen from github what this does is this creates a copy of style
gained in that content drive now this is very important in google colab only
things connected to your Google Drive are going to actually remain things that
you put off in the file system elsewhere like here are going to go away but
that's ok you'll have to run through these steps each time you you do this
but just be aware that they will delete things from you you're you're
temporarily using a space in the cloud if I list that directory you can see the
contents of style gaen downloaded into your into your instance here now since
we've just downloaded style gaen normally this is where you do pip
install but you can't do pick installed style gain because NVIDIA has not
released it to this point so this adds it to the path and then we see that we
can import it so if you if you haven't done the previous step this will
probably give you an error but you basically have it here now this is the
code that I copied from the Nvidia site this URL that you have here this is
where it's going to basically download your pre-trained network that knows how
to generate these faces for you now Google Drive does have quota limits so
you'll sometimes get an error when you try to run this we'll see if we get that
or not now here this is the important part this generate image basically what
again does it takes a random seed value and
generates a face for it you could put in whatever number you wanted there and you
would get a consistent face if you leave it empty you're just going to get
whatever random one happens to pop up it will generate the image and then we'll
save it notice that I am saving it right here
now I had a folder called images you might want to just put it into the root
of your g-drive so you you could do that you can name it example 1 2 3 whatever
you want you can run this as many times as you want now we run it it's spinning
around this does not take much time to generate one this does use the GPU ah
you do get the quota exceeded this is a common problem with this because there's
all these people trying to use the shared link that you have here let me
show you just how to quickly fix that because that can be that can be a little
frustrating so just search for style Dan you'll go to invidious style gain and
github and down here they show you resources this is their Google Drive
folder this is where you're trying to download it from this network's folder
that they have here is where the pre-training networks are this is the
key one that you want so what you want to do this is kind of a trick to how to
get around quota limits in in Google we are going to add this to my drive now I
can go to my own Google Drive and this is where they copied it to I'm gonna
right-click this get a shareable link copy that go back to here now you can't
just paste it right in if you do that takes you to a download page which is
not what not what they want to see so you need to copy just this ID value
put that in there then they'll download remove this one here now you can't use
that link because that's just that temporary one that I set up
I won't leave that available go ahead and click run now now it's running not
downloading from your G Drive rather than the highly overworked in video one
it's taking a little bit longer because it's actually starting to run it has to
download that for the first time now there's the trained network from Nvidia
quite a big network and it's done so it has now generated your file now your
file was this example one not PNG if we go back to my Google Drive example one
PNG there it is just double-click it that is the face that it just generated
completely random thank you for watching this video if you'd like to see more
about Gans and in particular how to use them with Google collab and pre-trained
cans subscribe to my channel and click the like button because that lets me
know that this is something that you're interested in thank you very much