How to Easily Use AI to Generate AMAZING Images [VQGAN+CLIP]

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello and welcome today i'm going to be showing you how to use vqgan and clip to generate images based on a text prompt my purpose of this video is to show you very simply how to make these uh interesting videos and images that you've probably seen all over uh in the simplest way possible there's no need for coding experience or anything of the sort it literally takes one google search and i will show you that now if you go into google and type in vqgan plus clip search that up and the first link you should get is introduction to vqgan plus clip sourceful click on that open it up you're gonna be brought to this webpage with a google doc this google doc gives you a lot of information about the google cloud lab that we're going to be using which i will get to in a second right here catherine crossin has authored this as well as a bunch of other people and it has been remodified and modified multiple times but today we have this link right here for this google collab and if we open it up it will bring us here uh firstly uh google colab is not something that will be using any of your gpu or memory from your machine it is entirely online and free to use which is what makes this so amazing you can run all this code from your desktop or any other browser i ran it on my phone even the other day and it worked just as well what you're going to want to do is firstly you should read over this google doc that i just showed uh this has a very great guide on how this works and what all the parameters are and it's also a great reference sheet for if you get lost and how to go back and fix issues that you might have this google collab includes google drive integration which will use your google drive for outputs to save directly to we're not going to be doing that because i would rather just run it and then save it to my computer rather than a google drive but if this is something that interests you it has information about how to do this on the google doc as well as here but since we're not going to be doing that what we're going to be doing instead is right clicking and going to delete cell for both these two cells here what that's going to do is just completely remove them from the equation so that when we want to finally run our program it won't have to go through there and it will take forever because it will not have an input since we're not using it so firstly the models these are the libraries of images that it uses you can change this and what you want to do if you want to change it is deselect the default one and reselect any one that you want for my purposes i'm just going to be using the default one imagenet16384 uh if you wanted to change that we'll get to that in a second but for now what we can do to get started is to run these four once you've selected your model that you're gonna use go ahead and click the play button right here then go ahead and click run anyway and then you can click on the next cell and it will queue up to run immediately after the previous cell is finished this cell is in style it excuse me installing libraries that will it will use for the ai to generate our images and this will take a second but as i said we can click the next cell to run immediately after these are finished so we're going to do that for all of these up until implementation tools what these are is all of the parameters and uh different things you can do with the image for it to generate firstly we have the most important parameter which is the prompt we're going to give the ai to generate an image from so this could be anything you want uh i'm feeling kind of like i want to see some mountains next we have width and height this will determine the size of the image we generate in pixels the google doc has a good explanation for aspect ratios and resizing personally i have had troubles with this to uh and changing it so i would recommend for your first time just leaving it at five twelve by five twelve this will generate a square image but if you would like you can always change this but be careful because making the image too large will cause a cuda error meaning that you run out of space and it will not load because there is not enough space on the machine you're using from google collab to run the program and load the image so we're going to be leaving this as is next is the model as i was talking about earlier you would change this to whatever model you have selected previously up here as i said we're using imagenet16384 so the model has been selected as imagenet16384. next is the display frequency and what this is is every iteration which is uh imagine it as a step the ai is taking currently we have it selected so every 50 iterations or steps it will print the image and it will show it to you what it looks like this is very helpful for if you want a still image generation you might want to set this lower as well as just getting a good idea of what it's looking like as it generates next we have initial image and target image personally i have not gotten these to work yet i've tried a multitude of things but presumably you would use this as an image the ai would start with and an image that you want the ai to finish on again i have not gotten this to work yet if someone does know how to make this work please let me know i would be very grateful next we have the seed what this is is essentially a number that is telling the computer what path it's taking as it generates the image so currently it is set to negative one and what that will do is generate a new random seed every time we generate the image you might use this for if you want to recreate an image for some reason or if you need specific different iterations of an image you would use this but for our purposes we're just gonna leave it as is on negative one next we have max iterations and as i spoke about before for display frequency this is the maximum number of iterations or steps that the ai will take before it finishes running personally i like to leave it at negative 1 which will run it indefinitely until we manually stop it from running this is up to you and however much space you were given by google collab to use personally i found the sweet spot around 500 iterations is usually when you get a very clean good looking image and also have time to generate a video from it but i have also been able to run the ai for almost 2 000 iterations and generate a video for it with no problems so it's really up to you and what you're doing for now we're going gonna leave it at negative one so now that we're done with all our parameters what we're gonna do is go over here to this little play button again and hit play it should only take half a second there you go you get a little check mark saying it's done and then we're gonna move on to the fun part execution so go ahead and click the little play button there it's gonna load everything in including our library and models and then it will start generating our images so i will get back to you as soon as it is done generating our first image all right so here we go we have our very first iteration uh as you can see it is an amorphous blob of pale color and various specks and dots around it this is essentially our seed that we have selected that it will use to generate the image if i'm wrong please correct me but this is the very first iteration now as you can see up here we have a very nice little loading bar right here that will show us what iteration we're on and if we look over here we can see what iteration each one of the printed images is so as we can see here this is iteration zero and as we have talked about earlier we have selected that it will print an image every 50 iterations so we're about to come up on 50 iterations right now we're at 45 at the moment and as you can see it runs pretty quickly and there we go so what we're going to do ah very beautiful look at that that's so interesting very pretty we got definitely what we asked for which was mountainside snowy cliff face definitely see some mountains here some sort of uh indents in the snow for sure and definitely a lot of white like we have asked it for and again we can look right here and this will tell us what iteration this printed image is and we can see that this is iteration 50. and if we look back up here we can see we are on iteration 80. moving towards 100 where it will print another image so i'll get back to you then all right here we go we have just hit iterate iteration 100 and let's see the result all right looking good there's a lot more yellow in it now but it's definitely taking shape here as the mountain formations are coming along so what i'm going to do is let this run for a little while and then i will explain how to generate a video with the result and stop the machine from running so i'll get back to you at iteration 500. so i know i said i would stop at aeration 500 here we are at 250. here are the results every 50 iterations it's looking great but for my tastes i feel like it's not as interesting as it could be my selection of a prompt probably wasn't that great to give it something that is mostly just white snow however we can definitely see some snow texture here and some mountain range peeking out from some snow as well over here so definitely got what we asked for so what we're gonna do once we're done with this we're gonna go over here to the top where it says run time select that and then go down to interrupt execution and there we go we have stopped the execution here and it's completed and we have finished at iteration 280. so now that we're done you can go down and select any of these images that you've generated right click on them and save them if you want if that's what you want or we could go down here and generate a video with the results so to do that we're gonna go over here to these two little brackets and click this little play button and what's that what that is going to do is take all of our uh iterations put them together nice and neat into a video format all right our video is finished loading and it is currently compressing it almost done there we go finished so these next two cells are to view the video in the browser or to download the video you can do either one or both i'm going to load it in the browser so i'm going to hit play on new video in browser and there we go we have the video here let's take a look very beautiful very beautiful very happy with this result uh even if it wasn't the most interesting in the world but very happy nonetheless next what we're going to want to do if you want to download this video you're going to go and click this button right here and there it goes it's going to give you a little loading bar and there we go it has downloaded you can move this wherever obviously you now have it on your computer so what we're gonna do after this we are completely done with everything you've saved your video i'm going to go ahead and close this for now once we're done if you want to start a new render the way google collab works is you only have a certain amount of disk space so what we're going to do is click this little tab up here and view resources so as you can see we have just about reached our maximum disk space right here as the green goes into a yellow line and our ram usage is fine but since we are almost out of disk space to use we will not have enough room to generate another image using the same session so what we're going to want to do to start a new session is go down here to manage sessions go ahead and click that and open it up and as you can see ram used we've almost used two gigabytes of ram and we've used 14 gigabytes of gpu so now that we have completed our rendering what we're going to want to do is go over here and click terminate there we go no active sessions once we're done with that you can go ahead and refresh the page click reload and there you go you have a completely new fresh google collab page ready to be used again you can do the same steps over again with different prompts everything else and that should be it thank you so much for watching i hope you enjoyed and i hope you learned something i hope this helped you out that was my intention uh if you have any questions let me know however i am no expert and i would prefer answers be in the comments more than questions because i have a multitude of them and i'm sure i have gotten a lot of these things incorrect and i would love someone to correct me so i could get them correct next time thank you so much for watching again and goodbye foreign
Info
Channel: Mild Fractal
Views: 68,878
Rating: undefined out of 5
Keywords: vqgan, clip, ai, ai image generation
Id: 8hnZmtqi-YE
Channel Id: undefined
Length: 17min 59sec (1079 seconds)
Published: Mon Jul 26 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.