nathanglm commited on
Commit
912f012
·
verified ·
1 Parent(s): 7033498

Upload animate.sh

Browse files
Files changed (1) hide show
  1. animate.sh +377 -0
animate.sh ADDED
@@ -0,0 +1,377 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ source /venv/main/bin/activate
4
+ COMFYUI_DIR=${WORKSPACE}/ComfyUI
5
+
6
+ # Packages are installed after nodes so we can fix them...
7
+
8
+ APT_PACKAGES=(
9
+ #"package-1"
10
+ #"package-2"
11
+ )
12
+
13
+ PIP_PACKAGES=(
14
+ "mediapipe==0.10.21"
15
+ )
16
+
17
+ NODES=(
18
+ "https://github.com/ltdrdata/ComfyUI-Manager"
19
+ "https://github.com/rgthree/rgthree-comfy"
20
+ "https://github.com/ltdrdata/ComfyUI-Impact-Pack"
21
+ "https://github.com/yolain/ComfyUI-Easy-Use"
22
+ "https://github.com/ssitu/ComfyUI_UltimateSDUpscale"
23
+ "https://github.com/sipherxyz/comfyui-art-venture"
24
+ "https://github.com/ltdrdata/ComfyUI-Impact-Subpack"
25
+ "https://github.com/moonwhaler/comfyui-moonpack"
26
+ "https://github.com/gseth/ControlAltAI-Nodes"
27
+ "https://github.com/vrgamegirl19/comfyui-vrgamedevgirl"
28
+ "https://github.com/numz/ComfyUI-SeedVR2_VideoUpscaler"
29
+ "https://github.com/robertvoy/ComfyUI-Flux-Continuum"
30
+ "https://github.com/ltdrdata/was-node-suite-comfyui"
31
+ "https://github.com/ChangeTheConstants/SeedVarianceEnhancer"
32
+ "https://github.com/city96/ComfyUI-GGUF"
33
+ "https://github.com/kijai/ComfyUI-KJNodes"
34
+ "https://github.com/Suzie1/ComfyUI_Comfyroll_CustomNodes"
35
+ "https://github.com/pythongosssss/ComfyUI-Custom-Scripts"
36
+ "https://github.com/kijai/ComfyUI-WanVideoWrapper"
37
+ "https://github.com/PGCRT/CRT-Nodes"
38
+ "https://github.com/chibiace/ComfyUI-Chibi-Nodes"
39
+ "https://github.com/crystian/comfyui-crystools"
40
+ "https://github.com/kijai/ComfyUI-MelBandRoFormer"
41
+ "https://github.com/Kosinkadink/ComfyUI-VideoHelperSuite"
42
+ "https://github.com/kijai/ComfyUI-WanAnimatePreprocess"
43
+ "https://github.com/Smirnov75/ComfyUI-mxToolkit"
44
+ "https://github.com/chrisgoringe/cg-use-everywhere"
45
+ "https://github.com/kijai/ComfyUI-Florence2"
46
+ "https://github.com/kijai/ComfyUI-segment-anything-2"
47
+ "https://github.com/un-seen/comfyui-tensorops"
48
+ "https://github.com/jamesWalker55/comfyui-various"
49
+ "https://github.com/cubiq/ComfyUI_essentials"
50
+ "https://github.com/Daxamur/DaxNodes"
51
+ "https://github.com/ClownsharkBatwing/RES4LYF"
52
+ "https://github.com/chrisgoringe/cg-image-filter"
53
+ "https://github.com/M1kep/ComfyLiterals"
54
+ "https://github.com/evanspearman/ComfyMath"
55
+ "https://github.com/digitaljohn/comfyui-propost"
56
+ "https://github.com/Fannovel16/ComfyUI-Frame-Interpolation"
57
+ )
58
+
59
+ WORKFLOWS=(
60
+ )
61
+
62
+ SAMS=(
63
+ )
64
+
65
+ CLIP=(
66
+ "https://huggingface.co/Kijai/WanVideo_comfy/resolve/main/umt5-xxl-enc-bf16.safetensors"
67
+ )
68
+
69
+ CLIP_VISION=(
70
+ )
71
+
72
+ CHECKPOINT_MODELS=(
73
+ )
74
+
75
+ BBOX=(
76
+ )
77
+
78
+ UNET_MODELS=(
79
+ )
80
+
81
+ UPSCALE_MODELS=(
82
+ )
83
+
84
+ # Format: "URL|filename.safetensors"
85
+ LORA_MODELS=(
86
+ "https://huggingface.co/Kijai/WanVideo_comfy/resolve/main/LoRAs/Wan22_Lightx2v/Wan_2_2_I2V_A14B_LOW_lightx2v_4step_lora_260412_rank_256_fp16.safetensors"
87
+ "https://huggingface.co/Kijai/WanVideo_comfy/resolve/main/Lightx2v/lightx2v_T2V_14B_cfg_step_distill_v2_lora_rank256_bf16.safetensors"
88
+ "https://huggingface.co/Kijai/WanVideo_comfy/resolve/main/Pusa/Wan21_PusaV1_LoRA_14B_rank512_bf16.safetensors"
89
+ "https://huggingface.co/alibaba-pai/Wan2.2-Fun-Reward-LoRAs/resolve/main/Wan2.2-Fun-A14B-InP-low-noise-MPS.safetensors"
90
+ "https://huggingface.co/Comfy-Org/Wan_2.2_ComfyUI_Repackaged/resolve/main/split_files/loras/wan2.2_animate_14B_relight_lora_bf16.safetensors"
91
+ )
92
+
93
+ VAE_MODELS=(
94
+ "https://huggingface.co/Kijai/WanVideo_comfy/resolve/main/Wan2_1_VAE_bf16.safetensors"
95
+ )
96
+
97
+ DIFFUSION_MODELS=(
98
+ "https://huggingface.co/Comfy-Org/Wan_2.2_ComfyUI_Repackaged/resolve/main/split_files/diffusion_models/wan2.2_animate_14B_bf16.safetensors"
99
+ )
100
+
101
+ TEXT_ENCODERS=(
102
+ )
103
+
104
+ DETECTION=(
105
+ "https://huggingface.co/Kijai/vitpose_comfy/resolve/main/onnx/vitpose_h_wholebody_model.onnx"
106
+ "https://huggingface.co/Wan-AI/Wan2.2-Animate-14B/resolve/main/process_checkpoint/det/yolov10m.onnx"
107
+ )
108
+
109
+ ESRGAN_MODELS=(
110
+ )
111
+
112
+ CONTROLNET_MODELS=(
113
+ )
114
+
115
+ ### DO NOT EDIT BELOW HERE UNLESS YOU KNOW WHAT YOU ARE DOING ###
116
+
117
+ function provisioning_start() {
118
+ provisioning_print_header
119
+ provisioning_get_apt_packages
120
+ provisioning_get_nodes
121
+ provisioning_get_pip_packages
122
+ provisioning_get_files \
123
+ "${COMFYUI_DIR}/models/sams" \
124
+ "${SAMS[@]}"
125
+ provisioning_get_files \
126
+ "${COMFYUI_DIR}/models/checkpoints" \
127
+ "${CHECKPOINT_MODELS[@]}"
128
+ provisioning_get_files \
129
+ "${COMFYUI_DIR}/models/ultralytics/bbox" \
130
+ "${BBOX[@]}"
131
+ provisioning_get_files \
132
+ "${COMFYUI_DIR}/models/unet" \
133
+ "${UNET_MODELS[@]}"
134
+ provisioning_get_files \
135
+ "${COMFYUI_DIR}/models/clip" \
136
+ "${CLIP[@]}"
137
+ provisioning_get_files \
138
+ "${COMFYUI_DIR}/models/clip_vision" \
139
+ "${CLIP_VISION[@]}"
140
+ provisioning_get_files \
141
+ "${COMFYUI_DIR}/models/loras" \
142
+ "${LORA_MODELS[@]}"
143
+ provisioning_get_files \
144
+ "${COMFYUI_DIR}/models/detection" \
145
+ "${DETECTION[@]}"
146
+ provisioning_get_files \
147
+ "${COMFYUI_DIR}/models/diffusion_models" \
148
+ "${DIFFUSION_MODELS[@]}"
149
+ provisioning_get_files \
150
+ "${COMFYUI_DIR}/models/upscale_models" \
151
+ "${UPSCALE_MODELS[@]}"
152
+ provisioning_get_files \
153
+ "${COMFYUI_DIR}/models/text_encoders" \
154
+ "${TEXT_ENCODERS[@]}"
155
+ provisioning_get_files \
156
+ "${COMFYUI_DIR}/models/controlnet" \
157
+ "${CONTROLNET_MODELS[@]}"
158
+ provisioning_get_files \
159
+ "${COMFYUI_DIR}/models/vae" \
160
+ "${VAE_MODELS[@]}"
161
+ provisioning_get_files \
162
+ "${COMFYUI_DIR}/user/default/workflows" \
163
+ "${WORKFLOWS[@]}"
164
+ provisioning_get_files \
165
+ "${COMFYUI_DIR}/models/esrgan" \
166
+ "${ESRGAN_MODELS[@]}"
167
+ provisioning_print_end
168
+ }
169
+
170
+ function provisioning_get_apt_packages() {
171
+ if [[ -n $APT_PACKAGES ]]; then
172
+ sudo $APT_INSTALL ${APT_PACKAGES[@]}
173
+ fi
174
+ }
175
+
176
+ function provisioning_get_pip_packages() {
177
+ if [[ -n $PIP_PACKAGES ]]; then
178
+ pip install --no-cache-dir ${PIP_PACKAGES[@]}
179
+ fi
180
+ }
181
+
182
+ function provisioning_get_nodes() {
183
+ for repo in "${NODES[@]}"; do
184
+ dir="${repo##*/}"
185
+ path="${COMFYUI_DIR}/custom_nodes/${dir}"
186
+ requirements="${path}/requirements.txt"
187
+ if [[ -d $path ]]; then
188
+ if [[ ${AUTO_UPDATE,,} != "false" ]]; then
189
+ printf "Updating node: %s...\n" "${repo}"
190
+ ( cd "$path" && git pull )
191
+ if [[ -e $requirements ]]; then
192
+ pip install --no-cache-dir -r "$requirements"
193
+ fi
194
+ fi
195
+ else
196
+ printf "Downloading node: %s...\n" "${repo}"
197
+ git clone "${repo}" "${path}" --recursive
198
+ if [[ -e $requirements ]]; then
199
+ pip install --no-cache-dir -r "${requirements}"
200
+ fi
201
+ fi
202
+ done
203
+ }
204
+
205
+ function provisioning_get_files() {
206
+ if [[ -z $2 ]]; then return 1; fi
207
+
208
+ dir="$1"
209
+ mkdir -p "$dir"
210
+ shift
211
+ arr=("$@")
212
+ printf "Downloading %s model(s) to %s...\n" "${#arr[@]}" "$dir"
213
+ for entry in "${arr[@]}"; do
214
+ # Support "URL|filename" format for custom filenames
215
+ if [[ "$entry" == *"|"* ]]; then
216
+ url="${entry%%|*}"
217
+ filename="${entry##*|}"
218
+ else
219
+ url="$entry"
220
+ filename=""
221
+ fi
222
+ printf "Downloading: %s\n" "${url}"
223
+ provisioning_download "${url}" "${dir}" "${filename}"
224
+ printf "\n"
225
+ done
226
+ }
227
+
228
+ function provisioning_print_header() {
229
+ 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"
230
+ }
231
+
232
+ function provisioning_print_end() {
233
+ printf "\nProvisioning complete: Application will start now\n\n"
234
+ }
235
+
236
+ function provisioning_has_valid_hf_token() {
237
+ [[ -n "$HF_TOKEN" ]] || return 1
238
+ url="https://huggingface.co/api/whoami-v2"
239
+
240
+ response=$(curl -o /dev/null -s -w "%{http_code}" -X GET "$url" \
241
+ -H "Authorization: Bearer $HF_TOKEN" \
242
+ -H "Content-Type: application/json")
243
+
244
+ if [ "$response" -eq 200 ]; then
245
+ return 0
246
+ else
247
+ return 1
248
+ fi
249
+ }
250
+
251
+ function provisioning_has_valid_civitai_token() {
252
+ [[ -n "$CIVITAI_TOKEN" ]] || return 1
253
+ url="https://civitai.com/api/v1/models?hidden=1&limit=1"
254
+
255
+ response=$(curl -o /dev/null -s -w "%{http_code}" -X GET "$url" \
256
+ -H "Authorization: Bearer $CIVITAI_TOKEN" \
257
+ -H "Content-Type: application/json")
258
+
259
+ if [ "$response" -eq 200 ]; then
260
+ return 0
261
+ else
262
+ return 1
263
+ fi
264
+ }
265
+
266
+ # Download CivitAI models with curl (pure bash)
267
+ function download_civitai_bash() {
268
+ local url="$1"
269
+ local output_dir="$2"
270
+ local forced_filename="$3"
271
+ local model_id=""
272
+
273
+ if [[ $url =~ /models/([0-9]+) ]]; then
274
+ model_id="${BASH_REMATCH[1]}"
275
+ else
276
+ printf "ERROR: Could not extract model ID from URL\n"
277
+ return 1
278
+ fi
279
+
280
+ printf "Downloading CivitAI model %s...\n" "$model_id"
281
+
282
+ if [[ -n "$forced_filename" ]]; then
283
+ local output_file="${output_dir}/${forced_filename}"
284
+ if [[ -f "$output_file" ]]; then
285
+ printf "File already exists: %s\n" "$forced_filename"
286
+ return 0
287
+ fi
288
+ printf "Downloading to: %s\n" "$forced_filename"
289
+ if [[ -n "$CIVITAI_TOKEN" ]]; then
290
+ curl -L -o "$output_file" --progress-bar -H "Authorization: Bearer $CIVITAI_TOKEN" "$url"
291
+ else
292
+ curl -L -o "$output_file" --progress-bar "$url"
293
+ fi
294
+ if [[ $? -eq 0 ]]; then
295
+ printf "Download completed: %s\n" "$forced_filename"
296
+ return 0
297
+ else
298
+ printf "ERROR: Download failed for model %s\n" "$model_id"
299
+ return 1
300
+ fi
301
+ fi
302
+
303
+ local redirect_url=""
304
+ if [[ -n "$CIVITAI_TOKEN" ]]; then
305
+ redirect_url=$(curl -s -I -L -H "Authorization: Bearer $CIVITAI_TOKEN" "$url" | grep -i "^location:" | tail -1 | sed 's/location: //i' | tr -d '\r\n')
306
+ else
307
+ redirect_url=$(curl -s -I -L "$url" | grep -i "^location:" | tail -1 | sed 's/location: //i' | tr -d '\r\n')
308
+ fi
309
+
310
+ if [[ -z "$redirect_url" ]]; then
311
+ printf "ERROR: Could not get redirect URL for model %s\n" "$model_id"
312
+ return 1
313
+ fi
314
+
315
+ local filename=""
316
+
317
+ if [[ $redirect_url =~ response-content-disposition=attachment.*filename%3D%22([^%\"]+) ]]; then
318
+ filename="${BASH_REMATCH[1]}"
319
+ filename=$(echo "$filename" | sed 's/%20/ /g; s/%2D/-/g; s/%2E/./g; s/%5F/_/g')
320
+ elif [[ $redirect_url =~ filename=\"([^\"]+)\" ]]; then
321
+ filename="${BASH_REMATCH[1]}"
322
+ elif [[ $redirect_url =~ filename=([^&]+) ]]; then
323
+ filename="${BASH_REMATCH[1]}"
324
+ else
325
+ local path_part=$(echo "$redirect_url" | sed 's/?.*//')
326
+ filename=$(basename "$path_part")
327
+ if [[ ! "$filename" =~ \.(safetensors|pt|pth|ckpt|bin)$ ]]; then
328
+ filename="${filename}.safetensors"
329
+ fi
330
+ fi
331
+
332
+ filename=$(printf '%b' "${filename//%/\\x}")
333
+
334
+ if [[ -z "$filename" ]] || [[ "$filename" == "." ]] || [[ "$filename" == ".safetensors" ]]; then
335
+ filename="civitai_${model_id}.safetensors"
336
+ fi
337
+
338
+ local output_file="${output_dir}/${filename}"
339
+
340
+ if [[ -f "$output_file" ]]; then
341
+ printf "File already exists: %s\n" "$filename"
342
+ return 0
343
+ fi
344
+
345
+ printf "Downloading to: %s\n" "$filename"
346
+ curl -L -o "$output_file" --progress-bar "$redirect_url"
347
+
348
+ if [[ $? -eq 0 ]]; then
349
+ printf "Download completed: %s\n" "$filename"
350
+ return 0
351
+ else
352
+ printf "ERROR: Download failed for model %s\n" "$model_id"
353
+ return 1
354
+ fi
355
+ }
356
+
357
+ # Download from $1 URL to $2 file path, with optional $3 forced filename
358
+ function provisioning_download() {
359
+ local url="$1"
360
+ local dir="$2"
361
+ local forced_filename="$3"
362
+
363
+ if [[ $url =~ ^https://civitai\.com/api/download/models/([0-9]+) ]]; then
364
+ download_civitai_bash "$url" "$dir" "$forced_filename"
365
+ else
366
+ if [[ -n "$forced_filename" ]]; then
367
+ wget -qnc --show-progress -e dotbytes="${4:-4M}" -O "${dir}/${forced_filename}" "$url"
368
+ else
369
+ wget -qnc --content-disposition --show-progress -e dotbytes="${4:-4M}" -P "$dir" "$url"
370
+ fi
371
+ fi
372
+ }
373
+
374
+ # Allow user to disable provisioning if they started with a script they didn't want
375
+ if [[ ! -f /.noprovisioning ]]; then
376
+ provisioning_start
377
+ fi