DanyGreen commited on
Commit
d56dcdd
·
verified ·
1 Parent(s): c13104a

Upload ustawienia.sh

Browse files
Files changed (1) hide show
  1. ustawienia.sh +291 -0
ustawienia.sh ADDED
@@ -0,0 +1,291 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ # This file will be sourced in init.sh
4
+
5
+ # https://github.com/MushroomFleet/Runpod-init
6
+
7
+ # Packages are installed after nodes so we can fix them...
8
+
9
+ DEFAULT_WORKFLOW="https://raw.githubusercontent.com/ai-dock/comfyui/main/config/workflows/flux-comfyui-example.json"
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/XLabs-AI/x-flux-comfyui"
25
+ )
26
+
27
+ WORKFLOWS=(
28
+ #"https://github.com/MushroomFleet/DJZ-Workflows"
29
+ )
30
+
31
+ CHECKPOINT_MODELS=(
32
+ #"https://huggingface.co/runwayml/stable-diffusion-v1-5/resolve/main/v1-5-pruned-emaonly.ckpt"
33
+ #"https://huggingface.co/stabilityai/stable-diffusion-2-1/resolve/main/v2-1_768-ema-pruned.ckpt"
34
+ #"https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0/resolve/main/sd_xl_base_1.0.safetensors"
35
+ #"https://huggingface.co/stabilityai/stable-diffusion-xl-refiner-1.0/resolve/main/sd_xl_refiner_1.0.safetensors"
36
+ )
37
+
38
+ UNET_MODELS=(
39
+ #"https://huggingface.co/camenduru/FLUX.1-dev/resolve/main/flux1-dev.sft"
40
+ "https://huggingface.co/DanyGreen/Test/resolve/main/flux-hyp8-Q4_0.gguf"
41
+ )
42
+
43
+ CLIP_MODELS=(
44
+ "https://huggingface.co/camenduru/FLUX.1-dev/resolve/main/clip_l.safetensors"
45
+ "https://huggingface.co/camenduru/FLUX.1-dev/resolve/main/t5xxl_fp16.safetensors"
46
+ "https://huggingface.co/DanyGreen/Test/resolve/main/ViT-L-14-TEXT-detail-improved-hiT-GmP-TE-only-HF.safetensors"
47
+ "https://huggingface.co/DanyGreen/Test/resolve/main/t5-v1_1-xxl-encoder-Q6_K.gguf"
48
+ "https://huggingface.co/Comfy-Org/sigclip_vision_384/resolve/main/sigclip_vision_patch14_384.safetensors"
49
+ )
50
+
51
+ LORA_MODELS=(
52
+ #"https://huggingface.co/mushroomfleet/Flux-Lora-Collection/resolve/main/AssassinKahb-8-16-e9-10.safetensors"
53
+ "https://huggingface.co/DanyGreen/Test/resolve/main/Coco_flux_80img.safetensors"
54
+ )
55
+
56
+ VAE_MODELS=(
57
+ "https://huggingface.co/camenduru/FLUX.1-dev/resolve/main/ae.sft"
58
+ #"https://huggingface.co/stabilityai/sdxl-vae/resolve/main/sdxl_vae.safetensors"
59
+ )
60
+
61
+ STYLE_MODELS=(
62
+ "https://huggingface.co/DanyGreen/Test/resolve/main/flux1-redux-dev.safetensors"
63
+ )
64
+
65
+ UPSCALE_MODELS=(
66
+ "https://huggingface.co/lokCX/4x-Ultrasharp/resolve/main/4x-UltraSharp.pth"
67
+ "https://huggingface.co/Akumetsu971/SD_Anime_Futuristic_Armor/resolve/main/4x_NMKD-Siax_200k.pth"
68
+ )
69
+
70
+ ESRGAN_MODELS=(
71
+ #"https://huggingface.co/ai-forever/Real-ESRGAN/resolve/main/RealESRGAN_x4.pth"
72
+ "https://huggingface.co/FacehugmanIII/4x_foolhardy_Remacri/resolve/main/4x_foolhardy_Remacri.pth"
73
+ #"https://huggingface.co/Akumetsu971/SD_Anime_Futuristic_Armor/resolve/main/4x_NMKD-Siax_200k.pth"
74
+ )
75
+
76
+ CONTROLNET_MODELS=(
77
+ "https://huggingface.co/Shakker-Labs/FLUX.1-dev-ControlNet-Union-Pro/resolve/main/diffusion_pytorch_model.safetensors"
78
+ #"https://huggingface.co/XLabs-AI/flux-controlnet-collections/resolve/main/flux-hed-controlnet-v3.safetensors"
79
+ #"https://huggingface.co/XLabs-AI/flux-controlnet-collections/resolve/main/flux-canny-controlnet-v3.safetensors"
80
+ #"https://huggingface.co/XLabs-AI/flux-controlnet-collections/resolve/main/flux-depth-controlnet-v3.safetensors"
81
+ #"https://huggingface.co/lllyasviel/sd_control_collection/resolve/main/diffusers_xl_canny_mid.safetensors"
82
+ #"https://huggingface.co/lllyasviel/sd_control_collection/resolve/main/diffusers_xl_depth_mid.safetensors"
83
+ #"https://huggingface.co/lllyasviel/sd_control_collection/resolve/main/t2i-adapter_diffusers_xl_openpose.safetensors"
84
+ #"https://huggingface.co/webui/ControlNet-modules-safetensors/resolve/main/control_canny-fp16.safetensors"
85
+ #"https://huggingface.co/webui/ControlNet-modules-safetensors/resolve/main/control_depth-fp16.safetensors"
86
+ #"https://huggingface.co/kohya-ss/ControlNet-diff-modules/resolve/main/diff_control_sd15_depth_fp16.safetensors"
87
+ #"https://huggingface.co/webui/ControlNet-modules-safetensors/resolve/main/control_hed-fp16.safetensors"
88
+ #"https://huggingface.co/webui/ControlNet-modules-safetensors/resolve/main/control_mlsd-fp16.safetensors"
89
+ #"https://huggingface.co/webui/ControlNet-modules-safetensors/resolve/main/control_normal-fp16.safetensors"
90
+ #"https://huggingface.co/webui/ControlNet-modules-safetensors/resolve/main/control_openpose-fp16.safetensors"
91
+ #"https://huggingface.co/webui/ControlNet-modules-safetensors/resolve/main/control_scribble-fp16.safetensors"
92
+ #"https://huggingface.co/webui/ControlNet-modules-safetensors/resolve/main/control_seg-fp16.safetensors"
93
+ #"https://huggingface.co/webui/ControlNet-modules-safetensors/resolve/main/t2iadapter_canny-fp16.safetensors"
94
+ #"https://huggingface.co/webui/ControlNet-modules-safetensors/resolve/main/t2iadapter_color-fp16.safetensors"
95
+ #"https://huggingface.co/webui/ControlNet-modules-safetensors/resolve/main/t2iadapter_depth-fp16.safetensors"
96
+ #"https://huggingface.co/webui/ControlNet-modules-safetensors/resolve/main/t2iadapter_keypose-fp16.safetensors"
97
+ #"https://huggingface.co/webui/ControlNet-modules-safetensors/resolve/main/t2iadapter_openpose-fp16.safetensors"
98
+ #"https://huggingface.co/webui/ControlNet-modules-safetensors/resolve/main/t2iadapter_seg-fp16.safetensors"
99
+ #"https://huggingface.co/webui/ControlNet-modules-safetensors/resolve/main/t2iadapter_sketch-fp16.safetensors"
100
+ #"https://huggingface.co/webui/ControlNet-modules-safetensors/resolve/main/t2iadapter_style-fp16.safetensors"
101
+ )
102
+
103
+ ### DO NOT EDIT BELOW HERE UNLESS YOU KNOW WHAT YOU ARE DOING ###
104
+
105
+ function provisioning_start() {
106
+ if [[ ! -d /opt/environments/python ]]; then
107
+ export MAMBA_BASE=true
108
+ fi
109
+ source /opt/ai-dock/etc/environment.sh
110
+ source /opt/ai-dock/bin/venv-set.sh comfyui
111
+
112
+ if provisioning_has_valid_hf_token; then
113
+ UNET_MODELS+=("https://huggingface.co/black-forest-labs/FLUX.1-dev/resolve/main/flux1-dev.safetensors")
114
+ VAE_MODELS+=("https://huggingface.co/black-forest-labs/FLUX.1-dev/resolve/main/ae.safetensors")
115
+ else
116
+ UNET_MODELS+=("https://huggingface.co/black-forest-labs/FLUX.1-schnell/resolve/main/flux1-schnell.safetensors")
117
+ VAE_MODELS+=("https://huggingface.co/black-forest-labs/FLUX.1-schnell/resolve/main/ae.safetensors")
118
+ sed -i 's/flux1-dev\.safetensors/flux1-schnell.safetensors/g' /opt/ComfyUI/web/scripts/defaultGraph.js
119
+ fi
120
+
121
+ provisioning_print_header
122
+ provisioning_get_apt_packages
123
+ provisioning_get_nodes
124
+ provisioning_get_pip_packages
125
+ provisioning_get_models \
126
+ "${WORKSPACE}/ComfyUI/models/ckpt" \
127
+ "${CHECKPOINT_MODELS[@]}"
128
+ provisioning_get_models \
129
+ "${WORKSPACE}/ComfyUI/models/unet" \
130
+ "${UNET_MODELS[@]}"
131
+ provisioning_get_models \
132
+ "${WORKSPACE}/ComfyUI/models/clip" \
133
+ "${CLIP_MODELS[@]}"
134
+ provisioning_get_models \
135
+ "${WORKSPACE}/ComfyUI/models/lora" \
136
+ "${LORA_MODELS[@]}"
137
+ provisioning_get_models \
138
+ "${WORKSPACE}/ComfyUI/models/controlnet" \
139
+ "${CONTROLNET_MODELS[@]}"
140
+ provisioning_get_models \
141
+ "${WORKSPACE}/ComfyUI/models/vae" \
142
+ "${VAE_MODELS[@]}"
143
+ provisioning_get_models \
144
+ "${WORKSPACE}/ComfyUI/models/esrgan" \
145
+ "${ESRGAN_MODELS[@]}"
146
+ provisioning_get_workflows
147
+ provisioning_print_end
148
+ }
149
+
150
+ function pip_install() {
151
+ if [[ -z $MAMBA_BASE ]]; then
152
+ "$COMFYUI_VENV_PIP" install --no-cache-dir "$@"
153
+ else
154
+ micromamba run -n comfyui pip install --no-cache-dir "$@"
155
+ fi
156
+ }
157
+
158
+ function provisioning_get_apt_packages() {
159
+ if [[ -n $APT_PACKAGES ]]; then
160
+ sudo $APT_INSTALL ${APT_PACKAGES[@]}
161
+ fi
162
+ }
163
+
164
+ function provisioning_get_pip_packages() {
165
+ if [[ -n $PIP_PACKAGES ]]; then
166
+ pip_install ${PIP_PACKAGES[@]}
167
+ fi
168
+ }
169
+
170
+ function provisioning_get_nodes() {
171
+ for repo in "${NODES[@]}"; do
172
+ dir="${repo##*/}"
173
+ path="/opt/ComfyUI/custom_nodes/${dir}"
174
+ requirements="${path}/requirements.txt"
175
+ if [[ -d $path ]]; then
176
+ if [[ ${AUTO_UPDATE,,} != "false" ]]; then
177
+ printf "Updating node: %s...\n" "${repo}"
178
+ ( cd "$path" && git pull )
179
+ if [[ -e $requirements ]]; then
180
+ pip_install -r "$requirements"
181
+ fi
182
+ fi
183
+ else
184
+ printf "Downloading node: %s...\n" "${repo}"
185
+ git clone "${repo}" "${path}" --recursive
186
+ if [[ -e $requirements ]]; then
187
+ pip_install -r "${requirements}"
188
+ fi
189
+ fi
190
+ done
191
+ }
192
+
193
+ function provisioning_get_workflows() {
194
+ for repo in "${WORKFLOWS[@]}"; do
195
+ dir=$(basename "$repo" .git)
196
+ path="/opt/ComfyUI/user/default/workflows/${dir}"
197
+ if [[ -d "$path" ]]; then
198
+ if [[ ${AUTO_UPDATE,,} != "false" ]]; then
199
+ printf "Updating workflows: %s...\n" "${repo}"
200
+ ( cd "$path" && git pull )
201
+ fi
202
+ else
203
+ printf "Cloning workflows: %s...\n" "${repo}"
204
+ git clone "$repo" "$path"
205
+ fi
206
+ done
207
+ }
208
+
209
+ function provisioning_get_default_workflow() {
210
+ if [[ -n $DEFAULT_WORKFLOW ]]; then
211
+ workflow_json=$(curl -s "$DEFAULT_WORKFLOW")
212
+ if [[ -n $workflow_json ]]; then
213
+ echo "export const defaultGraph = $workflow_json;" > /opt/ComfyUI/web/scripts/defaultGraph.js
214
+ fi
215
+ fi
216
+ }
217
+
218
+ function provisioning_get_models() {
219
+ if [[ -z $2 ]]; then return 1; fi
220
+
221
+ dir="$1"
222
+ mkdir -p "$dir"
223
+ shift
224
+ arr=("$@")
225
+ printf "Downloading %s model(s) to %s...\n" "${#arr[@]}" "$dir"
226
+ for url in "${arr[@]}"; do
227
+ printf "Downloading: %s\n" "${url}"
228
+ provisioning_download "${url}" "${dir}"
229
+ printf "\n"
230
+ done
231
+ }
232
+
233
+ function provisioning_print_header() {
234
+ 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"
235
+ if [[ $DISK_GB_ALLOCATED -lt $DISK_GB_REQUIRED ]]; then
236
+ 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"
237
+ fi
238
+ }
239
+
240
+ function provisioning_print_end() {
241
+ printf "\nProvisioning complete: Web UI will start now\n\n"
242
+ }
243
+
244
+ function provisioning_has_valid_hf_token() {
245
+ [[ -n "$HF_TOKEN" ]] || return 1
246
+ url="https://huggingface.co/api/whoami-v2"
247
+
248
+ response=$(curl -o /dev/null -s -w "%{http_code}" -X GET "$url" \
249
+ -H "Authorization: Bearer $HF_TOKEN" \
250
+ -H "Content-Type: application/json")
251
+
252
+ # Check if the token is valid
253
+ if [ "$response" -eq 200 ]; then
254
+ return 0
255
+ else
256
+ return 1
257
+ fi
258
+ }
259
+
260
+ function provisioning_has_valid_civitai_token() {
261
+ [[ -n "$CIVITAI_TOKEN" ]] || return 1
262
+ url="https://civitai.com/api/v1/models?hidden=1&limit=1"
263
+
264
+ response=$(curl -o /dev/null -s -w "%{http_code}" -X GET "$url" \
265
+ -H "Authorization: Bearer $CIVITAI_TOKEN" \
266
+ -H "Content-Type: application/json")
267
+
268
+ # Check if the token is valid
269
+ if [ "$response" -eq 200 ]; then
270
+ return 0
271
+ else
272
+ return 1
273
+ fi
274
+ }
275
+
276
+ # Download from $1 URL to $2 file path
277
+ function provisioning_download() {
278
+ if [[ -n $HF_TOKEN && $1 =~ ^https://([a-zA-Z0-9_-]+\.)?huggingface\.co(/|$|\?) ]]; then
279
+ auth_token="$HF_TOKEN"
280
+ elif
281
+ [[ -n $CIVITAI_TOKEN && $1 =~ ^https://([a-zA-Z0-9_-]+\.)?civitai\.com(/|$|\?) ]]; then
282
+ auth_token="$CIVITAI_TOKEN"
283
+ fi
284
+ if [[ -n $auth_token ]];then
285
+ wget --header="Authorization: Bearer $auth_token" -qnc --content-disposition --show-progress -e dotbytes="${3:-4M}" -P "$2" "$1"
286
+ else
287
+ wget -qnc --content-disposition --show-progress -e dotbytes="${3:-4M}" -P "$2" "$1"
288
+ fi
289
+ }
290
+
291
+ provisioning_start