#!/bin/bash set -euo pipefail function download-model() { local _option=$1 local _filename=$2 local _url=$3 local _dir ! [ $# -eq 3 ] && (echo "usage: "; for o in checkpoint lora vae control-net embedding; do echo " \$ download-model --$o "; done) || true [ $# -eq 0 ] && return 0 || ! [ $# -eq 3 ] && (echo ""; echo "error - invalid number of arguments (expected 3, received $#)"; echo -n "\$ download-model $1"; (for arg in "${@: 2}"; do echo -n " \"${arg//\"/\\\"}\""; done) && echo "") && return 1 || true case ${_option,,} in --checkpoint) _dir="/app/stable-diffusion-webui/models/Stable-diffusion";; --lora) _dir="/app/stable-diffusion-webui/extensions/sd-webui-additional-networks/models/LoRA";; --vae) _dir="/app/stable-diffusion-webui/models/VAE";; --control-net) _dir="/app/stable-diffusion-webui/models/ControlNet";; --embedding) _dir="/app/stable-diffusion-webui/embeddings";; *) echo "error - unknown first argument: '$1' (valid options are --checkpoint, --lora, --vae, --control-net or --embedding):"; echo "\$ download-model $1 \"$2\" \"$3\""; return 1;; esac echo "\$ download-model $_option \"$2\" \"$3\"" ; echo "" aria2c --console-log-level=error -c -x 16 -s 16 -k 1M $_url -d $_dir -o $_filename && echo "" } ## ---------------------------- ## Adds a header to the webui on Hugging Face Spaces. sed -i -e '/demo:/r /app/stable-diffusion-webui/header_patch.py' /app/stable-diffusion-webui/modules/ui.py ## ---------------------------- ## Installing less models if $IS_SHARED_UI environment variable is set. if [ ${IS_SHARED_UI:-0} != 0 ]; then download-model --checkpoint "v1-5-pruned-emaonly.safetensors" "https://huggingface.co/runwayml/stable-diffusion-v1-5/resolve/39593d5650112b4cc580433f6b0435385882d819/v1-5-pruned-emaonly.safetensors" download-model --checkpoint "v1-5-pruned-emaonly.yaml" "https://huggingface.co/runwayml/stable-diffusion-v1-5/resolve/39593d5650112b4cc580433f6b0435385882d819/v1-inference.yaml" download-model --control-net "cldm_v15.yaml" "https://huggingface.co/webui/ControlNet-modules-safetensors/resolve/87c3affbcad3baec52ffe39cac3a15a94902aed3/cldm_v15.yaml" download-model --control-net "control_canny-fp16.safetensors" "https://huggingface.co/webui/ControlNet-modules-safetensors/resolve/87c3affbcad3baec52ffe39cac3a15a94902aed3/control_canny-fp16.safetensors" download-model --control-net "control_depth-fp16.safetensors" "https://huggingface.co/webui/ControlNet-modules-safetensors/resolve/87c3affbcad3baec52ffe39cac3a15a94902aed3/control_depth-fp16.safetensors" download-model --control-net "control_normal-fp16.safetensors" "https://huggingface.co/webui/ControlNet-modules-safetensors/resolve/87c3affbcad3baec52ffe39cac3a15a94902aed3/control_normal-fp16.safetensors" download-model --control-net "control_openpose-fp16.safetensors" "https://huggingface.co/webui/ControlNet-modules-safetensors/resolve/87c3affbcad3baec52ffe39cac3a15a94902aed3/control_openpose-fp16.safetensors" download-model --control-net "control_scribble-fp16.safetensors" "https://huggingface.co/webui/ControlNet-modules-safetensors/resolve/87c3affbcad3baec52ffe39cac3a15a94902aed3/control_scribble-fp16.safetensors" download-model --checkpoint "AtoZovyaRPGArtistTools15_sd15V1.safetensors" "https://civitai.com/api/download/models/10185" download-model --embedding "bad_prompt_version2.pt" "https://huggingface.co/datasets/Nerfgun3/bad_prompt/resolve/72fd9d6011c2ba87b5847b7e45e6603917e3cbed/bad_prompt_version2.pt" sed -i -e '/(modelmerger_interface, \"Checkpoint Merger\", \"modelmerger\"),/d' /app/stable-diffusion-webui/modules/ui.py sed -i -e '/(train_interface, \"Train\", \"ti\"),/d' /app/stable-diffusion-webui/modules/ui.py sed -i -e '/extensions_interface, \"Extensions\", \"extensions\"/d' /app/stable-diffusion-webui/modules/ui.py sed -i -e '/settings_interface, \"Settings\", \"settings\"/d' /app/stable-diffusion-webui/modules/ui.py rm -rf /app/stable-diffusion-webui/scripts /app/stable-diffusion-webui/extensions/deforum-for-automatic1111-webui /app/stable-diffusion-webui/extensions/stable-diffusion-webui-images-browser /app/stable-diffusion-webui/extensions/sd-civitai-browser /app/stable-diffusion-webui/extensions/sd-webui-additional-networks cp -f shared-config.json config.json cp -f shared-ui-config.json ui-config.json exit 0 fi ## End of lightweight installation for $IS_SHARED_UI setup. ## ---------------------------- ## env $IS_SHARED_UI is not set ## ---------------------------- ## Stable Diffusion 2.1 · 768 base model: #download-model --checkpoint "v2-1_768-ema-pruned.safetensors" "https://huggingface.co/stabilityai/stable-diffusion-2-1/resolve/36a01dc742066de2e8c91e7cf0b8f6b53ef53da1/v2-1_768-ema-pruned.safetensors" #download-model --checkpoint "v2-1_768-ema-pruned.yaml" "https://raw.githubusercontent.com/Stability-AI/stablediffusion/fc1488421a2761937b9d54784194157882cbc3b1/configs/stable-diffusion/v2-inference-v.yaml" ## Stable Diffusion 1.5 · 512 base model: #download-model --checkpoint "v1-5-pruned-emaonly.safetensors" "https://huggingface.co/stabilityai/sd-vae-ft-mse-original/resolve/main/vae-ft-mse-840000-ema-pruned.safetensors" #download-model --checkpoint "v1-5-pruned-emaonly.yaml" "https://huggingface.co/runwayml/stable-diffusion-v1-5/resolve/39593d5650112b4cc580433f6b0435385882d819/v1-inference.yaml" ## ---------------------------- ## LoRA (low-rank adaptation) · epi_noiseoffset v2: #download-model --lora "hyperfusion100k_v4.safetensors" "https://civitai.com/api/download/models/19987" #download-model --lora "jimLeeDCComicsMarvel_offset.safetensors" "https://civitai.com/api/download/models/10580" #download-model --lora "epi_noiseoffset2.safetensors" "https://civitai.com/api/download/models/16576" #download-model --lora "agneseInnocente_1.safetensors" "https://civitai.com/api/download/models/34144" #download-model --lora "seethru_v10.safetensors" "https://civitai.com/api/download/models/32083" #download-model --lora "CommunityLoraExtract_lora320comicbabesV1.safetensors" "https://civitai.com/api/download/models/33744" #download-model --lora "CommunityLoraExtract_lora320revanimated.safetensors" "https://civitai.com/api/download/models/33787" ## ---------------------------- ## VAE (variational autoencoder) · VAE 840k EMA: download-model --vae "vae-ft-mse-840000-ema-pruned.safetensors" "https://huggingface.co/stabilityai/sd-vae-ft-mse-original/resolve/main/vae-ft-mse-840000-ema-pruned.safetensors" download-model --vae "Grapefruit.vae.pt" "https://huggingface.co/iZELX1/Grapefruit/resolve/main/Grapefruit.vae.pt" download-model --vae "kl-f8-anime.ckpt" "https://huggingface.co/hakurei/waifu-diffusion-v1-4/resolve/main/vae/kl-f8-anime.ckpt" ## ---------------------------- ## ControlNet · Pre-extracted models: download-model --control-net "cldm_v15.yaml" "https://huggingface.co/webui/ControlNet-modules-safetensors/resolve/87c3affbcad3baec52ffe39cac3a15a94902aed3/cldm_v15.yaml" download-model --control-net "cldm_v21.yaml" "https://huggingface.co/webui/ControlNet-modules-safetensors/resolve/87c3affbcad3baec52ffe39cac3a15a94902aed3/cldm_v21.yaml" download-model --control-net "control_canny-fp16.safetensors" "https://huggingface.co/webui/ControlNet-modules-safetensors/resolve/87c3affbcad3baec52ffe39cac3a15a94902aed3/control_canny-fp16.safetensors" download-model --control-net "control_depth-fp16.safetensors" "https://huggingface.co/webui/ControlNet-modules-safetensors/resolve/87c3affbcad3baec52ffe39cac3a15a94902aed3/control_depth-fp16.safetensors" download-model --control-net "control_hed-fp16.safetensors" "https://huggingface.co/webui/ControlNet-modules-safetensors/resolve/87c3affbcad3baec52ffe39cac3a15a94902aed3/control_hed-fp16.safetensors" download-model --control-net "control_normal-fp16.safetensors" "https://huggingface.co/webui/ControlNet-modules-safetensors/resolve/87c3affbcad3baec52ffe39cac3a15a94902aed3/control_normal-fp16.safetensors" download-model --control-net "control_openpose-fp16.safetensors" "https://huggingface.co/webui/ControlNet-modules-safetensors/resolve/87c3affbcad3baec52ffe39cac3a15a94902aed3/control_openpose-fp16.safetensors" download-model --control-net "control_scribble-fp16.safetensors" "https://huggingface.co/webui/ControlNet-modules-safetensors/resolve/87c3affbcad3baec52ffe39cac3a15a94902aed3/control_scribble-fp16.safetensors" download-model --control-net "control_v1p_sd15_qrcode.safetensors" "https://huggingface.co/DionTimmer/controlnet_qrcode/resolve/main/control_v1p_sd15_qrcode.safetensors" download-model --control-net "control_v1p_sd15_qrcode.yaml" "https://huggingface.co/DionTimmer/controlnet_qrcode/resolve/main/control_v1p_sd15_qrcode.yaml" ## ---------------------------- ## Embedding #download-model --embedding "bad_prompt_version2.pt" "https://huggingface.co/datasets/Nerfgun3/bad_prompt/resolve/72fd9d6011c2ba87b5847b7e45e6603917e3cbed/bad_prompt_version2.pt" #download-model --embedding "easynegative.safetensors" "https://huggingface.co/embed/EasyNegative/resolve/main/EasyNegative.safetensors" #download-model --embedding "microwaist_01bEmbedding.pt" "https://civitai.com/api/download/models/5246" ## ---------------------------- ## Checkpoints: download-model --checkpoint "XenoBABES.safetensors" "https://huggingface.co/Xenos14/Checkpoints/resolve/main/XenoBABES.safetensors" download-model --checkpoint "XenoGASM_LCM-v5.safetensors" "https://huggingface.co/Xenos14/XenoREALITY/resolve/main/LCM/XenoGASM_LCM-v5.safetensors" download-model --checkpoint "XenoBABES_LCM.safetensors" "https://huggingface.co/Xenos14/XenoREALITY/resolve/main/LCM/XenoBABES_LCM.safetensors" download-model --checkpoint "XenoGASM-v5.safetensors" "https://huggingface.co/Xenos14/XenoREALITY/resolve/main/XenoGASM-v5.safetensors" download-model --checkpoint "XenoPHOBIA-v1.safetensors" "https://huggingface.co/Xenos14/XenoREALITY/resolve/main/XenoPHOBIA-v1.safetensors" download-model --checkpoint "XenoXTC-LCM-vTOON.safetensors" "https://huggingface.co/Xenos14/XenoREALITY/resolve/main/LCM/XenoXTC-LCM-vTOON.safetensors" download-model --checkpoint "Kitsch-In-Synch-LCM-v2.safetensors" "https://huggingface.co/Xenos14/TestBed/resolve/main/LCM/Kitsch-In-Synch-LCM-v2.safetensors" download-model --checkpoint "XenoREALITY-v2.safetensors" "https://huggingface.co/Xenos14/XenoREALITY/resolve/main/XenoREALITY-v2.safetensors" ## ---------------------------- ## Add additional models that you want to install on startup. Replace URL and FILENAME from the examples below with your values. ## Usage: ## download-model --checkpoint ## download-model --lora ## download-model --vae ## download-model --control-net ## download-model --embedding ## ---------------------------- ## Checkpoint · Example: # download-model --checkpoint "FILENAME" "URL" ## LORA (low-rank adaptation) · Example: # download-model --lora "FILENAME" "URL" ## VAE (variational autoencoder) · Example: # download-model --vae "FILENAME" "URL"