|
#!/bin/bash |
|
|
|
source /venv/main/bin/activate |
|
FORGE_DIR=${WORKSPACE}/stable-diffusion-webui-forge |
|
|
|
|
|
|
|
APT_PACKAGES=( |
|
|
|
|
|
) |
|
|
|
PIP_PACKAGES=( |
|
) |
|
EXTENSIONS=( |
|
"https://github.com/Bing-su/adetailer.git" |
|
"https://github.com/adieyal/sd-dynamic-prompts" |
|
"https://github.com/Koishi-Star/Euler-Smea-Dyn-Sampler.git" |
|
"https://github.com/DominikDoom/a1111-sd-webui-tagcomplete.git" |
|
"https://github.com/BlafKing/sd-civitai-browser-plus.git" |
|
"https://github.com/zanllp/sd-webui-infinite-image-browsing.git" |
|
"https://github.com/altoiddealer/--sd-webui-ar-plusplus" |
|
"https://github.com/Haoming02/sd-webui-tabs-extension.git" |
|
"https://github.com/Haoming02/sd-forge-couple.git" |
|
) |
|
|
|
CHECKPOINT_MODELS=( |
|
"https://huggingface.co/huchukato/favs/resolve/main/ckpt/aniversePonyXL_v60.safetensors" |
|
"https://huggingface.co/huchukato/favs/resolve/main/ckpt/autismmixSDXL_autismmixConfetti_256991.safetensors" |
|
"https://huggingface.co/huchukato/favs/resolve/main/ckpt/babes_12p5.safetensors" |
|
"https://huggingface.co/huchukato/favs/resolve/main/ckpt/beautifulGirls_v10.safetensors" |
|
"https://huggingface.co/huchukato/favs/resolve/main/ckpt/bemypony_Semirealanime.safetensors" |
|
"https://huggingface.co/huchukato/favs/resolve/main/ckpt/celestiquerealmixAtomix_v10.safetensors" |
|
"https://huggingface.co/huchukato/favs/resolve/main/ckpt/cyberrealisticPony_semiRealV36.safetensors" |
|
"https://huggingface.co/huchukato/favs/resolve/main/ckpt/incursiosMemeDiffusion_v27PDXL.safetensors" |
|
"https://huggingface.co/huchukato/favs/resolve/main/ckpt/magicalpony_3_628661.safetensors" |
|
"https://huggingface.co/huchukato/favs/resolve/main/ckpt/pimpmypony-v1-fp16-clip-fix.safetensors" |
|
"https://huggingface.co/huchukato/favs/resolve/main/ckpt/ponyDiffusionV6XL_v6StartWithThisOne_228616.safetensors" |
|
"https://huggingface.co/huchukato/favs/resolve/main/ckpt/ponyRealism_V23ULTRA.safetensors" |
|
"https://huggingface.co/huchukato/favs/resolve/main/ckpt/prefectPonyXL_v50.safetensors" |
|
"https://huggingface.co/huchukato/favs/resolve/main/ckpt/snowpony_v10.safetensors" |
|
"https://huggingface.co/huchukato/favs/resolve/main/ckpt/waiANINSFWPONYXL_v140.safetensors" |
|
) |
|
|
|
UNET_MODELS=( |
|
|
|
) |
|
|
|
LORA_MODELS=( |
|
"https://huggingface.co/huchukato/favs/resolve/main/loras/nsfw/Expressive_H-000001.safetensors" |
|
"https://huggingface.co/huchukato/favs/resolve/main/loras/nsfw/incase_style_v3-1_ponyxl_ilff_356767.safetensors" |
|
"https://huggingface.co/huchukato/favs/resolve/main/loras/pony/S1_Dramatic_Lighting_v3_1184559.safetensors" |
|
"https://huggingface.co/huchukato/favs/resolve/main/loras/pony/d3t41l3dXLP_404816.safetensors" |
|
"https://huggingface.co/huchukato/favs/resolve/main/loras/pony/43stl1ght1ngXLP2_348038.safetensors" |
|
"https://huggingface.co/huchukato/favs/resolve/main/loras/pony/V3n3t14nXLP2_404377.safetensors" |
|
) |
|
|
|
VAE_MODELS=( |
|
|
|
"https://huggingface.co/huchukato/favs/resolve/main/VAE/ponyStandardVAE_v10.safetensors" |
|
"https://huggingface.co/stabilityai/sdxl-vae/resolve/main/sdxl_vae.safetensors" |
|
) |
|
|
|
ESRGAN_MODELS=( |
|
"https://huggingface.co/ai-forever/Real-ESRGAN/resolve/main/RealESRGAN_x4.pth" |
|
"https://huggingface.co/FacehugmanIII/4x_foolhardy_Remacri/resolve/main/4x_foolhardy_Remacri.pth" |
|
"https://huggingface.co/Akumetsu971/SD_Anime_Futuristic_Armor/resolve/main/4x_NMKD-Siax_200k.pth" |
|
) |
|
|
|
CONTROLNET_MODELS=( |
|
) |
|
|
|
|
|
|
|
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[@]}" |
|
|
|
|
|
export GIT_CONFIG_GLOBAL=/tmp/temporary-git-config |
|
git config --file $GIT_CONFIG_GLOBAL --add safe.directory '*' |
|
|
|
|
|
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}" |
|
provisioning_download "${url}" "${dir}" |
|
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" |
|
} |
|
|
|
function provisioning_has_valid_hf_token() { |
|
[[ -n "$HF_TOKEN" ]] || return 1 |
|
url="https://huggingface.co/api/whoami-v2" |
|
|
|
response=$(curl -o /dev/null -s -w "%{http_code}" -X GET "$url" \ |
|
-H "Authorization: Bearer $HF_TOKEN" \ |
|
-H "Content-Type: application/json") |
|
|
|
|
|
if [ "$response" -eq 200 ]; then |
|
return 0 |
|
else |
|
return 1 |
|
fi |
|
} |
|
|
|
function provisioning_has_valid_civitai_token() { |
|
[[ -n "$CIVITAI_TOKEN" ]] || return 1 |
|
url="https://civitai.com/api/v1/models?hidden=1&limit=1" |
|
|
|
response=$(curl -o /dev/null -s -w "%{http_code}" -X GET "$url" \ |
|
-H "Authorization: Bearer $CIVITAI_TOKEN" \ |
|
-H "Content-Type: application/json") |
|
|
|
|
|
if [ "$response" -eq 200 ]; then |
|
return 0 |
|
else |
|
return 1 |
|
fi |
|
} |
|
|
|
|
|
function provisioning_download() { |
|
if [[ -n $HF_TOKEN && $1 =~ ^https://([a-zA-Z0-9_-]+\.)?huggingface\.co(/|$|\?) ]]; then |
|
auth_token="$HF_TOKEN" |
|
elif |
|
[[ -n $CIVITAI_TOKEN && $1 =~ ^https://([a-zA-Z0-9_-]+\.)?civitai\.com(/|$|\?) ]]; then |
|
auth_token="$CIVITAI_TOKEN" |
|
fi |
|
if [[ -n $auth_token ]];then |
|
wget --header="Authorization: Bearer $auth_token" -qnc --content-disposition --show-progress -e dotbytes="${3:-4M}" -P "$2" "$1" |
|
else |
|
wget -qnc --content-disposition --show-progress -e dotbytes="${3:-4M}" -P "$2" "$1" |
|
fi |
|
} |
|
|
|
|
|
if [[ ! -f /.noprovisioning ]]; then |
|
provisioning_start |
|
fi |