How to Use Google Colab to Run Web GUI to Draw AI Images
If you have a browser, you will be able to use Google Colab to run Stable Diffusion Web UI created by ATOMATIC1111, which has github project: https://github.com/AUTOMATIC1111/stable-diffusion-webui
In this post, I am going to show how to write your own notebook and customize the code to have more functions to meet your presonal customization requirements.
Stable Diffusion Web UI Introduction
Following sections is mostly coming from this blog post: https://ivonblog.com/en-us/posts/google-colab-stable-diffusion-webui/
A browser interface based on Gradio library for Stable Diffusion.
Github: https://github.com/AUTOMATIC1111/stable-diffusion-webui
Steps to Run Stable Diffusion Web UI at Colab
-
Go to Google Colab, click "New notebook". Or from File menu's drop down list, select New notebook.
-
In the new notebook, copy & paste following example code.
-
First we mount the Drive to
/content/drive
. And create a new folder (sd-webui-files) for storing files on your google drive's root folder.
|
|
- Install dependencies
|
|
- Clone SD WebUI directly from ATOMATIC1111’s repo
|
|
- Download checkpoint models from Hugging Face. I prefer to use Anything model for generating anime art. Or you can use original Stable Diffusion model for generating realistic arts.
|
!wget -nc -P /content/drive/MyDrive/sd-webui-files/stable-diffusion-webui/models/Stable-diffusion https://huggingface.co/andite/anything-v4.0/resolve/main/anything-v4.5-pruned.safetensors
|
- There are some issues of switching branches after launching SD WebUI. Thus, add these lines to fix them.
|
|
- Finally, we will have python to launch the WebUI. We use
--xformers
to decrease the consumption of VRAM. By adding--enable-insecure-extension-access
we can install extensions from URL in WebUI without gettingAssertionError: extension access disabed
.
|
|
- Here is the full code
|
|
-
Click Edit → Notebook Settings →Change Hardware accelerator type to use GPU as Hardware accelerator. Click Save.
-
If you have not enabled GPU, the running result will show you torch can not use GPU error. The process will be stopped from there. You will have to enable GPU and re-run the notebook codes again.
-
Click Run button beside the code to run the cell, wait for 5 minutes.
-
Click generated Gradio links (expired after 72 hours).
-
Now we are ready to use Stable Diffusion WebUI.
Run Simplified Code After First Time Run
Now we have installed SD WebUI on Google drive. Even we closed our instance. Don’t worry, your data and progress has been stored on your Google Drive. It is about 4GB data stored on your Google Drive folders.
Because we had downloaded all required files, replace the code in the cell with these lines:
|
|
This will install requirements while running SD WebUI and start SD WebUI from our Google Drive. The Gradio link should be ready in 2 minutes. You might got the following warning message about permitting notebook to access Google Drive Files.
共有 0 条评论