Create AI Images Of Yourself for Free: DreamBooth & Stable Diffusion

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
what if I told you every single one of these images had a secret the secret is none of these are real that's right every single one of these images was generated using artificial intelligence specifically with stable diffusion today I'm going to show you how you can build your own AI model you can train it using stable diffusion and then you can use it to generate an unlimited number of images just like this let's jump right into it all right we're not going to mess around because I know you're excited to get started testing this out we're going to use is something from Google called dream Booth I'm going to drop a link to this down in the description below because it's a long URL so just go ahead and grab that and get started the first thing we're going to do when we come here is we're going to click this run button it's going to let you know that this notebook was not authored by Google it was authored by a third party go ahead and click run anyway this is going to check the GPU and vram this is basically connecting to Google cloud and setting up one of their Nvidia Tesla gpus to train the model with again this is free so just go ahead and get this going as soon as that's done you're going to kind of just follow this from top to bottom so you're going to go here and install the requirements it's going to install Python and everything else that you need in order to build this stable diffusion model this is going to take just a couple minutes for the next step we're going to log into a place called hugging face hugging face is a community that has a bunch of information and models about artificial intelligence so we want to do is we're going to click this link to the model card that'll open up this page now the first time you come here there is going to be a check box somewhere on the page for you to accept their terms go ahead and click that you also need to sign up for again a free account you can use your Google address your Google email address to just connect via oauth and once you've done both of those things you're going to need an access token so if you go up to the upper right hand corner you can click this and you can go to settings once you're in settings you're going to see this section for Access tokens click on that and then you're gonna the first time you come in here you're gonna click generate new token so just click new token and then it's going to provide this access token you can go over here and click on the copy token to clipboard we're going to need that for the next step this is just going to give API access over to hugging face so that dream Booth is able to pull some data from their system to train your model so now we're going to go here and just where it says hugging face token we're going to right click and paste in our hugging face token by now the above step should be done it takes about a minute we're going to go ahead and click play on this run cell now for this next section is settings and run this allows you to save the model directly to your Google Drive which is super handy especially if you want to use this in a local development version of stable diffusion on your own computer later which I'm going to show you in another video so go ahead and the only thing you need to do here is go ahead and delete this zwx directory click save to G Drive and then click the Run cell again now this is going to prompt you to connect your Google Drive and you need to be aware that this is going to take several gigabytes in order to store this so as it says at the top it's around four to five gigabytes there's an additional two gigabytes depending on the options that you select later so what you're going to do is go ahead and give it access to your Google Drive it's going to pop up in a window and you simply need to log in with your Gmail account and then click allow this is going to set up the directories on your Google Drive takes just a minute all right and with that done we can go ahead and scroll down to the next section so this is where it gets really important so you can see this section is where we're actually going to set up the prompts that we're going to use this is you can think about this when you're typing out a text prompt for artificial intelligence if you use chat GPT or you've used any other stable diffusion you know that you use a prompt so you say something like I want a photo of Tom Cruise riding a unicorn whatever it might be so this is where we're going to set up the prompt that it's going to answer back with data about you and your training model you don't want this to be generic you don't want to say photo of Brian for example you want to say something more explicit that is not common so you can use a nickname if you got one just use something that's not very common so I'm going to go with B love that's kind of what some people call me so it goes Be Love person I know grammatically that's kind of a weird way to put it but you want to say photo of be loved person and then for the class prompt kind of a similar thing you want to say dot photo of a dog unless you're training this model on dog photos in this case it's on me so I'm going to say person so photo of a person photo of B love person that's perfect so again for this we're going to change the directory so we're going to go belove model all one word and then we're going to come down here and we're going to say person instead of dog that's it that's all we need to do there so we're going to go ahead and click play this is going to set up the directory structure that it needs for us to import the training data which we're going to talk about in just a minute so once that's done takes about a second the next portion is where you upload your images now you can upload your images right here right you can press run cell and it'll prompt you to upload the images we don't want to do that so instead of choosing the file here and uploading them one at a time we're going to do kind of a batch upload so we're going to go over to files we're going to go to data and you can see belove model is a directory in here okay this is where we want to upload all of our training data this is a really important step so I want to pause here for a second the quality of the training data that you provide to this model and the variety of the data that you provide is going to impact directly the output that you get the better your training data the more varied the training data the better this system is going to perform when you actually ask it to produce an image for you so here's what I did that I found successful I went through my Google Drive I went through my iCloud photos and I found probably 40 or 50 images of me what you want to do is you want to get images that are in different lighting conditions you want to get some selfies if you can some close-ups some Far Away what I've found typically speaking is that from shoulder up if you get shoulder up photos and you get close-up photos you're going to be able to generate very highly detailed images after the fact so you can see a lot of these are varied some of these have pictures of other people in them now what I did here is I cropped every single one of these images down to 512 by 512. that's really important because that's the ratio that's the aspect ratio in size that the training model is actually expecting so you can see that we ended up with let's say 30 items and I think that's a fair amount now the more data you have up to a point the better the model is going to come out but in this case 20 to 30 images seems to be enough I also trained a model on my wife and we got great results out of about 20 30 images so what you're going to do once you have all that training data set up you've got all your images you can go ahead and select all of the images in the folder and you can just drag and drop them in the B model folder now it's going to prompt you that you need to have these saved somewhere else but of course you already have these on your computer you can see that's going to take just a second to upload all of those depending on your internet speed once all of your photos are uploaded you can go ahead and scroll down to the next step this is where you're actually going to train the model and there are a couple things we want to change in here so you can see resolution is 512 that's perfect what we need to do is go down to Max training steps now this is the number of sort of iterations that the the model makes on every single one of the images that you upload the more iterations it takes the more training data it has the better the results are to a point sometimes it can get weird if you put too high a number in here we have 30 images and what I've found is that for every 10 images about a thousand steps seems to be kind of The Sweet Spot so in our case we're going to put Max train steps at three thousand we're also going to set the save interval so how often it saves to 3 000 steps same thing and then we're going to change the sample prompt do the same thing we specified earlier so B love person and then we're going to hit run cell this is the most intensive part this is going to take probably 30 to 40 minutes depending on the number of images that you've uploaded you can see in the background this is using tensorflow this is what's actually training the model so that's going to go ahead and do its thing you can take a break here you can go grab some coffee come back in about a half hour I would come back every few minutes and just kind of scroll the page a little bit maybe uh shrink and open a dialog box something like that just to show that there's some activity on the site because here's what happens if you let this page run and you leave it for say an hour when you come back to it it's going to have already timed out it's going to be done and you're going to have to start this entire process all over so you can go away while this is happening but don't go too far you might just you might just watch some of my other YouTube videos while you're waiting something to pass the time all right you might have had time for a couple cups of coffee there because that took about 45 minutes but we have completed it hopefully yours did the same the next thing we're going to do is go down here and press play on the next run cell specify the weights directory I'm going to leave that to the default we're not going to fill anything in there that takes just one second to run here is the moment of truth so we're going to run this cell and it's going to actually generate some images based on our training data and these might not look exactly perfect but they're going to give you a representation of the model they're going to be a little off but you can tweak that later with your prompt let's hit the run and see what it comes back with not bad first one's a little bit weird there but you know that's how it goes these look directionally okay the second and third one you can at least tell it's me and so I think we're at least headed in the right direction with this model so the next part that we're going to do is convert weights to c h p t this is a checkpoint file this is what we're going to use later on in the next video to actually run this locally on your own machine so this is what's going to actually download the model that you can use in stable diffusion so we're going to go ahead and run the conversion leave everything checked as is and that's going to save this to your Google Drive it's going to take another two gigabytes of storage so make sure you have plenty of room for that and it takes just a minute for this to run we're going to come down here and run the next cell this is going to import itorch and everything else it's needed to actually generate some images so we're going to go ahead and set that up while that's going we can go ahead and figure out some other stuff here so the next section under this is set a random seed for reproducibility so the way that this works is it uses a random number as a seed for the stable diffusion model to actually generate some images if you use the same seed number or code what it happens is it actually generates very similar images sometimes the same images it's a way for reproducibility so what we can do is we can set this to negative one that's going to use a random seed every single time this runs once this is done actually importing we're going to go ahead and run this and then we're going to set up our first prompt we can go ahead and write this out while we're waiting you can scroll up here you can see it says photo of zwx dog in a bucket now this is the prompt that is the default for this model but remember we changed ours so it should be B love person whatever you named yours you use as a replacement so photo of B love person looks like our import finish so we can set our random seeds we'll run that takes less than a second you can also do a negative prompt so you could say things like you know you don't want to be shirtless you don't want weird hands you can add a whole bunch of negative things there this is basically a filter that's going to filter out some of the weird results you get number samples four this is just a number of images that it's going to produce guidance scale the lower this number is the more it adheres to your prompt so the more it's going to be like a photo of beloved person the higher the number is the more it's going to have sort of creative influence over what happened number of inference steps this is the number of times that the image is actually iterated over in the artificial neural networks higher this number the more iterations it does but you're not necessarily going to get better results I find that a number between I'd say 20 and 65 ish is typically sufficient for most of the models that have trained and then height 512 by 512 we're going to leave that otherwise it takes a really long time to drain some of these so we're going to go ahead and run this all right let's see what we got back uh that one's not too bad the face is a little bit odd not quite photorealistic but something sometimes so you'll notice with farther away when it has like a full body image like this you'll get really weird facial details I'll show you some tips and tricks later to actually correct that in another video uh this one again you can see some facial abnormalities but it's directionally okay so what we want to use this for is okay this directionally looks all right like the training succeeded and everything came out okay from here the big thing is going to be learning how to write the prompts both the positive prompt that shows the result and the negative prompt the things to filter out I'm gonna do an entire series of videos on that so hit like And subscribe if you found this useful and you'd like me to continue making content like this it just gives me a good indication that this was worthwhile let me know in the comments below if you have any questions or you had any difficulties up to this point and we're going to follow up with a whole series of videos about how you can use this to run local models on your own computer and how you can get better results out of the data hope you found this useful thank you all so much this is all your Tech I'm Brian Lovett we'll see you next time thank you
Info
Channel: All Your Tech AI
Views: 41,539
Rating: undefined out of 5
Keywords: stable diffusion tutorial, stable diffusion, ai art, stable diffusion ai, dreambooth stable diffusion, stable diffusion art, stable diffusion browser, stable diffusion online free, stable diffusion gui, stable diffusion ai art, stable diffusion installation, free ai art generator, ai art tutorial, dreambooth google, turn myself into a cartoon, open source ai art generator, ai art generator, how to make ai art for free
Id: q7wfFMIcvsU
Channel Id: undefined
Length: 14min 19sec (859 seconds)
Published: Fri Mar 03 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.