Save thousands of dollars! Stable Diffusion Installation Tutorial on Google Colab

written in front

If you're an artist or designer, you probably already know how to create with AI. Still, for those just getting started with AI creation, the high-performance computers and expensive GPUs required can be confusing.

Using stable diffusion to create AI paintings requires a lot of memory and computing resources. If you don't have GPU hardware support, your computer can't run these models at all. Even if you have a GPU in your computer, it may take a long time to output the image due to the small video memory, or an error will be reported when multiple images are calculated.

Fortunately, you only need to install Stable Diffusion on Google Colab to run programs in the cloud and get 16G of video memory for free. This can not only help you increase the calculation speed, but also save a lot of time and thousands of dollars to buy a GPU.

In this article, we will introduce how to install Stable Diffusion on Google Colab, and how to use it for AI creation. Whether you are just getting started with AI creation or you are already an experienced artist, I hope this article can help you.

installation steps

Step 1: Open the github repository

Open the github address, and switch the branch to the drive branch. This github warehouse is the installation source code of stable diffusion on Colab.

GitHub - camenduru/stable-diffusion-webui-colab: stable diffusion webui colab

​We can see that there are three links here

  • The first one is one time install and update, which is a script installed to Colab

  • The second link is run, which is a script running on Colab

  • The third link is add model, which is to add a new model in stable diffusion

In this tutorial we will only use the first two, add model will use other better methods.

Step 2: Install

We are going to open the first script here by holding down control and then open in Collab, and then install.ipynb will be opened in colab.

First click "Copy to Drive", then we will be prompted to log in to our Google account, just log in to our Google account.

​After the login is complete, install.ipynb will be copied to your Google drive cloud disk and renamed as a copy of "install.ipynb". We need to delete the extra characters and rename the script to "install.ipynb".

​At this point, we can see that our file name has been modified successfully. Next, you can click the "Run" button. After clicking, it will be displayed on the right side that google colab allocates resources to us. After the allocation is complete, you can see that there is only memory and disk, and no GPU.

​We need to change the settings so that google allocates GPU resources to us. In "Modify" in the upper left corner, click "Notebook Settings"

​After the hardware accelerator is changed to "GPU", click "Save"

​At this point, we can see that Google has allocated GPU resources to us. Then we click the "Run" button on the left, and it reminds us whether to allow access to Google cloud disk, we can allow it.

​After running, when the log prints "installed", it means that our installation process has been successful.

​Step 3: Run

Basically the same as step 2, first press and hold control and open in Collab, and then run.ipynb will be opened in colab. After opening, "Copy to Drive", modify the file name after copying, and remove redundant characters. At this time, after clicking "run" on the left side of the figure below, Colab will prompt us that there are too many sessions. This is because Colab can only allocate resources to us once at a time, but our previous install window is already using the resources allocated to us. So just turn off the resource of install.ipynb according to the prompt.

After running, you need to wait for a while. When the webUI Colab URL is printed out, it means that it has been opened successfully.

There are four links here, basically all of them are available, for example, if we click on the first link,

​At this time, it will pop up the stable diffusion interface, which means that we have successfully installed it!

​Step 4: Download the model

At this point, stable diffusion has been successfully installed, so how to install the model you need? We can use CivitAi plugin. Take the download of the Guofeng 3 model in https://civitai.com/ as an example

​First we select the CivitAi plug-in, then check "Checkpoint" and "Search by term", then enter "guofeng" in "Search term", and then click "Get List".

​At this time, select "Guofeng 3 GuoFeng3" in "Model", and select "v3.3-Guofeng 2 GuoFeng3" in "Version", and when "Download Url" appears, you can click "4th -Download Model" to download the model.

Let's go back to the google colab interface. When the log prints out successfully downloaded, it means that the model has been downloaded successfully.

​At this point in the stable diffusion interface, you can see the model we downloaded.

​Step 5: Start creating

Let AI generate a painting for us.

Positive prompts:

best quality, masterpiece, highres, 1girl,blush,(seductive smile:0.8),star-shaped pupils,china hanfu,hair ornament,necklace, jewelry,Beautiful face,upon_body, tyndall effect,photorealistic, dark studio, rim lighting, two tone lighting,(high detailed skin:1.2), 8k uhd, dslr, soft lighting, high quality, volumetric lighting, candid, Photograph, high resolution, 4k, 8k, Bokeh

Reverse cue words:

(((simple background))),monochrome ,lowres, bad anatomy, bad hands, text, error, missing fingers, extra digit, fewer digits, cropped, worst quality, low quality, normal quality, jpeg artifacts, signature, watermark, username, blurry, lowres, bad anatomy, bad hands, text, error, extra digit, fewer digits, cropped, worst quality, low quality, normal quality, jpeg artifacts, signature, watermark, username, blurry, ugly,pregnant,vore,duplicate,morbid,mut ilated,tran nsexual, hermaphrodite,long neck,mutated hands,poorly drawn hands,poorly drawn face,mutation,deformed,blurry,bad anatomy,bad proportions,malformed limbs,extra limbs,cloned face,disfigured,gross proportions, (((missing arms))),(((missing legs))), (((extra arms))),(((extra legs))),pubic hair, plump,bad legs,error legs,username,blurry,bad feet

Other settings: CFG scale:9 ; Steps:30 ; Sampler : Euler a ; Seed : 3556647833

After clicking Generate, you can get the picture drawn by AI.

epilogue

Well, from now on, give full play to your creativity!

Guess you like

Origin blog.csdn.net/lb5482464/article/details/130191721