Privately Host Your Own AI Image Generator With Stable Diffusion - Easy Tutorial!

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey everybody and welcome back to jy's garage in the last video I showed you how to spin up a private self-hosted large language model and in this video we're taking that a step further as I'll show you how to do the same but for image generation now this process is ridiculously easy so I'm going to give you a couple of options the video is going to focus around stable diffusion which is one of the better open-source models now before I do get into this it's probably worth stating that from my experience at least the results aren't as good as some of the big players like things like darly or mid Journey but obviously those come with privacy concerns and some of them are behind a pay wall so first of all I'm going to show you how to install this locally on your Windows machine because thankfully there's some kind folk out there that have made this process absolutely simple next we're then going to take that same setup and dockerize it so you'll be able to have the same stable diffus fusion with a web UI of your choice on Docker and you can also choose whether you want to use a CPU only or a GPU now as with many of these things it typically tends to be that Nvidia has the better time AMD and Intel can work but there's often more setup and configuration that's required in this video I'll show you how to do it just with the CPU only but the Nvidia instructions are pretty straightforward I might potentially come back to doing Intel in the future but or gpus still aren't that popular so let's jump straight into the first deployment which will install it locally on your machine now do bear in mind that you could use something like proxmox with GPU pass through or whichever hypervisor you're using and you could still have the same experience so you could have a dedicated Windows machine with GPU pass through that you dedicate specifically for this now given some of the topics that I cover on this channel this almost feels fraudulent and patronizing but if you head over to easy diffusion 3.0 and simply hit the download link you can begin the download process for easy diffusion so if you want to download this for Windows just hit the windows download and that'll start and there's also one for Linux which will do that for you as well and once that's downloaded it really is as simple as just executing the executable going through the process next next next accepting the license agreements and hitting the Finish button it will take some time to compile and download but once it's done you're ready to go and I'll show you what that looks like now so work your way through the installer and then when you finish that you should be able to launch it from your menu and when you do it usually spins up the terminal for you it will load that up in the background and it should present you with a nice web gooey it really is a pretty cool tool and it's simple to launch and configure on Windows and so here we are it was as simple as that and out the box it will have support for your GPU as it's running locally on your machine so I'm just going to hit make the image and here you'll see that it goes away and within just a few seconds I should have that image generated using my GPU and when it's generating that image as it completes you'll get a popup here and you'll be able to use that to download it you can hone in on that image you can use that image to train and all that good stuff now this is quite a powerful tool and I'm not going to go in depth that's quite an interesting image and you'll be able to configure this in the same way that you can configure stable diffusion so some of the things here you'll want to tweak to your liking I'm not going to go into detail on this video and if you want to add new models to this you can go and download new models and you just need to add it into the models folder where stable diffusion was installed so let's give it a bit of a challenge a bit of a Warhammer nerd so let's put in some characters from that and then let's see what comes out the back of it and I'll compare that to things like Microsoft which uses darly in the background so this is a much smaller model and that's kind of where the issues come from I'm sure you can probably train this model and there are bigger models out there but when it comes to generative AI you're dealing with things like obviously Microsoft Google Etc who have the Monopoly on data on the internet so this looks pretty good it looks like an army from Warhammer not quite sure what's going on with a lot of these weapons but not too bad but let's compare that now to what Microsoft spat out and so yeah here you start to see the difference um I mean look at that compared to the other one and running that prompt again you get things like this so yeah your mileage may vary it's really cool that you can deploy this locally and you've got all the Privacy benefits and I'm sure that over time you can probably train it to get better and better or you could possibly use use a different model and that might have better results but that will be a lot more involved so let's now hop into doing the same thing bought for Docker so thankfully due to uh ABD Baro give this person a star they put together a really cool and easy to use container for doing this and it's quite similar to in my previous video where we need to spin it up and it has a build process during it now when I did this it took about 20 to 25 minutes to actually download install build Etc so your mileage may vary depending on your hardware and your internet connection what's pretty cool about this is you get to choose your front end so automatic tends to be the most popular and that's the one I use but you can use things like invoke and comfy UI The Comfy UI is pretty good for advanced users because you can tweak the entire workflow so you choose something that suits you and you can always change in the future so moving on to the instructions it's pretty straightforward we need to run two commands the first thing is to do the docker composed profile download so that's things like stable diffusion itself pulling all of its dependencies and then once we've done that we're going to run the second command which will actually spin up the user interface which will connect to the backend stable diffusion now the First Command you can run without issue it's always going to be the same the second command is where you need to make a choice so if we hone in on that you can see here that we need to specify a value for the UI now we've got the choice of invoke Auto auto CPU comfy and comfy CPU now those specify directly some of those uis we just mentioned but equally it's GPU and CPU now at the moment you can use Nvidia without issue if you have an Nvidia card pass through that will work fine but if you've got an Intel card or an AMD there is some additional configuration that you need to deal with so for this demonstration I'm going to use the auto CPU just because I don't have an Nvidia card and I'm not going to go into the weeds in installing the Intel card but to do that you have got instructions down here so I recommend you start out with the automatic the most popular fork with many features and a neat UI so if we click on here there are instructions for how to get this working with an Intel GPU and an AMD now as you can see Nvidia is the recommended GPU and whilst the others can Will might work you're going to have to invest a lot more time to get up and running so I recommend stick with an Nvidia GPU if you've got it that should work out the gate if you don't I recommend CPU and if you're brave have a look at these instructions so let's now hop into our terminal and get this working okay so I've created a new virtual machine for this in proxmox and I've given it about 20 CPU cores and about 20 gigs of RAM and about 50 gigs of hard drive space you'll obviously want to tailor this to your needs and you can always change it at a later date the first thing you're going to need to do is to install Docker so make sure you've got that installed you can check out my videos on how to do that once that that's done we then need to start the installation process much like my last video you're going to need to clone this GitHub repo first so there's a million ways you can do that you can either hit the code and just go here and download it as zip and then use something like win SCP to copy it over or you can obviously download and extract it using curl on the command line do whichever you're comfortable with and then copy over to the host so here you can see that I've copied the files over to my host and I've just put it in a stable diffusion folder so now in the command line I'm going to change directory to that stable diffusion and then we're going to run the commands that are on the website behind us so tudo Docker compos profile up download build this is going to take a while so when you run this Con grab a t I'll catch you on the other side once this is completed so now that the first part's completed and we didn't get any issues there we can move on to the second bit which as I said you need to be careful which option you select so for this one I'm just going to copy this into my terminal stick a sudo at the front and then I'm going to edit where it says the UI now because I don't have a GPU in this machine I'm going to put this one down to the auto- CPU if you do have a GPU you can just leave that as Auto so let's run that command and I'll see you on the other side this should automatically start the container and you'll be able to access this through your web browser once it's completed now when you running this you might experience the following error and that's because we've got a permission denied on the shell script because it's not executable by default so if you do full file of this head back into your local folder and you want to go into services and then for this one we're using the automatic and here you can see the entrypoint.sh so we want to go to properties and just make sure that that's executable hit okay hopefully we can press up and then return and it's going to go through now and execute that script so now this is completed we should be able to reach this on the IP address of your Docker host and Port 7860 obviously you can add some traffic labels if you wanted to and you could root this then through your reverse proxy with SSL and a nice friendly DNS name and so once you've done that you're landed with this page so now let's try rendering the same image that we did in the desktop version within the server dockerized version so that's now generating and as you can see again there are a ton of different options you can do in here to tweak stable diffusion and just like the previous deployment you can add additional models you can train these models and you can improve them over time now with the CPU this usually takes 2 or 3 minutes on how I've got this set up obviously if you have a faster CPU it's going to take less time and do bear in mind that if you start tweaking these settings it can have massive implications on RAM usage so if you do run into errors check the logs and make sure that you've got enough RAM and as always if you do have an Nvidia GPU I strongly advise that you use it just whilst that's rendering in the background here you can see the CPU and RAM usage so you really get a feel for how intimidating this is to your machine hopefully just just a few seconds more we'll have this up and running and quite handily you do get to see a preview of what's being created so now that render completed and yeah not not too far off nothing like obviously what was created with Bing that I showed earlier but hey this is local I'm sure you can train it and it remains private so now you have all of the tools you need to go and do AI image generation and like I said check out all the different models that are out there some of them are trained more specifically to generate certain types of imagery so thanks for watching Everybody thankfully this was quite a simple video arguably it's more just of an awareness piece to let you know that it is really simple to go and self-host this stuff if you like this video please give it a thumbs up hit that subscribe button and I'll see you on the next one take care everybody [Music]
Info
Channel: Jim's Garage
Views: 8,159
Rating: undefined out of 5
Keywords: ai, uncensored ai, private ai, homelab, docker, linux, artificial intelligence, ai image generation, stable diffusion, dall e, midjourney, ai image generator, free ai image generator, ai image generator free, bing ai image generator, dall e 3, stable diffusion tutorial, stable diffusion video, how to use stable diffusion, how to install stable diffusion
Id: 5XHSV56hsJM
Channel Id: undefined
Length: 12min 34sec (754 seconds)
Published: Thu Dec 21 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.