kato96 commited on
Commit
2ca50d1
·
verified ·
1 Parent(s): 893f7e4

Upload default.sh

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