Use Your Face in AI Images - Self-Hosted Stable Diffusion Tutorial

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
I have collected a literal ton of Enterprise gpus over the years in an effort to use them in gaming but what do you say I start using these more for their intended purpose today's video is brought to you by extra wallets the minimalist wallet that won't slow you down this is a wallet for the Modern Age mild bifold was perfect for carrying around cash and checks but that's just not how business is done anymore I've been using minimalist wallets for the last few years and while it certainly cuts down on the bulk and looks sleek getting my cards out of it was always difficult and made me look like a mess but with my new extra wallet all my cards are just a click away go to shop.exter.com craft Computing and use promo code craft to receive 35 off your next order that's shop.exter.com craft Computing promo code craft and thanks again to extra for sponsoring today's video welcome back to craft Computing everyone as always I'm Jeff as I mentioned in my last video I've been wanting to get into AI generated art for quite some time as I have more gpus on hand than I really know what to do with So today we're going to get stable diffusion up and running on one of my servers now I am fairly new to the AI image generation space and so I wanted to go with an open standard stability AI developed stable diffusion as an open source AI image generation tool and that's what we're going to be using today I'm going to walk through the install process what Hardware that I happen to be using and what Hardware you can use at home to keep things as simple as possible I'm going to be installing automatic 1111's Fork of stable diffusion that comes pre-packaged with a web GUI so I can access it from my desktop PC rather than needing remote into my server rack so what Hardware are we going to be using today the server itself will be fairly familiar to those of you who have followed my cloud gaming series that is my experimentation with gaming over a network to a virtualized gaming machine I've got a full playlist that you can check out right up here if you're interested in that I've been wanting to run ampere gpus in my cloud gaming server but as of yet there's really no support through KVM proxmox or any other hypervisor to run those using the Nvidia grid drivers however if I run Windows with hyper-v you can run GPU para virtualization with pretty much any graphics card that you want and so that's what we're going to be putting together today think of this video as a sneak peek to the hardware you'll be seeing in my next iteration of the cloud gaming server the core of the system is pretty much the same with an epic ROM 7742 64 core CPU and 256 gigabytes of ddr4 3200 ECC registered memory so what gpus am I going to be running in this new system well I could go with something like the Nvidia p100 or any other of the Enterprise graphics cards from the Pascal series but I decided to go all out and install a pair of RTX a5000s first and foremost a huge shout out to yakto for donating one of the a5000s to the channel for use in this project and thanks to my financial advisor for allowing me to spend eleven hundred dollars on a matching card the RTX a5000 is based on the same ga-102 GPU die from Nvidia as the RTX 3090 and the RTX 3080 it is a slightly cut down variant though with only 8192 Cuda cores but it has a full 24 gigabytes of gddr6 at the time that I acquired these cards going with the a5000 was the cheaper alternative to buying an RTX 3090 however based on eBay prices from today going with a pair of 30 90s is probably the move I would make if you were building the same system today now for running stable diffusion at home this is definitely overkill for the setup you could get very similar results by running something like a GTX 1080 or any other Nvidia graphics card with at least eight gigabytes of video memory so most of their graphics cards in recent releases I wanted this much power because again I'm also going to be splitting these into multiple gaming VMS down the road for today I will be installing stable diffusion onto the bare metal server using Windows Server 2022 however again I will be sectioning that off into its own dedicated virtual machine later on again for today I'm going to be installing on Windows Server 2022 but the same instructions will work for Windows 10 or Windows 11. in fact the exact same git repository and process will work for Linux and Mac OS as well you just have to run different script installers depending on your operating system the prerequisites for install are fairly simple you need to have git installed or be able to download from the git repository as well as Python 3.10.6 and I will have links for those both down in the video description so we're going to start out by opening up a Powershell prompt I'm going to go to the root of my C drive and then I'm going to clone the git repository for the stable diffusion web GUI that will create a new folder in my C drive and if we go to the stable diffusion directory this is where we're going to be working now you will need a couple more files to generate AI images these are known as AI models or checkpoints of staple diffusion if you open up a web browser and go to huggingface.co you can download the stable diffusion V 1.4 and stable diffusion v 2.1 I wanted to download both as while stable diffusion 2.1 is more advanced and does give in my opinion better results version 1.4 you can train with models of your face using some extensions in the stable diffusion web GUI which we'll be doing later in this video for 1.4 go ahead and download the SD 1.4 checkpoint and then for version 2.1 I downloaded the 2.1 512 EMA pruned checkpoint with those downloaded go ahead and copy both of those files into the stable diffusion directory so we're going to go into the C drive stable diffusion web GUI go into models and then stable diffusion and put your checkpoints there with that done we're ready to actually start stable diffusion so I'm going to go ahead and execute web UI dot bat now this will take a couple of minutes every time it starts up as it creates a new web GUI interface and web server from scratch it also Imports all of your extensions and models so you can start generating AI images with now the first time you start up this installer it will clone your python install into its own virtual directory that way it can maintain control of the version of python that it's running it also installs all the various dependencies like pip and torch so it doesn't have to rely on your PC having the exact correct version that way if you happen to upgrade python on your PC later on you won't break stable diffusion alright once all the dependencies are installed you should see running on local URL at your localhost address and then Port 7860 so let's go ahead and browse to that now and if you did everything right you should be met with a stable diffusion web interface that looks something like this and up here in the top left corner you should be able to check both of your checkpoints that you have installed just to make sure that everything is up and running let's give it a simple prompt something like uh dragon in a forest and let's have it generate us an image there we go simple as that we have uh a Siamese dragon in the opposite sense of a four-legged dragon with two offsetting legs coming into the center uh sharing a single head so not perfect but you get the idea all right that's a little better about night fighting a dragon in the style of Renoir foreign [Laughter] that's certainly interesting it's a lady Dragon apparently let's do one more there we go of all the ways I was gonna get demonetized on YouTube I didn't think this was gonna be it but uh there we go we have kind of a centaur naked lady where the Knight has a landscape painting all right let's check our version 2.1 and see if that is up and running as well [Music] how about just Knight fighting a dragon Let's uh let's get it a little simpler here or a dragon knight fighting I I think that works so now that we know everything is up and running let's see how much GPU power is actually required for something like this let's go ahead and have it generate you know what uh Super Mario and cyberpunk let's do that and instead of just one image let's have it do 30. and go ahead and hit generate so for these images we're using about five gigabytes of video memory and very little of our actual processing power and that's something I've seen in some of my early testing here is it doesn't actually require a ton of horsepower most of the work is actually being done in video memory so what that means is something like a Tesla M40 or a GTX 1080 are more than capable of processing and producing results like this you don't need an rtxa5000 although this will probably be faster so let's take a look at some of our results there's a little bit of a pixel art cyborg Mario I kind of like that one [Music] hahaha is that a Mario Wario clone with a gun at least I got the number of fingers right like that's actually impressive [Music] [Laughter] uh some of these are great oh I like that one that's kind of cool I don't know what's up with the uh multiple layered overalls there though I I kind of dig the double buckles though laughs wow that one's taking me back a little bit uh Bob Hoskins eat your heart out you know what I want to do I want to do uh Yoda bye Picasso nice [Laughter] all right a couple of these are legitimately awesome foreign I might have that one printed out on canvas and hang it on my wall like I I genuinely like that one so that's all well and good but I didn't download this and install it just to generate images of Yoda on canvas uh I kind of wanted to play with my face a little bit so let's do that now now I do have a little bit of public cred but if you type in craft Computing uh I don't think it's going to get anywhere close to me in fact let's go portrait of Jeff from Craft Computing I highly doubt this knows who I am well let's get in the facial hair right I don't know if I should be impressed or insulted let's take a look at these see if they're anywhere close nope [Music] I mean maybe no [Music] no I mean come on come on don't do me dirty like that nope nope nope okay so it clearly doesn't know who I am let's teach it who I am I'm gonna go over to extensions and then go to available and load all of the available extensions and then search by name uh I'm looking for dream Booth right there so dream Booth is probably the easiest training model for importing you and getting art based on you as well as everything that stable diffusion already knows and clicking install is pretty much as simple as it gets but then we do need to restart the service so I'm going to go ahead and hit Ctrl C terminate the web server and then we'll go ahead and restart it and now it should load dreambooth as an extension well I was meaning to get this video out a couple days ago but ran into an unexpected delay everyone me Charlie Rambo's not happy if you did everything correctly after stable diffusion comes back up you should have a new tab called dream Booth now's the really fun part where we're going to start training it on my face to do that we're going to create a new model based on the stable diffusion 1.4 checkpoint so I'm going to give this model a name of CC Jeff and then we're going to load up a source checkpoint so in this case stable diffusion 1.4 and then I like using the Euler ancestral training model that one gives me a little bit better results uh through all of my testing once you have those three things set up go ahead and click on create model and this takes just a couple of minutes now while that is installing we need to get a bunch of images ready to start training this on my face and uh you need probably between 10 and 20 overall and you want a variety of lighting sources and environments and backgrounds and facial expressions and angles and so basically you just want to go through your own library of photos and pick out a variety of good looking selfies now we do need to feed it an exact size of image and crop it down on the face and for doing that I'm going to use a bulk image resizing tool available for free online basically we're going to take my source images copy all of those and drag them on in then over here on the right hand side we're going to resize these to 512 by 512 and then on each one we're just going to make sure that my face is as centered as possible okay and once you have that done go ahead and click on save as zip once you have that zip file downloaded go ahead and unzip the contents into a source directory and that's the directory that we will Point our training algorithm to to pull the Selfies out of so with that go ahead and open Firefox back up we'll go back to stable diffusion and without our training model should be ready to go so over here in model selection you can see the model is now CC Jeff training your face is actually pretty darn simple from this point out first off we're going to click on settings and then click on the performance wizard button this will actually tune the training algorithm to match the hardware that you have so if you have a lower spec video card or less video memory available it'll go a little bit lighter versus again I'm running some a5000 so I've got 24 gigabytes of vram available I can bump up my training quite substantially next we're going to click on Concepts and under data set directory this is where the directory of the images that you just downloaded go so I'm going to put in the path to the files there next up go ahead and click on Concepts and this is where the image data is going to go so first under data set directory you're going to paste the directory path to the Selfies that you just downloaded next up we're going to scroll down to the prompt section and here is where we give context to the files that we are trying to train with this is the text that identifies the things that are in the images the instance is the exact thing that you're wanting to train on so in my case I want to train it with Jeff however I can't just type in Jeff because our training model already has likely some more famous gifs than me so how do we uniquely identify me as an object that it can learn well we need to give me a unique instance so I'm going to type in CC Jeff because I doubt there's anyone else using that exact term in the stable diffusion model that we're using and in fact these are all photographs so I'm going to say photo of CC Jeff next up we come to the class prompt and this is a more generic explanation of what these photos are yes these are a photo of CC Jeff more specifically they're a photo of a man and that's pretty much all you need to type in to get started on the training again we're going to scroll up a little bit and click on the training wizard for a person again because we're specifically training a face in this data this will set up all of the preset training algorithms for training a person's face and you should see a wizard result over here on the right hand side after that all we need to do is click on the Orange train button now this part will take some time regardless of what Hardware you have uh mine when I've been training it takes typically about 20 to 30 minutes as there's about 1400 images that it has to generate so we're just gonna wait that amount of time and I will see you after the break all right like I said that took about 20 minutes or so and if everything went as planned you should see training finished now we're just going to jump on back over to the text to image Tab and up here in the uh checkpoint selector we're gonna hit the refresh button and then we should see our new checkpoint right here so I'm gonna go ahead and click on that and now it's as simple as entering in a prompt and seeing what the AI generates uh first off let's just see if it knows who I am so photo of CC Jeff it's kind of me [Laughter] uh wow those are some uh those are some cheeks all right let's see what else we've got uh let's see CC Jeff cyberpunk uh oh there we go let's see CC Jeff has a superhero that's just frightening oil painting of CC Jeff what the is that uh I mean the face isn't bad but what am I holding there good God now remember these are not by any means guaranteed to be good uh anyone who made an avatar of themselves with lenza or any other similar Paid for apps uh you get 50 images back but maybe like five or six of them are like fantastic so if you really want to dive into this you need to generate a lot of images to start getting some good ones so let's uh let's let it do that I'm gonna go CC Jeff uh in Star Trek and we're gonna make let's make 20 images so we're gonna change the batch count to 20. and see what it does all right let's take a look at what we got okay those do vaguely look like me so far no real winners what's with bald Jeff in the window okay we finally got uh one of me at least in a Starfleet uniform of sorts looks like a t-shirt with a pin on it uh and the ears are slightly pointed I like that so slightly Vulcan Jeff uh hey look AI is getting better I have five fingers instead of 30. I'm not sure if I hate that hat or not I kind of like it foreign that's a little interesting I'm not sure why it twisted my mustache up not sure how many of these are Jeff in Star Trek versus Jeff the weird Wanderer you picked up in a failing shuttle craft see Jeff is an action movie hero I don't have a lot of high hopes for this one all right Jeff in the universe where Dentistry had not been invented yet oh God I have four rows of teeth there at least they at least they gave me an earring I guess ah Dear God all right so again no real winners here foreign right these are all interesting ly one more CC Jeff in cyberpunk because sometimes this gives some pretty good ones although not so sure about these results I'm getting so far the hell was that I'm pretty sure it just generated one with a bulletin board tack in my head with the pin coming out my mouth yup it's exactly what it did okay then all right well I think this is gonna round us out um getting more creepy results than anything else but there are some decent ones in there uh but uh yeah lots of trial and error and again the more images it has of you the better this will likely recreate your face or anything else that you're trying to recreate say you wanted to study a particular art style and then start recreating things in that style this is a pretty good tool set to start your progress on being able to do that but I think that's going to do it for today's video if you do have any questions or comments please leave them down below on your way down there make sure to drop this video a like And subscribe to craft Computing if you haven't done so already follow me on Mastodon at craft Computing at hostetucks.social for daily Shenanigans like this and if you like the content you see on this channel and want to help support me in what I do consider joining the patreon link is also down in the video description that's gonna do for me in this one thank you all so much for watching and as always I will see you in the next video cheers everyone [Music] beer for today is from barsidious brewing in Lebanon Oregon and this beer has a very interesting origin so the brewery was founded by a man named Bill Bartman who was a music teacher at Oregon City High School for 33 years and decided to retire and start a brewery barsidious is a combination of a couple of his favorite names from fictional TV shows one of them is Bartman obviously because Bill Bartman uh loved the character from Simpsons as well as Darth Sidious known for his role in the Star Wars extended universe and as the main antagonist in Shadows of the Empire so today we are drinking the barsidious Brewing black Stout ale an eight percent Stout and uh oh man is this thing ever dark uh man no light gets through this at all seriously it's it's literally like a black hole like it's crazy remember to change your car's oil every three months or three thousand miles boy that is super rich and super bitter uh if you are a fan of Stouts that lean into the darkest of dark flavors uh of your super dark chocolate and your blackened espresso you are going to be a fan of this beer it is thick it is chewy it probably shoots well above its weight class of eight percent ABV into something that if you told me this was 11 5 or even 12 percent I'd probably believe it it has that kind of a body on it it's like an espresso that punches you in the nose in the morning it's it's that kind of intense rich flavor silky smooth chocolate will seduce you to embrace your dark side embrace the darkness you know you want to uh very simple description of this beer and really I couldn't agree more it's not overly complex but I think it's also exactly what it sets out to be that is a super rich dark thick but still drinkable Stout I'd recommend it
Info
Channel: Craft Computing
Views: 95,890
Rating: undefined out of 5
Keywords:
Id: SCPUe-6KpyE
Channel Id: undefined
Length: 27min 22sec (1642 seconds)
Published: Wed Feb 08 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.