Last active
July 29, 2025 23:58
-
-
Save kiwina/728518ceffbcb0b439b04ad526ab4c6e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
source /venv/main/bin/activate | |
FORGE_DIR=${WORKSPACE}/stable-diffusion-webui-forge | |
# ===== PACKAGES (Optional Extra) ===== | |
APT_PACKAGES=( | |
# Add any apt packages here | |
) | |
PIP_PACKAGES=( | |
# Add Python packages here | |
) | |
# ===== MODELS ===== | |
CHECKPOINT_MODELS=( | |
"https://huggingface.co/SG161222/Realistic_Vision_V6.0_B1_noVAE/resolve/main/Realistic_Vision_V6.0_NV_B1.safetensors" | |
"https://huggingface.co/certified/dreamlike-photoreal-2.0/resolve/main/dreamlike-photoreal-2.0.safetensors" | |
) | |
LORA_MODELS=( | |
"https://huggingface.co/OedoSoldier/detail-tweaker-lora/resolve/main/add_detail.safetensors" | |
) | |
VAE_MODELS=( | |
"https://huggingface.co/stabilityai/sd-vae-ft-mse-original/resolve/main/vae-ft-mse-840000-ema-pruned.safetensors" | |
) | |
CONTROLNET_MODELS=( | |
"https://huggingface.co/lllyasviel/ControlNet-v1-1/resolve/main/control_v11p_sd15_canny.pth" | |
"https://huggingface.co/lllyasviel/ControlNet-v1-1/resolve/main/control_v11f1p_sd15_depth.pth" | |
"https://huggingface.co/lllyasviel/ControlNet-v1-1/resolve/main/control_v11p_sd15_openpose.pth" | |
) | |
UNET_MODELS=() | |
ESRGAN_MODELS=() | |
### DO NOT EDIT BELOW HERE ### | |
function provisioning_start() { | |
provisioning_print_header | |
provisioning_get_apt_packages | |
provisioning_get_extensions | |
provisioning_get_pip_packages | |
provisioning_get_files "${FORGE_DIR}/models/Stable-diffusion" "${CHECKPOINT_MODELS[@]}" | |
provisioning_get_files "${FORGE_DIR}/models/Lora" "${LORA_MODELS[@]}" | |
provisioning_get_files "${FORGE_DIR}/models/VAE" "${VAE_MODELS[@]}" | |
provisioning_get_files "${FORGE_DIR}/models/ControlNet" "${CONTROLNET_MODELS[@]}" | |
# Avoid git errors because we run as root but files are owned by 'user' | |
export GIT_CONFIG_GLOBAL=/tmp/temporary-git-config | |
git config --file $GIT_CONFIG_GLOBAL --add safe.directory '*' | |
# Start and exit because webui will probably require a restart | |
cd "${FORGE_DIR}" | |
LD_PRELOAD=libtcmalloc_minimal.so.4 \ | |
python launch.py \ | |
--skip-python-version-check \ | |
--no-download-sd-model \ | |
--do-not-download-clip \ | |
--no-half \ | |
--port 11404 \ | |
--exit | |
provisioning_print_end | |
} | |
function provisioning_get_apt_packages() { | |
if [[ -n $APT_PACKAGES ]]; then | |
sudo $APT_INSTALL ${APT_PACKAGES[@]} | |
fi | |
} | |
function provisioning_get_pip_packages() { | |
if [[ -n $PIP_PACKAGES ]]; then | |
pip install --no-cache-dir ${PIP_PACKAGES[@]} | |
fi | |
} | |
function provisioning_get_extensions() { | |
for repo in "${EXTENSIONS[@]}"; do | |
dir="${repo##*/}" | |
path="${FORGE_DIR}/extensions/${dir}" | |
if [[ ! -d $path ]]; then | |
printf "Downloading extension: %s...\n" "${repo}" | |
git clone "${repo}" "${path}" --recursive | |
fi | |
done | |
} | |
function provisioning_get_files() { | |
if [[ -z $2 ]]; then return 1; fi | |
dir="$1" | |
mkdir -p "$dir" | |
shift | |
arr=("$@") | |
printf "Downloading %s model(s) to %s...\n" "${#arr[@]}" "$dir" | |
for url in "${arr[@]}"; do | |
printf "Downloading: %s\n" "${url}" | |
wget -qnc --content-disposition --show-progress -e dotbytes="${3:-4M}" -P "$dir" "$url" | |
printf "\n" | |
done | |
} | |
function provisioning_print_header() { | |
printf "\n##############################################\n# #\n# Provisioning container #\n# #\n# This will take some time #\n# #\n# Your container will be ready on completion #\n# #\n##############################################\n\n" | |
} | |
function provisioning_print_end() { | |
printf "\nProvisioning complete: Application will start now\n\n" | |
} | |
# Allow user to disable provisioning if they started with a script they didn't want | |
if [[ ! -f /.noprovisioning ]]; then | |
provisioning_start | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment