スクリプト一発でStable Diffusion WebUIを立てる

#2023.03.13: CivitAIがファイル公開方式を変更したようで、下記スクリプトだとファイルを取得不可能。

手作業でやるのが面倒なので、スクリプトにした。別に難しいことはしてない。

#!/bin/bash

# Install venv
sudo apt-get update
sudo apt-get -y install python3.8-venv

# Install AUTOMATIC1111
git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui

cd stable-diffusion-webui/

# Enable Link Sharing
echo 'export COMMANDLINE_ARGS="--listen --enable-insecure-extension-access --xformers --no-half-vae"' >> webui-user.sh

# Install OpenPose-Editor / ControlNet
cd extensions/
git clone https://github.com/fkunn1326/openpose-editor
git clone https://github.com/Mikubill/sd-webui-controlnet
cd ../

# Install VAE, models, and so on
cd models/

# Install VAE
mkdir VAE
cd VAE/
curl -LOJ https://huggingface.co/AIARTCHAN/aichan_blend/resolve/main/vae/Anything-V3.0.vae.safetensors
cd ../

# Install Lora (2B (NieR:Automata) LoRA / YorHA edition)
mkdir Lora
cd Lora/
curl -LOJ https://civitai.com/api/download/models/6031
cd ../

# Install models
mkdir Stable-diffusion
cd Stable-diffusion/
# RealDosMix
curl -LOJ https://civitai.com/api/download/models/8137
# ChilloutMix
curl -LOJ https://civitai.com/api/download/models/11745
# SunshineMix & SunlightMix
curl -LOJ https://civitai.com/api/download/models/13510
cd ../

# Install ControlNet
mkdir ControlNet
cd ControlNet
curl -LOJ https://huggingface.co/webui/ControlNet-modules-safetensors/resolve/main/control_canny-fp16.safetensors
curl -LOJ https://huggingface.co/webui/ControlNet-modules-safetensors/resolve/main/control_depth-fp16.safetensors
curl -LOJ https://huggingface.co/webui/ControlNet-modules-safetensors/resolve/main/control_openpose-fp16.safetensors
cd ../

cd ../

# Install EasyNegative
cd embeddings/
curl -LOJ https://civitai.com/api/download/models/9208
cd ../

./webui.sh

# After accessing WebUI, config.json will be generated
# Enable VAE
# sed -i.orig 's/\"quicksettings\": \"sd_model_checkpoint/\"quicksettings\": \"sd_model_checkpoint,sd_vae/' config.json