Unlimited FREE AI Art - RUN Automatic1111 (Stable Diffusion) Google Colab for FREE

LARRUZ walks through running Automatic1111 Stable Diffusion on free Google Colab with GPU. You'll set up the environment, pick models, launch the web UI, and generate images by tweaking parameters like sampler, steps, and CFG scale.
Chapters
Midgen is great, but stable diffusion is even better because of the availability of free custom models. Today I'm going to show you how to run stable diffusion in automatic 1111 web UI using Google Colab. The best part is it's free and you don't need a powerful computer to run it. We will use a jupyter notebook. The link is in the description of the video. So let's get started. Before running the notebook, let's make sure that it's using the gpu. So come click on run type. Then change runtime type and make sure that for hardware accelerator GPU is selected. Click GPU and hit save. Next click Connect. It simply allocates you an instance on Google Cloud. So now you can see different resources. For example the RAM that you have, GPU RAM and then the disk usage. So you will notice there are different blocks. Some of them are code blocks. They have this play button in front of it. In order to execute this code, you simply click on this or you press Control enter on the keyboard. So let me run the first block. This blocks wants to connect to our Google Drive. Click Connect to Google Drive and then it will ask to connect to your account. So just allow it. Okay, so the next code block simply goes to the the main repo for automatic 1111 and it will update it and install the repo from there. So if you double click on it, you will be able to see the actual code that is wr. So let's click on this. If you don't want to see the code, you simply come here, the three dots and then you can click hide code. This will take a little bit of time. So this is done. Let's run the second block. It will simply download and install the libraries that are required to run automatic 1111. So the next block lets you download different stable diffusion models. So by default there are four different options that you can select from. So that's stable diffusion 1.57.68 pixel from version 2.1. So I'm going to select this one. But the beauty of an automatic 11.11 is that you can download any custom model and use it. So for example, if you have a folder on Google Drive, you can put the path and you can save all different models that you have. So one possible place that you probably want to look at it is this CVIT AI where people have trained different models and they're available for downloading. Well, we'll walk through this process later on in this tutorial. Right? But for the time being I'm simply selecting the version 2.1. If you have a model link, you can actually provide it here. For example, hugging face types, different Stable Diffusion models, you can simply copy the link and put it here. All right, so let's run this code block. So I already ran this. That's why it says that the model already exists. So I want to show you the file structure once you connect your instance and also connect your Google Drive. So you will see all your Google Drive folders here, right? In this case, it created this SD folder. And then within the SD folder you have the Stable Diffusion Web UI and then Stable Diffusion folder. And within Stable Diffusion Web UI you have different extensions and these different folders. So for example, here is the Models folder. And within the model folders you see this Stable Diffusion folder. So if you want to put any of your newer model, then you simply need to put them in this folder and you will be able to use them. This last section is for controlnet models. I'm going to select Canny. You can select. You can download all the control. Net models, but keep in mind that you have only 15 gigabytes of space in your Google Drive if you are on the preplan. So it will eat up a lot of space. That's why I'm simply only downloading the Canny. But there are all these different models as well that you can utilize. Okay, so next we are going to run Stable Diffusion, the web ui. Now here is an option. You can actually define username with password. So whenever you run it, it will ask you to enter that username and password for security purposes. But I'm going to just ignore this for the time being and simply run this cell. Okay, so our web app is up and running at this address. Copy this address and paste it in your web browser. The automatic 1111 web UI has several components. We are going to go over some of the most widely used ones in this introductory video. So the first one is this Stable Diffusion checkpoint. It will list all the models that you currently have. Currently we only have one model, but if you upload more models to the model folders in the Stable Diffusion Web ui, you are going to see them next. There are several tabs. So the first one is Text to image. So basically it has all the options to generate images from text. Then the second one is Image to Image. So you can provide a reference image along with your text and that will generate images based on both the image as well as the text prompt. Then you have some extras. PNG information, Checkpoint, mergers. And for the rest of the Settings, we will go over those in future videos. So this first text box is the prompt. Here you put the text what you want to see in the images. Then there's a negative prompt. If there are certain things you don't want to see in the image, you put them here. Next is the sampling algorithm. So that's basically the algorithm used for denoising process. You have a whole bunch of different options. Usually I like to work with this. DMP2M Keras sampling steps basically defines the number of steps or the number of iterations the sampling algorithm will take for denoising process. If you keep it higher, it will generate better results, but it's going to take much longer. Next, you can define the width and height of the image in pixels. That will define the size of the output image. You should at least set one side to 512 pixels for V1 models. For example, for a portrait image, we will set the width to 512 and the height to 768. That will give us an aspect ratio of 2 by 3 to understand the rest of the parameters. Let's look at an example. So I'm going to use this playground AI to get an inspiration for a prompt. So let's say I like this image, right? So there is a prompt. I'm going to copy the positive prompt. Then there is a negative prompt as well. Paste the positive prompt, copy the negative prompt, Paste it here. Okay. And let's make it a portrait. So 768. I'll keep the rest to default values. Right? Let's click Generate and it will start generating the image. Okay, so here's our generated image. Not too bad. Given that it's a very different model from what we just used, you can actually generate multiple images. So let's say if we increase the bite size to four. So instead of a single image, it will generate four different images. So here are the results. It generated four different images and then put them together in this one image. And one thing I noticed was that the prompt says English man, but for some reason it also put women in there. Maybe we can actually add this to negative prompt. So let's say woman. If you run the same prompt multiple times, you will see different results. So for example, let's go back to batch one and generate the results. So here are the results. But if I were to run this again, I might see a completely different phase. So for the second iteration, here are the results which are very different from what we saw before. This is controlled by this parameter called seed. So it's a random number generator which determines the output. So every time you run a prompt, it will start at the random point and that point is determined by the seed. You actually see all the parameters that were used. Right. So for example, here's our prompt, the negative prompt, and then all the different parameters, including the sampler, a number of steps, cfd. We're going to talk about this in a second. And then here's the sludge number, which is the seed. So if you copy the seed and paste it here and run this prompt again, you should see a very similar output. Okay, so here is the result of our new run, and this is the result of our previous run. So they are very similar because the starting point is the same. And if you put minus one here, that will simply start with the random seed. But if you put another number, that's going to be the starting point. And you can actually use this button, the recycle button, to reuse seed from last generation. So if you click on this, that is going to be same as the seed it's showing over here. When people share their work, they actually share these parameters so that you are able to reproduce them if you want. Okay. The last parameter that we're going to be discussing in this video is CFT scale scale, which stands for classifier free guidance scale. It is a parameter that controls how much the model should respect your prompt. If you keep it high, then it will give more weight to the prompt. And if you keep it really low, it will mostly ignore your prompt. In order to explain this, I have this very simple prompt, wolf wearing sunglasses. To keep it consistent, I'm going to be using a fixed seat. So let's first run it with a CFD scale of 7, which is pretty much the default value. Okay, so we do get a wolf and it is wearing some sort of sunglasses. Let's keep it very high. So let's say something around 20. Let's generate it again. So we see that it's following the prompt even more closely. But let's see what happens if we try a very small value. That should give it more creative freedom. CFG scale of 1. In this case, you see there are some sort of sunglasses, but we don't even see the wolf. Let's bring it up to three. Let's generate it again. So now there is a wolf on eyeglasses, but this is not exactly what we want. So you can see that it actually controls how much important model gives to your prompt. In this quick video, we cover text to image using stable diffusion in the subsequent videos. We are going to go over all the other parameters and these different tabs options. Hope you found this useful. If you did, please consider subscribing and liking the video. Thanks for watching. See you in the next one.










