Hello,

Sign up to join our community!

Welcome Back,

Please sign in to your account!

Forgot Password,

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Sorry, you do not have permission to ask a question, You must login to ask a question.

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Home Latest Topics

  • 26k
  • 26k
Kevin Stratvert

How to Install & Use Stable Diffusion on Windows

video
play-rounded-fill

Hi everyone, Kevin here. Today we are going to look at how you can both install and also use Stable Diffusion. With Stable Diffusion, you can type in some text, and then using AI, you can generate an image based off of that text, and the results are actually really stunning. There are many different companies that are pushing out technology like this, but the reason I like Stable Diffusion so much is first off, the code is public and also free to use, you can install it on your computer as long as you have a decent graphics card, and you also get full rights to all of the images that are generated. Let’s check this out. Before we install Stable Diffusion, one thing I want to call out is you can also just use it on the web if you just want to experiment with it. Simply click on the link right up above. On this website, you can type in some text and then you can click on generate and it’ll spit out four different images. So, why would you want to install it? Well, when you install it, you can adjust more of the parameters, and you can also output far more images. First, we want to make sure that your PC is even capable of running Stable Diffusion, and you’ll want to make sure that you have a discrete GPU. On Windows, press control + shift + escape. This opens up task manager and over on the left-hand side, click on performance. Here if you see NVIDIA in this list then that means that you have a discrete GPU or graphics card, so that’s good news. Right here, you’ll also want to verify that you have at least 4 gigabytes of dedicated GPU memory. Next, you’ll also want to make sure that you have at least 10 gigabytes of free hard drive space. If you have those, then we’re ready to move on to the pre-requisites that we need to install. To use Stable Diffusion, we need to get two different pre-requisites. The first one is called Git. You can click on the link right up above, and then on this page, click on this link to kick off the download. Once you finish downloading, click on the file to start the installation and you can stick with all of the defaults. You might be wondering, well, what is Git? Git is used for source control management, but in this case, we’re simply going to use it to download Stable Diffusion and also to keep it up to date. If you’re interested in learning more about what Git is and how else you might want to use it, you could check out the video down below in the description. The second pre-requisite that we need is Python. You can click on the link right up above. This drops us on a landing page and here you see that it’s version 10.6. This is the current version that works with Stable Diffusion. If you scroll all the way down the page, here you’ll see the installers. Here I’ll click on this one to kick off the download. Once you finish downloading, click on the install file. During the install process, make sure to check this box next to add python.exe to path. This will make it easier to run the various Python scripts. Now you might be wondering, well, what is Python and why do we need it? Well, Python is a programming language, and it turns out that Stable Diffusion is written in Python. If you want to learn more about Python or even how to program in Python, you can check out the video right up above. Now that we have all of the pre-requisites out of the way, we’re now ready to install Stable Diffusion, and we’re going to install a fork called WebUI. It happens to be the most popular fork. You also get a graphical interface that makes it easier to interact with Stable Diffusion. With the base version, you simply type your commands on the command line, and it’s also been optimized to work on consumer grade hardware. To install Stable Diffusion, open up File Explorer. Here I’ll press the Windows key together with E, E as in Explorer. Here I have File Explorer open. Then then navigate to where you want to install Stable Diffusion. Here I’ll click on this PC and let me place it on my D drive. Next, right click and then go down to new and select new folder and here I’ll type in Stable Diffusion. Then click into the folder that you just created. Up here on the address bar, click into there and then type in CMD. This opens up command prompt and we now need to get all of these Stable Diffusion files and we’re going to use Git to do that. Remember, we installed Git earlier. Here you could type in Git and then clone. We’re going to create a clone or copy of that repository, then paste in the following URL. You’ll find it in the description of this video. Once you enter that in, hit enter. It’ll now take a little bit of time to clone all of the files in that repository. Now that we’ve cloned the repository, if we click back into File Explorer, you’ll see that there’s now a new folder called stable-diffusion-webui, and if you click into that, you’ll see all of the associated repository files. Next, we need to download the model or a checkpoint. You could click on the link right up above. On this page, scroll down just a little bit and right here we see the download link for the checkpoint or the model and there are two different versions that you can choose from. There’s one that’s 4.27 gigabytes and there’s another one that’s 7.7 gigabytes. Now you don’t really get different results depending on which one you download, so I’d recommend going with the smaller one. Here I’ll click on this one. For this, we’re just going to stick with the base model, but one thing to keep in mind is you can also experiment with different models. Different models may be trained on different images and also different text. Here as an example, for this same text input, here you can see the outputs from three different models, and they’re all pretty different. Now you have different models that specialize in certain areas. You might have a model that’s really good for anime photos, or maybe there’s another model that’s really good for car illustrations. For this, we’re just sticking with the basic model. Once you finish downloading the model, go to your downloads folder and you should see the file here. Right click on it and go to rename. You can also press the F2 key and let’s rename the file to model. Then select the file and press control + X to cut it. Then navigate to where you created your Stable Diffusion folder. Here I’ll click into that folder and click into stable-diffusion-webui and right here find the folder called models. Click into that, then click into Stable Diffusion, and here press control + V to paste that model file into this folder. We now have all of the files that we need to be able to run Stable Diffusion. Up on the top address bar, let’s click back into this directory, stable-diffusion-webui, and let’s scroll all the way to the bottom where we have this file called webui-user.bat. Let’s select that file and then right click on it. We’re going to make one optimization to ensure that we always have the latest and greatest version of Stable Diffusion. Right over here, let’s click on show more options, and in this menu, let’s click on edit. This opens up Notepad, and at the very top of the file, let’s insert an additional line, and here let’s type in Git Pull. This way it’ll always pull down the latest version of the Stable Diffusion web UI repository. Next, go up to file save and then you can close out this file. All right, we are now ready to launch Stable Diffusion. Right here where we have that webui-user.bat file, let’s double click on that. Stable Diffusion now needs to install various dependencies to be able to work, and this will take a little bit of time, so feel free to go off and do something else and check back in a little bit to follow the progress. It’s now finished installing all of the dependencies, and don’t worry, you’ll only have to do this the first time you click on this file. Once you run it again, it’ll be much quicker. Right here we see a URL. You can select this and then press central + C to copy and we’re going to paste this into our browser. In your web browser, go to the address bar and then paste in this URL that you just copied from command prompt, and this opens up the Stable Diffusion web UI. In the top left-hand corner, we can choose the Stable Diffusion checkpoint or the model that we would like to use, and we just installed one model. This is the base model, so let’s select this one right here. Across the top of the page, you see all of these different tabs. The first one is text to image, and that’s where you can enter in some text, and it’ll generate an image based on that text, and right here, we have a prompt where we can type in our text. Here I’ll type in cookie monster in Times Square and I want it to be photorealistic, and I want it to have some depth of field. The more descriptive you are, the better your photo will be. Over on the right-hand side, there’s a color palette, and when you click on this, this will insert an artist’s name into your prompt, so this way it’ll apply a different artistic style to your image. But for now, I don’t need that, so I’ll remove that, but just to let you know that this is here. Down below, you can also enter in a negative prompt or things that you don’t want in your image. Now I don’t have anything in mind, so I’ll leave this blank. Down below, you can also configure these sampling steps or basically the way to think of this is how many times will the image be refined before you see it. In general, the higher the number, the better, but it will also take more time to compute. For now, I’ll leave it to the default of 20. Under that, you have the sampling method, and you can experiment with some of these different options, but for now I’ll stick with the default. Under that, you can also select the width and the height of the output photo, and by default it’s set to 512 pixels by 512 pixels, and I’ll stick with that. Here, too, the larger the photo, the longer the processing time will be, and the smaller the photo, the quicker the processing will be. Under this, you have many other settings and I’ll touch on some of the more interesting ones. Right here, there’s an option to restore faces, so if you find that as you’re generating photos, the faces are somewhat distorted, you could try turning this on to see if it makes a difference. Down here, you can set the batch count or how many images you want to get as part of the output. Here I’ll select maybe 10 images. Let’s try that. To the right of that, you can also define the batch size or how many images are worked on at the same time. Now with this one, you need a very high-end PC if you want to go anywhere above 1, so I would recommend just leaving it set to 1. Below that, there’s an option called CFG scale, and this defines how closely Stable Diffusion should match the prompt that you enter in above. If you go higher, this will more carefully follow the prompt, and if you go lower, it’ll give Stable Diffusion a little bit more creative freedom. Here I’ll stick with the default of 7. Lastly, down at the very bottom, there’s something called the seed, and currently it’s set to -1. What this means is, every time you generate an image, you’ll get a different image. However, if you fix it to a specific number, let’s say 50, every time you run it, you’ll get this same exact image. Now for now, I just want it to be completely random, so I’ll enter in –1, that way I get a different image every time I click on generate. Up on top, you have many additional settings that you can look at and that you can configure, and this will help you tweak the results that you get, but this is beyond the scope of this video today. So, for now, let’s just click on generate and see what we get back for this prompt. Here I’ll click on generate. It’s now all done generating my images and remember my prompt was cookie monster in Times Square, and here I can click into the first one and this will show me a preview of all 10 images, or here I could click through, and I can see each individual image, and these are actually pretty good. Look at that. We have cookie monster in the foreground and then I had the depth of field, so we see that there’s that nice bokeh effect in the background. Now, of course, some of these are a little off. Here, I don’t know, it looks like Cookie Monster has four eyes, for whatever reason, but some of them are really good. This is pretty nice output. I could use this. All right, well, hopefully you were able to pull together some epic looking images using Stable Diffusion. To watch more videos like this one, please consider subscribing, and I’ll see you in the next video.

Related Topics

You must login to add an answer.

Hide picture