Install Stable Diffusion Locally with ControlNet
April 11, 2023 - Written by Ho Chien Chang - 20 min read
#StableDiffusion #PC
This article covers:
1- Install Git
Use the link below to down download git 2.37.3
https://github.com/git-for-windows/git/releases/download/v2.37.3.windows.1/Git-2.37.3-64-bit.exe
Or you can go to the official website to download the latest version at the time you are installing
Mac: install Homebrew
(/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)")
copy paste on terminal
2- Install python 3.10.6
https://www.python.org/ftp/python/3.10.6/python-3.10.6-amd64.exe
Later version of python may cause some trouble installing stable diffusion, the 3.10.6 is recommanded at the time being. We can always up grade later.
Remember !!!!! make sure you choose "add to PATH when installing"Mac: install python
copy paste "brew install cmake protobuf rust python@3.10 git wget" on terminal
3- Create a Folder that you want to install stable diffusion:
Create the directory for you stable diffusion installation. Remember to install stable diffusion on the disk with plenty of memory.
Mac: use terminal to direct into the directory that you want Stable diffusion to be installed in
cd (Yourfilepath)
git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui
4- right click and open the folder in terminal
After you created the file, go into the file and right click on the empty space. Then copy and paste the code below into the terminal and press "Enter"
git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui
5- Download Official Stable diffusion models
The basis for it all, will perform decently for a wide variety of subjects However, for many purposes you may find vanilla SD lagging behind it's competitors_
(_Note: 1.5 produces much better results than 2.0 and 2.1. (https://www.assemblyai.com/blog/stable-diffusion-1-vs-2-what-you-need-to-know/)
v1.4
v1.5
V2.0
V2.1
Alternate Models/Mixes (Recommended)
Remember to move the model you've downloaded to models/stable-diffusion.
6- This step is optional. Rename Model name for default setting
Rename your .ckpt or .safetensors file file to "model.ckpt" or "model.safetensors", and place it in the `/models/Stable-diffusion`folder
-_You can have as many models as you want in the folder, "model" is just the one it will load by default_
7- (Optional):** Reduce the run time of stable diffusion if your device is not heavy duty.
This reduces VRAM, and allows you to generate at larger resolutions or batch sizes for a <10% loss in raw generation speed (For me, singular results were slightly slower, but generating with a batch size of 4 made each result **25% faster** on average) This is recommended for _most_ users
-Edit `webui-user.bat`
graphic card Ram below 8g
-Change `COMMANDLINE_ARGS=` to `COMMANDLINE_ARGS=--xformers`
graphic card Ram below 4g
-Change `COMMANDLINE_ARGS=` to `COMMANDLINE_ARGS=--xformers --medvram`
graphic card Ram below 2g
-Change `COMMANDLINE_ARGS=` to `COMMANDLINE_ARGS=--xformers --medvram --lowvram`
add "git pull" onto the next line
Note: If you copy the whole file of stable diffusion from other people, delete the venv folder and the python path in the webui-user.bat file. than continue.
8- Launch `webui-user.bat`, Open it as normal user, **not** as administrator.
- Wait patiently while it installs dependencies and does a first time run.
It may _seem_ "stuck" but it isn't. It may take up to 10-15 minutes.
And you're done!
mac:
# 进到stable-diffusion-webui目录
cd (yourfilepath)/stable-diffusion-webui
# 运行
./webui.sh
9- Press the local URL to run the Web UI
Copy and paste the local web ui URL to your browser and you'll be able to use stabe diffiusion! Have fun!
10- Installing ControlNet for Stable diffusion
The official github repository for https://github.com/lllyasviel/ControlNet
Go to Extensions and pick install from URL
Paste "https://github.com/Mikubill/sd-webui-controlnet.git"
Then press install.
If you have successfully downloaded controlnet, you'll see controlnet at the bottom column.
After installing ControlNet, download all the ControlNet model from the link below:
https://huggingface.co/lllyasviel/ControlNet/tree/main/models
At last move all the models that you downloaded into extensions/sd=webui-controlnet/models
11- Go to settings and reload UI
12- (Optional) Go to settings and check these two boxes to use ControlNet trouble free
By completing all the steps above, you'll be all set to use stable diffusion on local computer with controlNet included.
See my new blog for further information on how to use controlnet!