How to Install and Use Stable Diffusion (June 2023) - automatic1111 Tutorial

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi I'm Albert and today I'm going to show you how to install and use the stable diffusion AI image generating software now I started this YouTube channel almost a year ago and this is by far the most request tutorial but I decided to hold off until it became completely clear what the best way to use stable diffusion was going to be and the results are in it's definitely the auto 1111 web UI at least for now today I'm also going to introduce you to the control net extension which I believe is the key Advantage stable diffusion has over the competition and will really blow mid-journey and Dolly out of the water the other huge advantage of stable diffusion is that it's completely and permanently free to use and it runs locally on your computer if that computer is powerful enough that means there's no data going to the cloud you're not paying for any subscriptions and there's a huge open source Community developing this tool together making updates much faster and more regular than any commercial alternative all links to the resources I use in this video are of course in the video description so anytime you see me use something on screen just check below and you can install it there let's begin what do you need well currently stable diffusion runs best on Nvidia gpus of at least the 20 series and I'll be using Windows so make sure you meet those requirements before attempting to install any of this or it will not work and you will probably get very frustrated if any questions come up make sure you watch the whole video and check the links in the description before asking if your question is still not answered feel free to comment below or to get a quicker response ask in the stable diffusion subreddit the community has grown immensely over the past few months and in all likelihood someone has already experienced your problem and has an answer ready for you and now let's begin installing if your PC fulfills all the necessary requirements you can now install the auto 1111 web UI for this you'll need python 3.10.6 the newer versions of python currently don't support some things so make sure you have the right version download it from the link below and be sure to check add python to path while installing this is very important next download and install something called git which is necessary to install the actual UI itself and get updates for it once you're done with these installations it's time to download the stable diffusion web UI repository for this open command prompt and a Windows Explorer window find the folder that you want to install stable diffusion in and copy the file path from up here enter CD then paste your file path and hit enter now you're in the right folder enter the command git clone and this URL to the GitHub repository which you can copy from the video description then hit enter wait for the process to finish and then you'll find your installation in Windows Explorer run this web ui-user.bat file and wait again briefly now it's installing all the remaining components you can now see your UI under this address in your web browser our first step is models head over to civitai.com a popular website for user created models a model is the most significant way to influence your image people have improved upon the basic model of stable diffusion that was originally published to improve General quality change art styles or be good at very specific subjects like characters genres like fantasy or anime or even their own face fair warning there is a lot of not safe for work content on this website so be sure to set up some filters in your user settings to not see those if you don't want to pick a model that catches your eye and has high ratings if you're new to this I suggest you start with a versatile model that can do all kinds of stuff like cyber realistic you can pick a so-called pruned model here which is much smaller than the big ones this is fine if you don't plan to train your own model on top of it which I will not be covering in this video here you can see that this specific model needs a so-called vae so click here and download and save it too once both are downloaded you'll need to place the model in your web UI models stable diffusion folder and the vae goes into the folder labeled vae we're almost ready to go into your UI under settings hit user interface scroll here and type SD underscore vae apply and reload this added a vae selector up here where we will select the vae to use with most models that we just downloaded to the left you can pick which model you want to use today let's pick cyber realistic because that's the only option right now this text box is where the positive prompt goes here's where you enter what you want to see there are many ways and grammars of how to do this what I like to do is start with the medium I want to see so a photo portrait of then what the subject is a man in fantasy armor then with a comma I start adding details 40 years old Brave expression grizzled brown hair detailed face background is Medieval camp at sunset down here is the negative prompt here is where you write what you definitely do not want to see especially regarding quality this is just as important as the positive prompt what I write here is usually the stylistic opposite of the image I want so cartoon illustration monochrome the last term will prevent black and white results usually now this is not an incredible prompt but this video is not about prompting go on civit AI and check out how others prompt on images or check out the rest of my YouTube tutorials for more detail and most importantly try it out yourself that's the best way to learn how to do this now all these other settings the sampling method has a ton of different options some have advantages and disadvantages to one another While others are just old you can find detailed comparisons on Reddit I personally would stick with the DPM Samplers because they're new designed in 2022 for this exact purpose dpm2 is more accurate but slower than just DPM DPM plus plus is a general Improvement on DPM the specific differences depend on many other factors my go-to is DPM plus plus 2m Keras it's a great trade-off of quality and speed sampling steps is basically the time spent processing the higher the steps the better the result although the quality does tend to flatten out so 150 steps is not going to give you double the quality of 75 steps but the difference between 20 and 40 steps is clear I never really go higher than 50 and for testing settings 20 can be enough somewhere in between is usually the sweet spot for a great result that doesn't take too much time next width and height your first instinct might be to set these up really high but that would wreck your result that's because most stable diffusion models are trained on 512 by 512 pixel images some are 768 by 768 so for best results keep them at this native resolution that they were trained on you could change them also make them non-square that works usually but sometimes if you do that you might get multiple heads and other weirdness so I recommend researching this hi-res fix feature for more info on how to get larger but also better results in exchange for a lot more process same time next CFG scale this essentially tells the AI how creative it's allowed to be if you set it very low around three it will do what it wants just vaguely inspired by your prompt usually the result will be good but it will be missing some details you might want a high setting like 15 will include more of your prompt but may look aesthetically worse now you might be hearing some pretty vague descriptions of settings for me here that's because AI image generation is a pretty imprecise science there are many many different factors at play that inform how your result will look this includes extensions and all sorts of stuff so I can't actually give you tips on how to get the exact image you want all I can do is encourage you to experiment restore faces does exactly what you think it does if you have some faces that are coming out messed up in your results this feature may make them better fair warning though it will also change them a little bit and can look bad so just try it out if your results aren't pretty without it and you're not trying to generate a specific face last but not least in the important features batch size and batch count batch count is how many images it should make in a row and batch size is how many images it should try to make at once now you do need a really strong GPU to make several at once so let's do four batches in a row with one image a piece now let's hit generate and finally see some results and you can see some pretty good results already if you tried this in the default stable diffusion model 1.5 for example you would not get results this good which is why I recommend taking a custom model right from the beginning now that we've generated our first images I want to introduce you to the sponsor that made today's video possible brilliant.org now if you share my interest in technology you might be wondering how stable diffusion works in the background I found an excellent interactive course on brilliant which explained neural networks to me through short fun daily exercises but that's not all brilliant has to offer it's the definitive resource for learning math and computer science it's perfect if you're strapped for time but need this knowledge for your career or if you're eager to delve deeper into a complex subject while preferring a relaxed fun and Hands-On method of learning by solving real world problems brilliant provides a wide range of meticulously designed courses to match your needs regardless of your proficiency their courses go from straightforward to advanced math AI data science and neural networks and they're always updating their material with new lessons each month so there's always something new to learn now whether you share my fascination with AI or are just up for exploring you can try brilliant for 30 days free by heading to brilliant.org albertosazon or by clicking the link in the description the first 200 of you to register will get a 20 discount off an annual premium subscription now let's get back to and deeper into stable diffusion now we come to extensions which improve and expand your stable diffusion features beyond what comes out of the box as an example look for control net in the repository and hit install go to the install tab now and make sure it's on apply and restart your UI now that you have the extension you can download and install the models required for controlnet this is comparable to the stable diffusion models we installed earlier just applied to control net you can download them via the link in the description for now get the depth.pathfile kenny.path and openpose.path the rest would be too much to download now and again once you've downloaded them place them in the extensions control net models folder in your text to image tab you'll see this new area down here hit the little refresh button and you'll find your downloaded models let me show you what controlnet does let's enable this unit 0 here and set it to depth you'll see that it automatically sets up some settings we'll need up here we can put an image that we want to use as a base I'll look for one on pexels.com like this house and download it in a smallish resolution that should be enough drag and drop it into your UI if you hit allow preview you can see what this control net depth preprocessor will do click the little explosion icon to activate it the first time you do this it might take a while that's just because it's downloading the depth map preprocessor as you can see if you open the command prompt window it won't need to do that again in the future here you can see what a depth map is it automatically recognized roughly what was closer to the camera and made it white and what was further away and made it black that way SD gets an understanding of how your scene should be set up in 3D space let's give this a prompt a house in the rainforest set the sampler and leave the other settings as they are generate it takes a little bit longer but you can immediately recognize that the general composition of the scene is now the same the foreground has some bushes there's the house and the Open Sky background but we did lose some detail of the house the windows are in different places and so forth let's go to another unit of control net bringing the image again and enable this time we'll set it to Kenny and preview you can see this recognizes the outlines of your reference play around with the thresholds to set exactly how much detail can see now generate again this new result has much more detail from the original like the windows in the door position an important thing to know here as you may have noticed this method does not take any color information from the image which is why we can turn it from a dry desert to a rainforest in this example you can use the color from your inspiration image but that comes later in the image to image tab now let's check out the final control net model open pose for this I'll find a photo of a person posing in a way that we want to copy deactivate the old units and bring this man into the new unit I'll enable and set it to open pose this will recognize this pose and even facial expressions set up preview again a new preprocessor will download the first time in this case it worked really well this picture will tell SD how we want our character posing and looking in the result let's prompt a man sitting on a bench okay you can see that this prompt was too simple let's keep it closer to the image for Simplicity a photo of a black man sitting on a bench and generate while that's processing that was actually a good example of bias in many AI models just writing man defaulted to a white guy I have to actually add black to make him black that just means that there were many more photos of white people in the original data set that this model was trained on the results are really good you can tell the face and watch are a little messed up because it's hard to get details in such a small part of the result we'll fix that in the next step to change your results after generating you can click Send to image to image down here this will move some of your settings and your image into the second tab of the UI first I want to use this to get a few more options of the image I liked best while keeping the general colors of this image for that I can go down here and change some settings I'll pick the same sampler and everything I can activate restore faces but the one thing I mainly want to adjust is the denoising strength down here it changes how close I want my result to be from the original a low number like 0.2 will change very little and just give me some light variation let's look at that hit generate okay this was almost too little changed let's go way up with that value generate again and now you can see the color and general shapes of everything are still similar but I have some real options I still like the original though now I want to adjust small parts of this image that's called in painting and if we head back to civit AI you'll see that our cyber realistic model has a special version for that specific in painting application go ahead and download that bring it into your stable diffusion models folder like before refresh your models up here and select it now on the image you want to in paint click this send to in paint button now you can literally draw over areas you want to edit I'll start with removing one of the watches I'll write watch in the negative prompt because I don't want it and now I change masked content to fill and change my denoising strength to about 0.5 this could take a little fiddling but it should remove the watch generate and boom the watch is gone I pick my favorite and hit send to in paint again click this little refresh icon to delete your original brush strokes and now I want to change the face which takes some different settings I'll adjust the prompt to reflect some more detail in the facial area photo of a smiling black man detailed face for example and now this time I'll change the in paint area to only masked so it works on that area in the full possible resolution and turn up the sampling steps to five because I want more detail here mask content should this time be original because I want it to stay close to the original face and I'm going to generate now and here we go the details are fixed and we have a pretty good result that was my introduction to stable diffusion in the web UI I hope you had fun learned a lot and now go enjoy all these incredible tools and get really creative dozens more in-depth tutorials with loads of specific use cases and tips await you on my channel both in the past and in the future so be sure to hit that subscribe button like and leave a comment about what you want to see next I'm Albert bosazan and I hope you have fun with stable diffusion
Info
Channel: Albert Bozesan
Views: 69,762
Rating: undefined out of 5
Keywords: ai art, concept art, stable diffusion, midjourney, dalle, open source, artifical intelligence, installation, auto1111, webui, controlnet, ai
Id: nBpD-RbglPw
Channel Id: undefined
Length: 18min 3sec (1083 seconds)
Published: Mon Jun 26 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.