Benni32947239874927384 commited on
Commit
77de436
·
verified ·
1 Parent(s): 479739d

Upload comfyui_kontext.sh

Browse files
Files changed (1) hide show
  1. comfyui_kontext.sh +222 -0
comfyui_kontext.sh ADDED
@@ -0,0 +1,222 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ source /venv/main/bin/activate
4
+ COMFYUI_DIR=${WORKSPACE}/ComfyUI
5
+ COMFYUI_VERSION="v0.3.56"
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
+ "onnxruntime-gpu"
15
+ "sageattention"
16
+ #"package-1"
17
+ #"package-2"
18
+ )
19
+
20
+ NODES=(
21
+ "https://github.com/cubiq/ComfyUI_essentials"
22
+ "https://github.com/kijai/ComfyUI-KJNodes"
23
+ "https://github.com/chflame163/ComfyUI_LayerStyle"
24
+ "https://github.com/yarik1988/comfyui_controlnet_aux"
25
+ "https://github.com/rgthree/rgthree-comfy"
26
+ "https://github.com/ltdrdata/ComfyUI-Impact-Pack"
27
+ "https://github.com/crystian/ComfyUI-Crystools"
28
+ #"https://github.com/ltdrdata/ComfyUI-Manager"
29
+ #"https://github.com/cubiq/ComfyUI_essentials"
30
+ )
31
+
32
+ WORKFLOWS=(
33
+
34
+ )
35
+
36
+ CHECKPOINT_MODELS=(
37
+ "https://huggingface.co/Comfy-Org/flux1-kontext-dev_ComfyUI/resolve/main/split_files/diffusion_models/flux1-dev-kontext_fp8_scaled.safetensors"
38
+ )
39
+
40
+ UNET_MODELS=(
41
+ )
42
+
43
+ LORA_MODELS=(
44
+ "https://huggingface.co/ByteDance/Hyper-SD/resolve/main/Hyper-FLUX.1-dev-8steps-lora.safetensors"
45
+ "https://civitai.com/api/download/models/1053505?type=Model&format=SafeTensor"
46
+ "https://civitai.com/api/download/models/1963302?type=Model&format=SafeTensor"
47
+ "https://civitai.com/api/download/models/1671848?type=Model&format=SafeTensor"
48
+ "https://civitai.com/api/download/models/1566229?type=Model&format=SafeTensor"
49
+ "https://civitai.com/api/download/models/305200?type=Model&format=SafeTensor"
50
+ "https://civitai.com/api/download/models/789742?type=Model&format=SafeTensor"
51
+ )
52
+
53
+ VAE_MODELS=(
54
+ "https://huggingface.co/Comfy-Org/Lumina_Image_2.0_Repackaged/resolve/main/split_files/vae/ae.safetensors"
55
+ )
56
+
57
+ TEXT_ENCODERS=(
58
+ "https://huggingface.co/comfyanonymous/flux_text_encoders/resolve/main/clip_l.safetensors"
59
+ "https://huggingface.co/comfyanonymous/flux_text_encoders/resolve/main/t5xxl_fp8_e4m3fn_scaled.safetensors"
60
+ )
61
+
62
+ ESRGAN_MODELS=(
63
+ )
64
+
65
+ CONTROLNET_MODELS=(
66
+ )
67
+
68
+ ### DO NOT EDIT BELOW HERE UNLESS YOU KNOW WHAT YOU ARE DOING ###
69
+
70
+ function provisioning_start() {
71
+ provisioning_print_header
72
+ provisioning_get_apt_packages
73
+ provisioning_update_comfyui
74
+ provisioning_get_nodes
75
+ provisioning_get_pip_packages
76
+ provisioning_get_files \
77
+ "${COMFYUI_DIR}/models/diffusion_models" \
78
+ "${CHECKPOINT_MODELS[@]}"
79
+ provisioning_get_files \
80
+ "${COMFYUI_DIR}/models/unet" \
81
+ "${UNET_MODELS[@]}"
82
+ provisioning_get_files \
83
+ "${COMFYUI_DIR}/models/loras" \
84
+ "${LORA_MODELS[@]}"
85
+ provisioning_get_files \
86
+ "${COMFYUI_DIR}/models/controlnet" \
87
+ "${CONTROLNET_MODELS[@]}"
88
+ provisioning_get_files \
89
+ "${COMFYUI_DIR}/models/vae" \
90
+ "${VAE_MODELS[@]}"
91
+ provisioning_get_files \
92
+ "${COMFYUI_DIR}/models/text_encoders" \
93
+ "${TEXT_ENCODERS[@]}"
94
+ provisioning_get_files \
95
+ "${COMFYUI_DIR}/models/esrgan" \
96
+ "${ESRGAN_MODELS[@]}"
97
+ provisioning_print_end
98
+ }
99
+
100
+ function provisioning_update_comfyui() {
101
+ # Update (or clone) the ComfyUI repo and pin to $COMFYUI_VERSION
102
+ cd "$COMFYUI_DIR" \
103
+ && git fetch --all --tags --prune \
104
+ && git checkout -f "$COMFYUI_VERSION"
105
+
106
+ # Re-install requirements every time in case the tag changed deps
107
+ if [[ -f "$COMFYUI_DIR/requirements.txt" ]]; then
108
+ printf "Installing ComfyUI requirements…\n"
109
+ pip install --no-cache-dir -r "$COMFYUI_DIR/requirements.txt"
110
+ fi
111
+ }
112
+
113
+
114
+ function provisioning_get_apt_packages() {
115
+ if [[ -n $APT_PACKAGES ]]; then
116
+ sudo $APT_INSTALL ${APT_PACKAGES[@]}
117
+ fi
118
+ }
119
+
120
+ function provisioning_get_pip_packages() {
121
+ if [[ -n $PIP_PACKAGES ]]; then
122
+ pip install --no-cache-dir ${PIP_PACKAGES[@]}
123
+ fi
124
+ }
125
+
126
+ function provisioning_get_nodes() {
127
+ for repo in "${NODES[@]}"; do
128
+ dir="${repo##*/}"
129
+ path="${COMFYUI_DIR}/custom_nodes/${dir}"
130
+ requirements="${path}/requirements.txt"
131
+ if [[ -d $path ]]; then
132
+ if [[ ${AUTO_UPDATE,,} != "false" ]]; then
133
+ printf "Updating node: %s...\n" "${repo}"
134
+ ( cd "$path" && git pull )
135
+ if [[ -e $requirements ]]; then
136
+ pip install --no-cache-dir -r "$requirements"
137
+ fi
138
+ fi
139
+ else
140
+ printf "Downloading node: %s...\n" "${repo}"
141
+ git clone "${repo}" "${path}" --recursive
142
+ if [[ -e $requirements ]]; then
143
+ pip install --no-cache-dir -r "${requirements}"
144
+ fi
145
+ fi
146
+ done
147
+ }
148
+
149
+ function provisioning_get_files() {
150
+ if [[ -z $2 ]]; then return 1; fi
151
+
152
+ dir="$1"
153
+ mkdir -p "$dir"
154
+ shift
155
+ arr=("$@")
156
+ printf "Downloading %s model(s) to %s...\n" "${#arr[@]}" "$dir"
157
+ for url in "${arr[@]}"; do
158
+ printf "Downloading: %s\n" "${url}"
159
+ provisioning_download "${url}" "${dir}"
160
+ printf "\n"
161
+ done
162
+ }
163
+
164
+ function provisioning_print_header() {
165
+ 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"
166
+ }
167
+
168
+ function provisioning_print_end() {
169
+ printf "\nProvisioning complete: Application will start now\n\n"
170
+ }
171
+
172
+ function provisioning_has_valid_hf_token() {
173
+ [[ -n "$HF_TOKEN" ]] || return 1
174
+ url="https://huggingface.co/api/whoami-v2"
175
+
176
+ response=$(curl -o /dev/null -s -w "%{http_code}" -X GET "$url" \
177
+ -H "Authorization: Bearer $HF_TOKEN" \
178
+ -H "Content-Type: application/json")
179
+
180
+ # Check if the token is valid
181
+ if [ "$response" -eq 200 ]; then
182
+ return 0
183
+ else
184
+ return 1
185
+ fi
186
+ }
187
+
188
+ function provisioning_has_valid_civitai_token() {
189
+ [[ -n "$CIVITAI_TOKEN" ]] || return 1
190
+ url="https://civitai.com/api/v1/models?hidden=1&limit=1"
191
+
192
+ response=$(curl -o /dev/null -s -w "%{http_code}" -X GET "$url" \
193
+ -H "Authorization: Bearer $CIVITAI_TOKEN" \
194
+ -H "Content-Type: application/json")
195
+
196
+ # Check if the token is valid
197
+ if [ "$response" -eq 200 ]; then
198
+ return 0
199
+ else
200
+ return 1
201
+ fi
202
+ }
203
+
204
+ # Download from $1 URL to $2 file path
205
+ function provisioning_download() {
206
+ if [[ -n $HF_TOKEN && $1 =~ ^https://([a-zA-Z0-9_-]+\.)?huggingface\.co(/|$|\?) ]]; then
207
+ auth_token="$HF_TOKEN"
208
+ elif
209
+ [[ -n $CIVITAI_TOKEN && $1 =~ ^https://([a-zA-Z0-9_-]+\.)?civitai\.com(/|$|\?) ]]; then
210
+ auth_token="$CIVITAI_TOKEN"
211
+ fi
212
+ if [[ -n $auth_token ]];then
213
+ wget --header="Authorization: Bearer $auth_token" -qnc --content-disposition --show-progress -e dotbytes="${3:-4M}" -P "$2" "$1"
214
+ else
215
+ wget -qnc --content-disposition --show-progress -e dotbytes="${3:-4M}" -P "$2" "$1"
216
+ fi
217
+ }
218
+
219
+ # Allow user to disable provisioning if they started with a script they didn't want
220
+ if [[ ! -f /.noprovisioning ]]; then
221
+ provisioning_start
222
+ fi