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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
|
| 3 |
+
# This file will be sourced in init.sh
|
| 4 |
+
|
| 5 |
+
# https://raw.githubusercontent.com/ai-dock/comfyui/main/config/provisioning/default.sh
|
| 6 |
+
|
| 7 |
+
# Packages are installed after nodes so we can fix them...
|
| 8 |
+
|
| 9 |
+
#DEFAULT_WORKFLOW="https://..."
|
| 10 |
+
|
| 11 |
+
APT_PACKAGES=(
|
| 12 |
+
#"package-1"
|
| 13 |
+
#"package-2"
|
| 14 |
+
)
|
| 15 |
+
|
| 16 |
+
PIP_PACKAGES=(
|
| 17 |
+
#"package-1"
|
| 18 |
+
#"package-2"
|
| 19 |
+
)
|
| 20 |
+
|
| 21 |
+
NODES=(
|
| 22 |
+
"https://github.com/ltdrdata/ComfyUI-Manager"
|
| 23 |
+
"https://github.com/cubiq/ComfyUI_essentials"
|
| 24 |
+
"https://github.com/ClownsharkBatwing/RES4LYF"
|
| 25 |
+
"https://github.com/ltdrdata/ComfyUI-Impact-Pack"
|
| 26 |
+
"https://github.com/ltdrdata/ComfyUI-Impact-Subpack"
|
| 27 |
+
"https://github.com/yolain/ComfyUI-Easy-Use"
|
| 28 |
+
"https://github.com/city96/ComfyUI-GGUF"
|
| 29 |
+
"https://github.com/rgthree/rgthree-comfy"
|
| 30 |
+
"https://github.com/Kosinkadink/ComfyUI-VideoHelperSuite"
|
| 31 |
+
)
|
| 32 |
+
|
| 33 |
+
CHECKPOINT_MODELS=(
|
| 34 |
+
|
| 35 |
+
)
|
| 36 |
+
|
| 37 |
+
UNET_MODELS=(
|
| 38 |
+
"https://huggingface.co/QuantStack/Wan2.2-T2V-A14B-GGUF/resolve/main/HighNoise/Wan2.2-T2V-A14B-HighNoise-Q6_K.gguf"
|
| 39 |
+
"https://huggingface.co/QuantStack/Wan2.2-T2V-A14B-GGUF/resolve/main/LowNoise/Wan2.2-T2V-A14B-LowNoise-Q6_K.gguf"
|
| 40 |
+
)
|
| 41 |
+
|
| 42 |
+
LORA_MODELS=(
|
| 43 |
+
#"https://civitai.com/api/download/models/16576"
|
| 44 |
+
"https://huggingface.co/Kijai/WanVideo_comfy/resolve/main/Wan22-Lightning/Wan2.2-Lightning_T2V-v1.1-A14B-4steps-lora_HIGH_fp16.safetensors"
|
| 45 |
+
"https://huggingface.co/Kijai/WanVideo_comfy/resolve/main/Wan22-Lightning/Wan2.2-Lightning_T2V-v1.1-A14B-4steps-lora_LOW_fp16.safetensors"
|
| 46 |
+
)
|
| 47 |
+
|
| 48 |
+
VAE_MODELS=(
|
| 49 |
+
"https://huggingface.co/stabilityai/sdxl-vae/resolve/main/sdxl_vae.safetensors"
|
| 50 |
+
"https://huggingface.co/Comfy-Org/Wan_2.2_ComfyUI_Repackaged/resolve/main/split_files/vae/wan_2.1_vae.safetensors"
|
| 51 |
+
|
| 52 |
+
)
|
| 53 |
+
|
| 54 |
+
ESRGAN_MODELS=(
|
| 55 |
+
"https://huggingface.co/ai-forever/Real-ESRGAN/resolve/main/RealESRGAN_x4.pth"
|
| 56 |
+
"https://huggingface.co/FacehugmanIII/4x_foolhardy_Remacri/resolve/main/4x_foolhardy_Remacri.pth"
|
| 57 |
+
"https://huggingface.co/Akumetsu971/SD_Anime_Futuristic_Armor/resolve/main/4x_NMKD-Siax_200k.pth"
|
| 58 |
+
)
|
| 59 |
+
|
| 60 |
+
CONTROLNET_MODELS=(
|
| 61 |
+
|
| 62 |
+
)
|
| 63 |
+
|
| 64 |
+
### DO NOT EDIT BELOW HERE UNLESS YOU KNOW WHAT YOU ARE DOING ###
|
| 65 |
+
|
| 66 |
+
function provisioning_start() {
|
| 67 |
+
if [[ ! -d /opt/environments/python ]]; then
|
| 68 |
+
export MAMBA_BASE=true
|
| 69 |
+
fi
|
| 70 |
+
source /opt/ai-dock/etc/environment.sh
|
| 71 |
+
source /opt/ai-dock/bin/venv-set.sh comfyui
|
| 72 |
+
|
| 73 |
+
provisioning_print_header
|
| 74 |
+
provisioning_get_apt_packages
|
| 75 |
+
provisioning_get_nodes
|
| 76 |
+
provisioning_get_pip_packages
|
| 77 |
+
provisioning_get_models \
|
| 78 |
+
"${WORKSPACE}/storage/stable_diffusion/models/ckpt" \
|
| 79 |
+
"${CHECKPOINT_MODELS[@]}"
|
| 80 |
+
provisioning_get_models \
|
| 81 |
+
"${WORKSPACE}/storage/stable_diffusion/models/unet" \
|
| 82 |
+
"${UNET_MODELS[@]}"
|
| 83 |
+
provisioning_get_models \
|
| 84 |
+
"${WORKSPACE}/storage/stable_diffusion/models/lora" \
|
| 85 |
+
"${LORA_MODELS[@]}"
|
| 86 |
+
provisioning_get_models \
|
| 87 |
+
"${WORKSPACE}/storage/stable_diffusion/models/controlnet" \
|
| 88 |
+
"${CONTROLNET_MODELS[@]}"
|
| 89 |
+
provisioning_get_models \
|
| 90 |
+
"${WORKSPACE}/storage/stable_diffusion/models/vae" \
|
| 91 |
+
"${VAE_MODELS[@]}"
|
| 92 |
+
provisioning_get_models \
|
| 93 |
+
"${WORKSPACE}/storage/stable_diffusion/models/esrgan" \
|
| 94 |
+
"${ESRGAN_MODELS[@]}"
|
| 95 |
+
provisioning_print_end
|
| 96 |
+
}
|
| 97 |
+
|
| 98 |
+
function pip_install() {
|
| 99 |
+
if [[ -z $MAMBA_BASE ]]; then
|
| 100 |
+
"$COMFYUI_VENV_PIP" install --no-cache-dir "$@"
|
| 101 |
+
else
|
| 102 |
+
micromamba run -n comfyui pip install --no-cache-dir "$@"
|
| 103 |
+
fi
|
| 104 |
+
}
|
| 105 |
+
|
| 106 |
+
function provisioning_get_apt_packages() {
|
| 107 |
+
if [[ -n $APT_PACKAGES ]]; then
|
| 108 |
+
sudo $APT_INSTALL ${APT_PACKAGES[@]}
|
| 109 |
+
fi
|
| 110 |
+
}
|
| 111 |
+
|
| 112 |
+
function provisioning_get_pip_packages() {
|
| 113 |
+
if [[ -n $PIP_PACKAGES ]]; then
|
| 114 |
+
pip_install ${PIP_PACKAGES[@]}
|
| 115 |
+
fi
|
| 116 |
+
}
|
| 117 |
+
|
| 118 |
+
function provisioning_get_nodes() {
|
| 119 |
+
for repo in "${NODES[@]}"; do
|
| 120 |
+
dir="${repo##*/}"
|
| 121 |
+
path="/opt/ComfyUI/custom_nodes/${dir}"
|
| 122 |
+
requirements="${path}/requirements.txt"
|
| 123 |
+
if [[ -d $path ]]; then
|
| 124 |
+
if [[ ${AUTO_UPDATE,,} != "false" ]]; then
|
| 125 |
+
printf "Updating node: %s...\n" "${repo}"
|
| 126 |
+
( cd "$path" && git pull )
|
| 127 |
+
if [[ -e $requirements ]]; then
|
| 128 |
+
pip_install -r "$requirements"
|
| 129 |
+
fi
|
| 130 |
+
fi
|
| 131 |
+
else
|
| 132 |
+
printf "Downloading node: %s...\n" "${repo}"
|
| 133 |
+
git clone "${repo}" "${path}" --recursive
|
| 134 |
+
if [[ -e $requirements ]]; then
|
| 135 |
+
pip_install -r "${requirements}"
|
| 136 |
+
fi
|
| 137 |
+
fi
|
| 138 |
+
done
|
| 139 |
+
}
|
| 140 |
+
|
| 141 |
+
function provisioning_get_default_workflow() {
|
| 142 |
+
if [[ -n $DEFAULT_WORKFLOW ]]; then
|
| 143 |
+
workflow_json=$(curl -s "$DEFAULT_WORKFLOW")
|
| 144 |
+
if [[ -n $workflow_json ]]; then
|
| 145 |
+
echo "export const defaultGraph = $workflow_json;" > /opt/ComfyUI/web/scripts/defaultGraph.js
|
| 146 |
+
fi
|
| 147 |
+
fi
|
| 148 |
+
}
|
| 149 |
+
|
| 150 |
+
function provisioning_get_models() {
|
| 151 |
+
if [[ -z $2 ]]; then return 1; fi
|
| 152 |
+
|
| 153 |
+
dir="$1"
|
| 154 |
+
mkdir -p "$dir"
|
| 155 |
+
shift
|
| 156 |
+
arr=("$@")
|
| 157 |
+
printf "Downloading %s model(s) to %s...\n" "${#arr[@]}" "$dir"
|
| 158 |
+
for url in "${arr[@]}"; do
|
| 159 |
+
printf "Downloading: %s\n" "${url}"
|
| 160 |
+
provisioning_download "${url}" "${dir}"
|
| 161 |
+
printf "\n"
|
| 162 |
+
done
|
| 163 |
+
}
|
| 164 |
+
|
| 165 |
+
function provisioning_print_header() {
|
| 166 |
+
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"
|
| 167 |
+
if [[ $DISK_GB_ALLOCATED -lt $DISK_GB_REQUIRED ]]; then
|
| 168 |
+
printf "WARNING: Your allocated disk size (%sGB) is below the recommended %sGB - Some models will not be downloaded\n" "$DISK_GB_ALLOCATED" "$DISK_GB_REQUIRED"
|
| 169 |
+
fi
|
| 170 |
+
}
|
| 171 |
+
|
| 172 |
+
function provisioning_print_end() {
|
| 173 |
+
printf "\nProvisioning complete: Web UI will start now\n\n"
|
| 174 |
+
}
|
| 175 |
+
|
| 176 |
+
function provisioning_has_valid_hf_token() {
|
| 177 |
+
[[ -n "$HF_TOKEN" ]] || return 1
|
| 178 |
+
url="https://huggingface.co/api/whoami-v2"
|
| 179 |
+
|
| 180 |
+
response=$(curl -o /dev/null -s -w "%{http_code}" -X GET "$url" \
|
| 181 |
+
-H "Authorization: Bearer $HF_TOKEN" \
|
| 182 |
+
-H "Content-Type: application/json")
|
| 183 |
+
|
| 184 |
+
# Check if the token is valid
|
| 185 |
+
if [ "$response" -eq 200 ]; then
|
| 186 |
+
return 0
|
| 187 |
+
else
|
| 188 |
+
return 1
|
| 189 |
+
fi
|
| 190 |
+
}
|
| 191 |
+
|
| 192 |
+
function provisioning_has_valid_civitai_token() {
|
| 193 |
+
[[ -n "$CIVITAI_TOKEN" ]] || return 1
|
| 194 |
+
url="https://civitai.com/api/v1/models?hidden=1&limit=1"
|
| 195 |
+
|
| 196 |
+
response=$(curl -o /dev/null -s -w "%{http_code}" -X GET "$url" \
|
| 197 |
+
-H "Authorization: Bearer $CIVITAI_TOKEN" \
|
| 198 |
+
-H "Content-Type: application/json")
|
| 199 |
+
|
| 200 |
+
# Check if the token is valid
|
| 201 |
+
if [ "$response" -eq 200 ]; then
|
| 202 |
+
return 0
|
| 203 |
+
else
|
| 204 |
+
return 1
|
| 205 |
+
fi
|
| 206 |
+
}
|
| 207 |
+
|
| 208 |
+
# Download from $1 URL to $2 file path
|
| 209 |
+
function provisioning_download() {
|
| 210 |
+
if [[ -n $HF_TOKEN && $1 =~ ^https://([a-zA-Z0-9_-]+\.)?huggingface\.co(/|$|\?) ]]; then
|
| 211 |
+
auth_token="$HF_TOKEN"
|
| 212 |
+
elif
|
| 213 |
+
[[ -n $CIVITAI_TOKEN && $1 =~ ^https://([a-zA-Z0-9_-]+\.)?civitai\.com(/|$|\?) ]]; then
|
| 214 |
+
auth_token="$CIVITAI_TOKEN"
|
| 215 |
+
fi
|
| 216 |
+
if [[ -n $auth_token ]];then
|
| 217 |
+
wget --header="Authorization: Bearer $auth_token" -qnc --content-disposition --show-progress -e dotbytes="${3:-4M}" -P "$2" "$1"
|
| 218 |
+
else
|
| 219 |
+
wget -qnc --content-disposition --show-progress -e dotbytes="${3:-4M}" -P "$2" "$1"
|
| 220 |
+
fi
|
| 221 |
+
}
|
| 222 |
+
|
| 223 |
+
provisioning_start
|