nathanglm commited on
Commit
2d5d005
·
verified ·
1 Parent(s): 8227939

Upload 2 files

Browse files
Files changed (2) hide show
  1. runpod.io.sh +327 -0
  2. vast.ai.sh +342 -0
runpod.io.sh ADDED
@@ -0,0 +1,327 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ #"package-1"
15
+ #"package-2"
16
+ )
17
+
18
+ NODES=(
19
+ "https://github.com/city96/ComfyUI-GGUF"
20
+ "https://github.com/kijai/ComfyUI-KJNodes"
21
+ "https://github.com/Suzie1/ComfyUI_Comfyroll_CustomNodes"
22
+ )
23
+
24
+ WORKFLOWS=(
25
+
26
+ )
27
+
28
+ SAMS=(
29
+ "https://huggingface.co/datasets/Gourieff/ReActor/resolve/main/models/sams/sam_vit_b_01ec64.pth"
30
+ )
31
+
32
+
33
+ CHECKPOINT_MODELS=(
34
+ "https://civitai.com/api/download/models/1910174" # SDXL-CyberRealistic-V5.8
35
+ "https://civitai.com/api/download/models/2155386" # SDXL-Lustify
36
+ )
37
+
38
+ BBOX=(
39
+ "https://huggingface.co/nathanglm/sofia/resolve/main/Eyes.pt"
40
+ "https://huggingface.co/nathanglm/sofia/resolve/main/Face.pt"
41
+ "https://huggingface.co/nathanglm/sofia/resolve/main/Foot.pt"
42
+ "https://huggingface.co/nathanglm/sofia/resolve/main/Hands.pt"
43
+ "https://huggingface.co/nathanglm/sofia/resolve/main/Nipples.pt"
44
+ "https://huggingface.co/nathanglm/sofia/resolve/main/Pussy.pt"
45
+ "https://huggingface.co/nathanglm/sofia/resolve/main/Pussy2.pt"
46
+ "https://huggingface.co/nathanglm/sofia/resolve/main/Penis.pt"
47
+ )
48
+
49
+ UNET_MODELS=(
50
+ "https://huggingface.co/jayn7/Z-Image-Turbo-GGUF/resolve/main/z_image_turbo-Q8_0.gguf"
51
+ )
52
+
53
+ LORA_MODELS=(
54
+ "https://huggingface.co/nathanglm/sofia/resolve/main/Sofia.safetensors" # ZIT-Sofia
55
+ "https://huggingface.co/Finesse365/Anya-Lora/resolve/main/ZIT-Anya.safetensors" # ZIT-Anya
56
+ "https://civitai.com/api/download/models/2483794?type=Model&format=SafeTensor&size=full&fp=fp16" # ZIT-Asian-To-Caucasian
57
+ "https://civitai.com/api/download/models/2534692?type=Model&format=SafeTensor&size=full&fp=fp16" # ZIT-Hands-XL-v2.1
58
+ "https://civitai.com/api/download/models/2536073?type=Model&format=SafeTensor&size=full&fp=fp16" # ZIT-Feet-XL-v2.1
59
+ "https://civitai.com/api/download/models/2581135?type=Model&format=SafeTensor&size=full&fp=fp16" # ZIT-Mystic
60
+ "https://civitai.com/api/download/models/2452071?type=Model&format=SafeTensor&size=full&fp=fp16" # ZIT-Lenovo
61
+ "https://civitai.com/api/download/models/2617751?type=Model&format=SafeTensor&size=full&fp=fp16" # ZIT-Realistic-Snapshot-v5
62
+ "https://civitai.com/api/download/models/2513043?type=Model&format=SafeTensor&size=full&fp=fp16" # ZIT-Hip-Slider
63
+ "https://civitai.com/api/download/models/2510875?type=Model&format=SafeTensor&size=full&fp=fp16" # ZIT-Breast-Slider
64
+ "https://civitai.com/api/download/models/550216?type=Model&format=SafeTensor&size=full&fp=fp16" # SDXL-Lady-Hands
65
+ "https://civitai.com/api/download/models/139194?type=Model&format=SafeTensor&size=full&fp=fp16" # SDXL-Real-Feet
66
+ "https://civitai.com/api/download/models/368603?type=Model&format=SafeTensor&size=full&fp=fp16" # SDXL-Detailed-Nipples
67
+ "https://civitai.com/api/download/models/1604857?type=Model&format=SafeTensor&size=full&fp=fp16" # SDXL-Real-Pussy-Peach
68
+ "https://civitai.com/api/download/models/1511445?type=Model&format=SafeTensor&size=full&fp=fp16" # SDXL-Real-Pussy-Spreading
69
+ "https://civitai.com/api/download/models/1284103?type=Model&format=SafeTensor&size=full&fp=fp16" # SDXL-Real-Pussy-Butterfly
70
+ "https://civitai.com/api/download/models/802232?type=Model&format=SafeTensor&size=full&fp=fp16" # SDXL-Real-Pussy-Cameltoe
71
+ "https://civitai.com/api/download/models/712004?type=Model&format=SafeTensor&size=full&fp=fp16" # SDXL-Real-Pussy-Lotte
72
+ "https://civitai.com/api/download/models/262705?type=Model&format=SafeTensor&size=full&fp=fp16" # SDXL-Real-Humans
73
+ "https://civitai.com/api/download/models/216946?type=Model&format=SafeTensor&size=full&fp=fp16" # SDXL-Penis-XL-v1
74
+ "https://civitai.com/api/download/models/707763?type=Model&format=SafeTensor&size=full&fp=fp16" # SDXL-Realistic-Skin-Texutre-v4
75
+ "https://civitai.com/api/download/models/341068?type=Model&format=SafeTensor&size=full&fp=fp16" # SDXL-NSFW-XL-v2.1
76
+ "https://civitai.com/api/download/models/1506027?type=Model&format=SafeTensor&size=full&fp=fp16" # SDXL-Add-Detail-Slider-v1.2
77
+ "https://civitai.com/api/download/models/1934796?type=Model&format=SafeTensor&size=full&fp=fp16" # SDXL-touch-of-Realism-v2
78
+ )
79
+
80
+ VAE_MODELS=(
81
+ "https://huggingface.co/Comfy-Org/z_image_turbo/resolve/main/split_files/vae/ae.safetensors"
82
+ )
83
+
84
+ DIFFUSION_MODELS=(
85
+ "https://huggingface.co/Comfy-Org/z_image_turbo/resolve/main/split_files/diffusion_models/z_image_turbo_bf16.safetensors"
86
+ )
87
+
88
+ TEXT_ENCODERS=(
89
+ "https://huggingface.co/Comfy-Org/z_image_turbo/resolve/main/split_files/text_encoders/qwen_3_4b.safetensors"
90
+ )
91
+
92
+ ESRGAN_MODELS=(
93
+ )
94
+
95
+ CONTROLNET_MODELS=(
96
+ )
97
+
98
+ ### DO NOT EDIT BELOW HERE UNLESS YOU KNOW WHAT YOU ARE DOING ###
99
+
100
+ function provisioning_start() {
101
+ provisioning_print_header
102
+ provisioning_get_apt_packages
103
+ provisioning_get_nodes
104
+ provisioning_get_pip_packages
105
+ provisioning_get_files \
106
+ "${COMFYUI_DIR}/models/sams" \
107
+ "${SAMS[@]}"
108
+ provisioning_get_files \
109
+ "${COMFYUI_DIR}/models/checkpoints" \
110
+ "${CHECKPOINT_MODELS[@]}"
111
+ provisioning_get_files \
112
+ "${COMFYUI_DIR}/models/ultralytics/bbox" \
113
+ "${BBOX[@]}"
114
+ provisioning_get_files \
115
+ "${COMFYUI_DIR}/models/unet" \
116
+ "${UNET_MODELS[@]}"
117
+ provisioning_get_files \
118
+ "${COMFYUI_DIR}/models/loras" \
119
+ "${LORA_MODELS[@]}"
120
+ provisioning_get_files \
121
+ "${COMFYUI_DIR}/models/diffusion_models" \
122
+ "${DIFFUSION_MODELS[@]}"
123
+ provisioning_get_files \
124
+ "${COMFYUI_DIR}/models/text_encoders" \
125
+ "${TEXT_ENCODERS[@]}"
126
+ provisioning_get_files \
127
+ "${COMFYUI_DIR}/models/controlnet" \
128
+ "${CONTROLNET_MODELS[@]}"
129
+ provisioning_get_files \
130
+ "${COMFYUI_DIR}/models/vae" \
131
+ "${VAE_MODELS[@]}"
132
+ provisioning_get_files \
133
+ "${COMFYUI_DIR}/models/esrgan" \
134
+ "${ESRGAN_MODELS[@]}"
135
+ provisioning_print_end
136
+ }
137
+
138
+ function provisioning_get_apt_packages() {
139
+ if [[ -n $APT_PACKAGES ]]; then
140
+ sudo $APT_INSTALL ${APT_PACKAGES[@]}
141
+ fi
142
+ }
143
+
144
+ function provisioning_get_pip_packages() {
145
+ if [[ -n $PIP_PACKAGES ]]; then
146
+ pip install --no-cache-dir ${PIP_PACKAGES[@]}
147
+ fi
148
+ }
149
+
150
+ function provisioning_get_nodes() {
151
+ for repo in "${NODES[@]}"; do
152
+ dir="${repo##*/}"
153
+ path="${COMFYUI_DIR}/custom_nodes/${dir}"
154
+ requirements="${path}/requirements.txt"
155
+ if [[ -d $path ]]; then
156
+ if [[ ${AUTO_UPDATE,,} != "false" ]]; then
157
+ printf "Updating node: %s...\n" "${repo}"
158
+ ( cd "$path" && git pull )
159
+ if [[ -e $requirements ]]; then
160
+ pip install --no-cache-dir -r "$requirements"
161
+ fi
162
+ fi
163
+ else
164
+ printf "Downloading node: %s...\n" "${repo}"
165
+ git clone "${repo}" "${path}" --recursive
166
+ if [[ -e $requirements ]]; then
167
+ pip install --no-cache-dir -r "${requirements}"
168
+ fi
169
+ fi
170
+ done
171
+ }
172
+
173
+ function provisioning_get_files() {
174
+ if [[ -z $2 ]]; then return 1; fi
175
+
176
+ dir="$1"
177
+ mkdir -p "$dir"
178
+ shift
179
+ arr=("$@")
180
+ printf "Downloading %s model(s) to %s...\n" "${#arr[@]}" "$dir"
181
+ for url in "${arr[@]}"; do
182
+ printf "Downloading: %s\n" "${url}"
183
+ provisioning_download "${url}" "${dir}"
184
+ printf "\n"
185
+ done
186
+ }
187
+
188
+ function provisioning_print_header() {
189
+ 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"
190
+ }
191
+
192
+ function provisioning_print_end() {
193
+ printf "\nProvisioning complete: Application will start now\n\n"
194
+ }
195
+
196
+ function provisioning_has_valid_hf_token() {
197
+ [[ -n "$HF_TOKEN" ]] || return 1
198
+ url="https://huggingface.co/api/whoami-v2"
199
+
200
+ response=$(curl -o /dev/null -s -w "%{http_code}" -X GET "$url" \
201
+ -H "Authorization: Bearer $HF_TOKEN" \
202
+ -H "Content-Type: application/json")
203
+
204
+ # Check if the token is valid
205
+ if [ "$response" -eq 200 ]; then
206
+ return 0
207
+ else
208
+ return 1
209
+ fi
210
+ }
211
+
212
+ function provisioning_has_valid_civitai_token() {
213
+ [[ -n "$CIVITAI_TOKEN" ]] || return 1
214
+ url="https://civitai.com/api/v1/models?hidden=1&limit=1"
215
+
216
+ response=$(curl -o /dev/null -s -w "%{http_code}" -X GET "$url" \
217
+ -H "Authorization: Bearer $CIVITAI_TOKEN" \
218
+ -H "Content-Type: application/json")
219
+
220
+ # Check if the token is valid
221
+ if [ "$response" -eq 200 ]; then
222
+ return 0
223
+ else
224
+ return 1
225
+ fi
226
+ }
227
+
228
+ # Download CivitAI models with curl (pure bash)
229
+ function download_civitai_bash() {
230
+ local url="$1"
231
+ local output_dir="$2"
232
+ local model_id=""
233
+
234
+ # Extract model ID from URL
235
+ if [[ $url =~ /models/([0-9]+) ]]; then
236
+ model_id="${BASH_REMATCH[1]}"
237
+ else
238
+ printf "ERROR: Could not extract model ID from URL\n"
239
+ return 1
240
+ fi
241
+
242
+ printf "Downloading CivitAI model %s...\n" "$model_id"
243
+
244
+ # Get redirect location with curl
245
+ local redirect_url=""
246
+ if [[ -n "a881da881b7c01e808f1fb7843092a11" ]]; then
247
+ redirect_url=$(curl -s -I -L -H "Authorization: Bearer a881da881b7c01e808f1fb7843092a11" "$url" | grep -i "^location:" | tail -1 | sed 's/location: //i' | tr -d '\r\n')
248
+ else
249
+ redirect_url=$(curl -s -I -L "$url" | grep -i "^location:" | tail -1 | sed 's/location: //i' | tr -d '\r\n')
250
+ fi
251
+
252
+ if [[ -z "$redirect_url" ]]; then
253
+ printf "ERROR: Could not get redirect URL for model %s\n" "$model_id"
254
+ return 1
255
+ fi
256
+
257
+ # Extract filename from redirect URL - improved method
258
+ local filename=""
259
+
260
+ # Method 1: Try to extract from response-content-disposition parameter (URL encoded)
261
+ if [[ $redirect_url =~ response-content-disposition=attachment.*filename%3D%22([^%\"]+) ]]; then
262
+ filename="${BASH_REMATCH[1]}"
263
+ # URL decode %20 to space, %2D to -, etc.
264
+ filename=$(echo "$filename" | sed 's/%20/ /g; s/%2D/-/g; s/%2E/./g; s/%5F/_/g')
265
+ # Method 2: Try filename=" pattern
266
+ elif [[ $redirect_url =~ filename=\"([^\"]+)\" ]]; then
267
+ filename="${BASH_REMATCH[1]}"
268
+ # Method 3: Try filename= without quotes
269
+ elif [[ $redirect_url =~ filename=([^&]+) ]]; then
270
+ filename="${BASH_REMATCH[1]}"
271
+ # Method 4: Extract from URL path before query string
272
+ else
273
+ # Remove query string and get the last part of the path
274
+ local path_part=$(echo "$redirect_url" | sed 's/?.*//')
275
+ filename=$(basename "$path_part")
276
+
277
+ # If filename doesn't have an extension, add .safetensors
278
+ if [[ ! "$filename" =~ \.(safetensors|pt|pth|ckpt|bin)$ ]]; then
279
+ filename="${filename}.safetensors"
280
+ fi
281
+ fi
282
+
283
+ # Clean up the filename - remove any remaining % encodings
284
+ filename=$(printf '%b' "${filename//%/\\x}")
285
+
286
+ # If still no valid filename, use fallback
287
+ if [[ -z "$filename" ]] || [[ "$filename" == "." ]] || [[ "$filename" == ".safetensors" ]]; then
288
+ filename="civitai_${model_id}.safetensors"
289
+ fi
290
+
291
+ local output_file="${output_dir}/${filename}"
292
+
293
+ # Check if file already exists
294
+ if [[ -f "$output_file" ]]; then
295
+ printf "File already exists: %s\n" "$filename"
296
+ return 0
297
+ fi
298
+
299
+ # Download with curl
300
+ printf "Downloading to: %s\n" "$filename"
301
+ curl -L -o "$output_file" --progress-bar "$redirect_url"
302
+
303
+ if [[ $? -eq 0 ]]; then
304
+ printf "Download completed: %s\n" "$filename"
305
+ return 0
306
+ else
307
+ printf "ERROR: Download failed for model %s\n" "$model_id"
308
+ return 1
309
+ fi
310
+ }
311
+
312
+ # Download from $1 URL to $2 file path
313
+ function provisioning_download() {
314
+ # Check if it's a CivitAI URL
315
+ if [[ $1 =~ ^https://civitai\.com/api/download/models/([0-9]+) ]]; then
316
+ download_civitai_bash "$1" "$2"
317
+ elif [[ $1 =~ ^https://([a-zA-Z0-9_-]+\.)?huggingface\.co(/|$|\?) ]]; then
318
+ wget -qnc --content-disposition --show-progress -e dotbytes="${3:-4M}" -P "$2" "$1"
319
+ else
320
+ wget -qnc --content-disposition --show-progress -e dotbytes="${3:-4M}" -P "$2" "$1"
321
+ fi
322
+ }
323
+
324
+ # Allow user to disable provisioning if they started with a script they didn't want
325
+ if [[ ! -f /.noprovisioning ]]; then
326
+ provisioning_start
327
+ fi
vast.ai.sh ADDED
@@ -0,0 +1,342 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ #"package-1"
15
+ #"package-2"
16
+ )
17
+
18
+ NODES=(
19
+ "https://github.com/ltdrdata/ComfyUI-Manager"
20
+ "https://github.com/rgthree/rgthree-comfy"
21
+ "https://github.com/ltdrdata/ComfyUI-Impact-Pack"
22
+ "https://github.com/yolain/ComfyUI-Easy-Use"
23
+ "https://github.com/ssitu/ComfyUI_UltimateSDUpscale"
24
+ "https://github.com/sipherxyz/comfyui-art-venture"
25
+ "https://github.com/ltdrdata/ComfyUI-Impact-Subpack"
26
+ "https://github.com/moonwhaler/comfyui-moonpack"
27
+ "https://github.com/gseth/ControlAltAI-Nodes"
28
+ "https://github.com/vrgamegirl19/comfyui-vrgamedevgirl"
29
+ "https://github.com/numz/ComfyUI-SeedVR2_VideoUpscaler"
30
+ "https://github.com/robertvoy/ComfyUI-Flux-Continuum"
31
+ "https://github.com/ltdrdata/was-node-suite-comfyui"
32
+ "https://github.com/ChangeTheConstants/SeedVarianceEnhancer"
33
+ "https://github.com/city96/ComfyUI-GGUF"
34
+ "https://github.com/kijai/ComfyUI-KJNodes"
35
+ "https://github.com/Suzie1/ComfyUI_Comfyroll_CustomNodes"
36
+ )
37
+
38
+ WORKFLOWS=(
39
+
40
+ )
41
+
42
+ SAMS=(
43
+ "https://huggingface.co/datasets/Gourieff/ReActor/resolve/main/models/sams/sam_vit_b_01ec64.pth"
44
+ )
45
+
46
+
47
+ CHECKPOINT_MODELS=(
48
+ "https://civitai.com/api/download/models/1910174" # SDXL-CyberRealistic-V5.8
49
+ "https://civitai.com/api/download/models/2155386" # SDXL-Lustify
50
+ )
51
+
52
+ BBOX=(
53
+ "https://huggingface.co/nathanglm/sofia/resolve/main/Eyes.pt"
54
+ "https://huggingface.co/nathanglm/sofia/resolve/main/Face.pt"
55
+ "https://huggingface.co/nathanglm/sofia/resolve/main/Foot.pt"
56
+ "https://huggingface.co/nathanglm/sofia/resolve/main/Hands.pt"
57
+ "https://huggingface.co/nathanglm/sofia/resolve/main/Nipples.pt"
58
+ "https://huggingface.co/nathanglm/sofia/resolve/main/Pussy.pt"
59
+ "https://huggingface.co/nathanglm/sofia/resolve/main/Pussy2.pt"
60
+ "https://huggingface.co/nathanglm/sofia/resolve/main/Penis.pt"
61
+ )
62
+
63
+ UNET_MODELS=(
64
+ "https://huggingface.co/jayn7/Z-Image-Turbo-GGUF/resolve/main/z_image_turbo-Q8_0.gguf"
65
+ )
66
+
67
+ LORA_MODELS=(
68
+ "https://huggingface.co/nathanglm/sofia/resolve/main/Sofia.safetensors" # ZIT-Sofia
69
+ "https://huggingface.co/Finesse365/Anya-Lora/resolve/main/ZIT-Anya.safetensors" # ZIT-Anya
70
+ "https://civitai.com/api/download/models/2483794?type=Model&format=SafeTensor&size=full&fp=fp16" # ZIT-Asian-To-Caucasian
71
+ "https://civitai.com/api/download/models/2534692?type=Model&format=SafeTensor&size=full&fp=fp16" # ZIT-Hands-XL-v2.1
72
+ "https://civitai.com/api/download/models/2536073?type=Model&format=SafeTensor&size=full&fp=fp16" # ZIT-Feet-XL-v2.1
73
+ "https://civitai.com/api/download/models/2581135?type=Model&format=SafeTensor&size=full&fp=fp16" # ZIT-Mystic
74
+ "https://civitai.com/api/download/models/2452071?type=Model&format=SafeTensor&size=full&fp=fp16" # ZIT-Lenovo
75
+ "https://civitai.com/api/download/models/2617751?type=Model&format=SafeTensor&size=full&fp=fp16" # ZIT-Realistic-Snapshot-v5
76
+ "https://civitai.com/api/download/models/2513043?type=Model&format=SafeTensor&size=full&fp=fp16" # ZIT-Hip-Slider
77
+ "https://civitai.com/api/download/models/2510875?type=Model&format=SafeTensor&size=full&fp=fp16" # ZIT-Breast-Slider
78
+ "https://civitai.com/api/download/models/550216?type=Model&format=SafeTensor&size=full&fp=fp16" # SDXL-Lady-Hands
79
+ "https://civitai.com/api/download/models/139194?type=Model&format=SafeTensor&size=full&fp=fp16" # SDXL-Real-Feet
80
+ "https://civitai.com/api/download/models/368603?type=Model&format=SafeTensor&size=full&fp=fp16" # SDXL-Detailed-Nipples
81
+ "https://civitai.com/api/download/models/1604857?type=Model&format=SafeTensor&size=full&fp=fp16" # SDXL-Real-Pussy-Peach
82
+ "https://civitai.com/api/download/models/1511445?type=Model&format=SafeTensor&size=full&fp=fp16" # SDXL-Real-Pussy-Spreading
83
+ "https://civitai.com/api/download/models/1284103?type=Model&format=SafeTensor&size=full&fp=fp16" # SDXL-Real-Pussy-Butterfly
84
+ "https://civitai.com/api/download/models/802232?type=Model&format=SafeTensor&size=full&fp=fp16" # SDXL-Real-Pussy-Cameltoe
85
+ "https://civitai.com/api/download/models/712004?type=Model&format=SafeTensor&size=full&fp=fp16" # SDXL-Real-Pussy-Lotte
86
+ "https://civitai.com/api/download/models/262705?type=Model&format=SafeTensor&size=full&fp=fp16" # SDXL-Real-Humans
87
+ "https://civitai.com/api/download/models/216946?type=Model&format=SafeTensor&size=full&fp=fp16" # SDXL-Penis-XL-v1
88
+ "https://civitai.com/api/download/models/707763?type=Model&format=SafeTensor&size=full&fp=fp16" # SDXL-Realistic-Skin-Texutre-v4
89
+ "https://civitai.com/api/download/models/341068?type=Model&format=SafeTensor&size=full&fp=fp16" # SDXL-NSFW-XL-v2.1
90
+ "https://civitai.com/api/download/models/1506027?type=Model&format=SafeTensor&size=full&fp=fp16" # SDXL-Add-Detail-Slider-v1.2
91
+ "https://civitai.com/api/download/models/1934796?type=Model&format=SafeTensor&size=full&fp=fp16" # SDXL-touch-of-Realism-v2
92
+ )
93
+
94
+ VAE_MODELS=(
95
+ "https://huggingface.co/Comfy-Org/z_image_turbo/resolve/main/split_files/vae/ae.safetensors"
96
+ )
97
+
98
+ DIFFUSION_MODELS=(
99
+ "https://huggingface.co/Comfy-Org/z_image_turbo/resolve/main/split_files/diffusion_models/z_image_turbo_bf16.safetensors"
100
+ )
101
+
102
+ TEXT_ENCODERS=(
103
+ "https://huggingface.co/Comfy-Org/z_image_turbo/resolve/main/split_files/text_encoders/qwen_3_4b.safetensors"
104
+ )
105
+
106
+ ESRGAN_MODELS=(
107
+ )
108
+
109
+ CONTROLNET_MODELS=(
110
+ )
111
+
112
+ ### DO NOT EDIT BELOW HERE UNLESS YOU KNOW WHAT YOU ARE DOING ###
113
+
114
+ function provisioning_start() {
115
+ provisioning_print_header
116
+ provisioning_get_apt_packages
117
+ provisioning_get_nodes
118
+ provisioning_get_pip_packages
119
+ provisioning_get_files \
120
+ "${COMFYUI_DIR}/models/sams" \
121
+ "${SAMS[@]}"
122
+ provisioning_get_files \
123
+ "${COMFYUI_DIR}/models/checkpoints" \
124
+ "${CHECKPOINT_MODELS[@]}"
125
+ provisioning_get_files \
126
+ "${COMFYUI_DIR}/models/ultralytics/bbox" \
127
+ "${BBOX[@]}"
128
+ provisioning_get_files \
129
+ "${COMFYUI_DIR}/models/unet" \
130
+ "${UNET_MODELS[@]}"
131
+ provisioning_get_files \
132
+ "${COMFYUI_DIR}/models/loras" \
133
+ "${LORA_MODELS[@]}"
134
+ provisioning_get_files \
135
+ "${COMFYUI_DIR}/models/diffusion_models" \
136
+ "${DIFFUSION_MODELS[@]}"
137
+ provisioning_get_files \
138
+ "${COMFYUI_DIR}/models/text_encoders" \
139
+ "${TEXT_ENCODERS[@]}"
140
+ provisioning_get_files \
141
+ "${COMFYUI_DIR}/models/controlnet" \
142
+ "${CONTROLNET_MODELS[@]}"
143
+ provisioning_get_files \
144
+ "${COMFYUI_DIR}/models/vae" \
145
+ "${VAE_MODELS[@]}"
146
+ provisioning_get_files \
147
+ "${COMFYUI_DIR}/models/esrgan" \
148
+ "${ESRGAN_MODELS[@]}"
149
+ provisioning_print_end
150
+ }
151
+
152
+ function provisioning_get_apt_packages() {
153
+ if [[ -n $APT_PACKAGES ]]; then
154
+ sudo $APT_INSTALL ${APT_PACKAGES[@]}
155
+ fi
156
+ }
157
+
158
+ function provisioning_get_pip_packages() {
159
+ if [[ -n $PIP_PACKAGES ]]; then
160
+ pip install --no-cache-dir ${PIP_PACKAGES[@]}
161
+ fi
162
+ }
163
+
164
+ function provisioning_get_nodes() {
165
+ for repo in "${NODES[@]}"; do
166
+ dir="${repo##*/}"
167
+ path="${COMFYUI_DIR}/custom_nodes/${dir}"
168
+ requirements="${path}/requirements.txt"
169
+ if [[ -d $path ]]; then
170
+ if [[ ${AUTO_UPDATE,,} != "false" ]]; then
171
+ printf "Updating node: %s...\n" "${repo}"
172
+ ( cd "$path" && git pull )
173
+ if [[ -e $requirements ]]; then
174
+ pip install --no-cache-dir -r "$requirements"
175
+ fi
176
+ fi
177
+ else
178
+ printf "Downloading node: %s...\n" "${repo}"
179
+ git clone "${repo}" "${path}" --recursive
180
+ if [[ -e $requirements ]]; then
181
+ pip install --no-cache-dir -r "${requirements}"
182
+ fi
183
+ fi
184
+ done
185
+ }
186
+
187
+ function provisioning_get_files() {
188
+ if [[ -z $2 ]]; then return 1; fi
189
+
190
+ dir="$1"
191
+ mkdir -p "$dir"
192
+ shift
193
+ arr=("$@")
194
+ printf "Downloading %s model(s) to %s...\n" "${#arr[@]}" "$dir"
195
+ for url in "${arr[@]}"; do
196
+ printf "Downloading: %s\n" "${url}"
197
+ provisioning_download "${url}" "${dir}"
198
+ printf "\n"
199
+ done
200
+ }
201
+
202
+ function provisioning_print_header() {
203
+ 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"
204
+ }
205
+
206
+ function provisioning_print_end() {
207
+ printf "\nProvisioning complete: Application will start now\n\n"
208
+ }
209
+
210
+ function provisioning_has_valid_hf_token() {
211
+ [[ -n "$HF_TOKEN" ]] || return 1
212
+ url="https://huggingface.co/api/whoami-v2"
213
+
214
+ response=$(curl -o /dev/null -s -w "%{http_code}" -X GET "$url" \
215
+ -H "Authorization: Bearer $HF_TOKEN" \
216
+ -H "Content-Type: application/json")
217
+
218
+ # Check if the token is valid
219
+ if [ "$response" -eq 200 ]; then
220
+ return 0
221
+ else
222
+ return 1
223
+ fi
224
+ }
225
+
226
+ function provisioning_has_valid_civitai_token() {
227
+ [[ -n "$CIVITAI_TOKEN" ]] || return 1
228
+ url="https://civitai.com/api/v1/models?hidden=1&limit=1"
229
+
230
+ response=$(curl -o /dev/null -s -w "%{http_code}" -X GET "$url" \
231
+ -H "Authorization: Bearer $CIVITAI_TOKEN" \
232
+ -H "Content-Type: application/json")
233
+
234
+ # Check if the token is valid
235
+ if [ "$response" -eq 200 ]; then
236
+ return 0
237
+ else
238
+ return 1
239
+ fi
240
+ }
241
+
242
+ # Download CivitAI models with curl (pure bash)
243
+ function download_civitai_bash() {
244
+ local url="$1"
245
+ local output_dir="$2"
246
+ local model_id=""
247
+
248
+ # Extract model ID from URL
249
+ if [[ $url =~ /models/([0-9]+) ]]; then
250
+ model_id="${BASH_REMATCH[1]}"
251
+ else
252
+ printf "ERROR: Could not extract model ID from URL\n"
253
+ return 1
254
+ fi
255
+
256
+ printf "Downloading CivitAI model %s...\n" "$model_id"
257
+
258
+ # Get redirect location with curl
259
+ local redirect_url=""
260
+ if [[ -n "$CIVITAI_TOKEN" ]]; then
261
+ 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')
262
+ else
263
+ redirect_url=$(curl -s -I -L "$url" | grep -i "^location:" | tail -1 | sed 's/location: //i' | tr -d '\r\n')
264
+ fi
265
+
266
+ if [[ -z "$redirect_url" ]]; then
267
+ printf "ERROR: Could not get redirect URL for model %s\n" "$model_id"
268
+ return 1
269
+ fi
270
+
271
+ # Extract filename from redirect URL - improved method
272
+ local filename=""
273
+
274
+ # Method 1: Try to extract from response-content-disposition parameter (URL encoded)
275
+ if [[ $redirect_url =~ response-content-disposition=attachment.*filename%3D%22([^%\"]+) ]]; then
276
+ filename="${BASH_REMATCH[1]}"
277
+ # URL decode %20 to space, %2D to -, etc.
278
+ filename=$(echo "$filename" | sed 's/%20/ /g; s/%2D/-/g; s/%2E/./g; s/%5F/_/g')
279
+ # Method 2: Try filename=" pattern
280
+ elif [[ $redirect_url =~ filename=\"([^\"]+)\" ]]; then
281
+ filename="${BASH_REMATCH[1]}"
282
+ # Method 3: Try filename= without quotes
283
+ elif [[ $redirect_url =~ filename=([^&]+) ]]; then
284
+ filename="${BASH_REMATCH[1]}"
285
+ # Method 4: Extract from URL path before query string
286
+ else
287
+ # Remove query string and get the last part of the path
288
+ local path_part=$(echo "$redirect_url" | sed 's/?.*//')
289
+ filename=$(basename "$path_part")
290
+
291
+ # If filename doesn't have an extension, add .safetensors
292
+ if [[ ! "$filename" =~ \.(safetensors|pt|pth|ckpt|bin)$ ]]; then
293
+ filename="${filename}.safetensors"
294
+ fi
295
+ fi
296
+
297
+ # Clean up the filename - remove any remaining % encodings
298
+ filename=$(printf '%b' "${filename//%/\\x}")
299
+
300
+ # If still no valid filename, use fallback
301
+ if [[ -z "$filename" ]] || [[ "$filename" == "." ]] || [[ "$filename" == ".safetensors" ]]; then
302
+ filename="civitai_${model_id}.safetensors"
303
+ fi
304
+
305
+ local output_file="${output_dir}/${filename}"
306
+
307
+ # Check if file already exists
308
+ if [[ -f "$output_file" ]]; then
309
+ printf "File already exists: %s\n" "$filename"
310
+ return 0
311
+ fi
312
+
313
+ # Download with curl
314
+ printf "Downloading to: %s\n" "$filename"
315
+ curl -L -o "$output_file" --progress-bar "$redirect_url"
316
+
317
+ if [[ $? -eq 0 ]]; then
318
+ printf "Download completed: %s\n" "$filename"
319
+ return 0
320
+ else
321
+ printf "ERROR: Download failed for model %s\n" "$model_id"
322
+ return 1
323
+ fi
324
+ }
325
+
326
+ # Download from $1 URL to $2 file path
327
+ function provisioning_download() {
328
+ # Check if it's a CivitAI URL
329
+ if [[ $1 =~ ^https://civitai\.com/api/download/models/([0-9]+) ]]; then
330
+ download_civitai_bash "$1" "$2"
331
+ # HuggingFace URLs
332
+ elif [[ $1 =~ ^https://([a-zA-Z0-9_-]+\.)?huggingface\.co(/|$|\?) ]]; then
333
+ wget -qnc --content-disposition --show-progress -e dotbytes="${3:-4M}" -P "$2" "$1"
334
+ else
335
+ wget -qnc --content-disposition --show-progress -e dotbytes="${3:-4M}" -P "$2" "$1"
336
+ fi
337
+ }
338
+
339
+ # Allow user to disable provisioning if they started with a script they didn't want
340
+ if [[ ! -f /.noprovisioning ]]; then
341
+ provisioning_start
342
+ fi