adbrasi commited on
Commit
0a2638d
·
verified ·
1 Parent(s): 90bd83a

Upload ImageStudioQWEN.sh

Browse files
Files changed (1) hide show
  1. ImageStudioQWEN.sh +435 -0
ImageStudioQWEN.sh ADDED
@@ -0,0 +1,435 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env bash
2
+ # setup_comfyui_simple.sh
3
+ # Script simples para instalação do ComfyUI
4
+
5
+ set -euo pipefail
6
+
7
+ # Cores
8
+ RED='\033[0;31m'
9
+ GREEN='\033[0;32m'
10
+ YELLOW='\033[1;33m'
11
+ BLUE='\033[0;34m'
12
+ NC='\033[0m'
13
+
14
+ log_info() { echo -e "${BLUE}[INFO]${NC} $1"; }
15
+ log_success() { echo -e "${GREEN}[✓]${NC} $1"; }
16
+ log_warn() { echo -e "${YELLOW}[!]${NC} $1"; }
17
+ log_error() { echo -e "${RED}[✗]${NC} $1"; }
18
+
19
+ drop_caches() {
20
+ sync
21
+ echo 3 > /proc/sys/vm/drop_caches || true
22
+ }
23
+
24
+ flush_cache_if_large() {
25
+ local file_path="$1"
26
+ if [ -f "$file_path" ]; then
27
+ local sz
28
+ sz=$(stat -c%s "$file_path" 2>/dev/null || echo 0)
29
+ if [ "$sz" -ge 209715200 ]; then
30
+ drop_caches
31
+ fi
32
+ else
33
+ drop_caches
34
+ fi
35
+ }
36
+
37
+ # Configuração
38
+ COMFY_BASE="/workspace/comfy"
39
+ COMFY_DIR="$COMFY_BASE/ComfyUI"
40
+ MODELS_DIR="$COMFY_DIR/models"
41
+ COMFY_HOST="0.0.0.0"
42
+ COMFY_PORT="8818"
43
+ VENV_DIR="$COMFY_BASE/.venv"
44
+ CIVITAI_TOKEN="4fcb2834969399006a736ee402b061e5"
45
+
46
+ export DEBIAN_FRONTEND=noninteractive
47
+ export HF_HOME="/workspace/.hf"
48
+ export HUGGINGFACE_HUB_CACHE="$HF_HOME"
49
+ export TRANSFORMERS_CACHE="$HF_HOME"
50
+ export TMPDIR="/workspace/.tmp"
51
+ export GIT_LFS_SKIP_SMUDGE=1
52
+ export PIP_NO_CACHE_DIR=off
53
+
54
+ PIP_FLAGS="--no-cache-dir --prefer-binary --only-binary=:all:"
55
+ ARIA="aria2c -c -x 2 -s 2 --disk-cache=0 --file-allocation=none --console-log-level=warn"
56
+
57
+ # Garantir diretórios necessários para instalar fora de /root e concentrar caches
58
+ mkdir -p "$COMFY_BASE" "$HF_HOME" "$TMPDIR"
59
+
60
+ # Performance
61
+ export MAX_JOBS=32
62
+ export HF_HUB_ENABLE_HF_TRANSFER=1
63
+
64
+ # Lista de downloads - Formato: "URL|TIPO|NOME_OPCIONAL"
65
+ DOWNLOAD_FILES=(
66
+ # Mega primeiro (sem nome forçado - usar nome original)
67
+ #"mega://https://mega.nz/file/gIRTFQSQ#no6Ay3JLE9LVRi7ib9O-Jc0CW7XmG046kCgpCzDg1tY|loras|"
68
+ "https://civitai.com/api/download/models/1828803?type=Model&format=SafeTensor&size=full&fp=fp16|checkpoints|"
69
+ # Checkpoints
70
+ "https://huggingface.co/Comfy-Org/Qwen-Image-Edit_ComfyUI/resolve/main/split_files/diffusion_models/qwen_image_edit_2509_fp8_e4m3fn.safetensors|diffusion_models|qwen_image_edit_2509_fp8_e4m3fn.safetensors"
71
+
72
+ "https://huggingface.co/Comfy-Org/Qwen-Image_ComfyUI/resolve/main/split_files/text_encoders/qwen_2.5_vl_7b_fp8_scaled.safetensors|text_encoders|qwen_2.5_vl_7b_fp8_scaled.safetensors"
73
+ "https://huggingface.co/Comfy-Org/Qwen-Image_ComfyUI/resolve/main/split_files/vae/qwen_image_vae.safetensors|vae|qwen_image_vae.safetensors"
74
+
75
+ "https://huggingface.co/lightx2v/Qwen-Image-Lightning/resolve/main/Qwen-Image-fp8-e4m3fn-Lightning-4steps-V1.0-fp32.safetensors|loras|Qwen-Image-fp8-e4m3fn-Lightning-4steps-V1.0-fp32.safetensors"
76
+ "https://huggingface.co/lightx2v/Qwen-Image-Lightning/resolve/main/Qwen-Image-Lightning-8steps-V2.0.safetensors|loras|Qwen-Image-Lightning-8steps-V2.0.safetensors"
77
+ "https://huggingface.co/lovis93/next-scene-qwen-image-lora-2509/resolve/main/next-scene_lora-v2-3000.safetensors|loras|next-scene_lora-v2-3000.safetensors"
78
+ "https://huggingface.co/adbrasi/wanlotest/resolve/main/multiangleQWEN.safetensors|loras|Qwen-Edit-2509-Multiple-angles.safetensors"
79
+ # LoRAs Civitai
80
+ "https://civitai.com/api/download/models/1818185?type=Model&format=SafeTensor|loras|"
81
+ "https://civitai.com/api/download/models/2295041?type=Model&format=SafeTensor|loras|"
82
+ "https://civitai.com/api/download/models/1245271?type=Model&format=SafeTensor|loras|"
83
+ "https://civitai.com/api/download/models/2310692?type=Model&format=SafeTensor|loras|"
84
+ "https://civitai.com/api/download/models/1164079?type=Model&format=SafeTensor|loras|"
85
+ "https://civitai.com/api/download/models/1031892?type=Model&format=SafeTensor|loras|"
86
+ "https://civitai.com/api/download/models/1452729?type=Model&format=SafeTensor|loras|"
87
+ "https://civitai.com/api/download/models/1969737?type=Model&format=SafeTensor|loras|"
88
+ "https://civitai.com/api/download/models/1941518?type=Model&format=SafeTensor|loras|"
89
+ "https://civitai.com/api/download/models/1941518?type=Model&format=SafeTensor|loras|"
90
+ "https://civitai.com/api/download/models/1431530?type=Model&format=SafeTensor|loras|"
91
+ "https://civitai.com/api/download/models/1777446?type=Model&format=SafeTensor|loras|"
92
+ "https://civitai.com/api/download/models/1565457?type=Model&format=SafeTensor|loras|"
93
+ "https://civitai.com/api/download/models/2326498?type=Model&format=SafeTensor|loras|"
94
+ "https://civitai.com/api/download/models/938035?type=Model&format=SafeTensor|loras|"
95
+ "https://civitai.com/api/download/models/1444623?type=Model&format=SafeTensor|loras|"
96
+ "https://civitai.com/api/download/models/1295936?type=Model&format=SafeTensor|loras|"
97
+ "https://civitai.com/api/download/models/2068919?type=Model&format=SafeTensor|loras|"
98
+ "https://civitai.com/api/download/models/1280931?type=Model&format=SafeTensor|loras|"
99
+ "https://civitai.com/api/download/models/2238110?type=Model&format=SafeTensor|loras|"
100
+ "https://civitai.com/api/download/models/1453075?type=Model&format=SafeTensor|loras|"
101
+ "https://civitai.com/api/download/models/1630029?type=Model&format=SafeTensor|loras|"
102
+ "https://civitai.com/api/download/models/2296528?type=Model&format=SafeTensor|loras|"
103
+ "https://civitai.com/api/download/models/1268294?type=Model&format=SafeTensor|loras|"
104
+ "https://civitai.com/api/download/models/1148809?type=Model&format=SafeTensor|loras|"
105
+ "https://civitai.com/api/download/models/1715330?type=Model&format=SafeTensor|loras|"
106
+ "https://civitai.com/api/download/models/1715330?type=Model&format=SafeTensor|loras|"
107
+ "https://civitai.com/api/download/models/1499397?type=Model&format=SafeTensor|loras|"
108
+ "https://civitai.com/api/download/models/1779002?type=Model&format=SafeTensor|loras|"
109
+ "https://civitai.com/api/download/models/1114313?type=Model&format=SafeTensor|loras|"
110
+ "https://civitai.com/api/download/models/1780244?type=Model&format=SafeTensor|loras|"
111
+ "https://civitai.com/api/download/models/1613410?type=Model&format=SafeTensor|loras|"
112
+ "https://civitai.com/api/download/models/1804885?type=Model&format=SafeTensor|loras|"
113
+ "https://civitai.com/api/download/models/1809575?type=Model&format=SafeTensor|loras|"
114
+ "https://civitai.com/api/download/models/2135873?type=Model&format=SafeTensor|loras|"
115
+ "https://civitai.com/api/download/models/2332149?type=Model&format=SafeTensor|loras|"
116
+ "https://civitai.com/api/download/models/1517104?type=Model&format=SafeTensor|loras|"
117
+ "https://civitai.com/api/download/models/1112990?type=Model&format=SafeTensor|loras|"
118
+ "https://civitai.com/api/download/models/1379428?type=Model&format=SafeTensor|loras|"
119
+ "https://civitai.com/api/download/models/1755071?type=Model&format=SafeTensor|loras|"
120
+ "https://civitai.com/api/download/models/2298959?type=Model&format=SafeTensor|loras|"
121
+ "https://civitai.com/api/download/models/1936647?type=Model&format=SafeTensor|loras|"
122
+ "https://civitai.com/api/download/models/1583448?type=Model&format=SafeTensor|loras|"
123
+ "https://civitai.com/api/download/models/1873259?type=Model&format=SafeTensor|loras|"
124
+ "https://civitai.com/api/download/models/1570568?type=Model&format=SafeTensor|loras|"
125
+ "https://civitai.com/api/download/models/1563658?type=Model&format=SafeTensor|loras|"
126
+ "https://civitai.com/api/download/models/1445868?type=Model&format=SafeTensor|loras|"
127
+ "https://civitai.com/api/download/models/1415706?type=Model&format=SafeTensor|loras|"
128
+ "https://civitai.com/api/download/models/1373187?type=Model&format=SafeTensor|loras|"
129
+ "https://civitai.com/api/download/models/2066157?type=Model&format=SafeTensor|loras|"
130
+ "https://civitai.com/api/download/models/1741819?type=Model&format=SafeTensor|loras|"
131
+ "https://civitai.com/api/download/models/1833157?type=Model&format=SafeTensor|embeddings|"
132
+
133
+ "https://huggingface.co/Anzhc/Anzhcs_YOLOs/resolve/main/Anzhc%20Face%20seg%201024%20v2%20y8n.pt|ultralytics/bbox|Anzhc_Faceseg_1024_v2_y8n.pt"
134
+ "https://dl.fbaipublicfiles.com/segment_anything/sam_vit_b_01ec64.pth|sams|sam_vit_b_01ec64.pth"
135
+ "https://huggingface.co/adbrasi/wanlotest/resolve/main/Eyeful_v2-Individual.pt|ultralytics/bbox|Eyeful_v2-Paired.pt"
136
+ "https://huggingface.co/Bingsu/adetailer/resolve/main/hand_yolov8s.pt|ultralytics/bbox|hand_yolov8s.pt"
137
+ "https://huggingface.co/adbrasi/wanlotest/resolve/main/ntd11_anime_nsfw_segm_v5-variant1.pt|ultralytics/bbox|ntd11_anime_nsfw_segm_v5-variant1.pt"
138
+ "https://civitai.com/api/download/models/2121199?type=Model&format=Other|embeddings|"
139
+ "https://civitai.com/api/download/models/1195487?type=Negative&format=Other|embeddings|"
140
+ "https://civitai.com/api/download/models/1470551?type=Model&format=SafeTensor|embeddings|"
141
+ # Upscalers
142
+ "https://huggingface.co/adbrasi/wanlotest/resolve/main/2x-AnimeSharpV4_RCAN_fp16_op17.onnx|upscale_models|2x-AnimeSharpV4_RCAN_fp16_op17.onnx"
143
+ "https://huggingface.co/Kim2091/AnimeSharp/resolve/main/4x-AnimeSharp.pth|upscale_models|4x-AnimeSharp.pth"
144
+ "https://huggingface.co/adbrasi/wanlotest/resolve/main/2x-AnimeSharpV4_Fast_RCAN_PU.safetensors|upscale_models|2x-AnimeSharpV4_Fast_RCAN_PU.safetensors"
145
+ "https://huggingface.co/Kim2091/AnimeSharpV3/resolve/main/2x-AnimeSharpV3.pth|upscale_models|2x-AnimeSharpV3.pth"
146
+ "https://huggingface.co/FacehugmanIII/4x_foolhardy_Remacri/resolve/main/4x_foolhardy_Remacri.pth"
147
+ "https://huggingface.co/Kim2091/UltraSharpV2/resolve/main/4x-UltraSharpV2.pth|upscale_models|4x-UltraSharpV2.pth"
148
+ "https://huggingface.co/Kim2091/UltraSharpV2/resolve/main/4x-UltraSharpV2_Lite.pth|upscale_models|4x-UltraSharpV2_Lite.pth"
149
+
150
+ # Ultralytics
151
+ "https://huggingface.co/adbrasi/testedownload/resolve/main/99coins_anime_girl_face_m_seg.pt|ultralytics/bbox|99coins_anime_girl_face_m_seg.pt"
152
+ )
153
+
154
+ # Custom nodes
155
+ CUSTOM_NODES=(
156
+ "https://github.com/adbrasi/huggpackreator"
157
+ "https://github.com/adbrasi/packreator_processor"
158
+ "https://github.com/Cezarsaint/Packreator_managerMEita"
159
+ "https://github.com/adbrasi/cezarsave34"
160
+ "https://github.com/adbrasi/pageonetor"
161
+ "https://github.com/QuietNoise/comfyui_queue_manager"
162
+ "https://github.com/adbrasi/pakreatorio"
163
+ "https://github.com/adbrasi/WaterMark_bumbumzin"
164
+ "https://github.com/adbrasi/marcadaguita"
165
+ "https://github.com/adbrasi/randomico"
166
+ "https://github.com/kijai/ComfyUI-KJNodes"
167
+ "https://github.com/ltdrdata/ComfyUI-Inspire-Pack"
168
+ "https://github.com/Goshe-nite/comfyui-gps-supplements"
169
+ "https://github.com/adbrasi/groqrouter"
170
+ "https://github.com/adbrasi/find_charakito"
171
+ "https://github.com/adbrasi/randomsizito"
172
+ "https://github.com/adbrasi/importex"
173
+ "https://github.com/adbrasi/storitadifusita"
174
+ "https://github.com/adbrasi/attentionPPM"
175
+ "https://github.com/Suzie1/ComfyUI_Comfyroll_CustomNodes"
176
+ "https://github.com/sipherxyz/comfyui-art-venture"
177
+ "https://github.com/pamparamm/sd-perturbed-attention"
178
+ "https://github.com/KoreTeknology/ComfyUI-Universal-Styler"
179
+ "https://github.com/WASasquatch/was-node-suite-comfyui"
180
+ "https://github.com/chflame163/ComfyUI_LayerStyle"
181
+ "https://github.com/newtextdoc1111/ComfyUI-Autocomplete-Plus"
182
+ "https://github.com/pythongosssss/ComfyUI-WD14-Tagger"
183
+ "https://github.com/ltdrdata/ComfyUI-Impact-Pack"
184
+ "https://github.com/pythongosssss/ComfyUI-Custom-Scripts"
185
+ "https://github.com/rgthree/rgthree-comfy"
186
+ "https://github.com/ssitu/ComfyUI_UltimateSDUpscale"
187
+ "https://github.com/adbrasi/Importador"
188
+ "https://github.com/adbrasi/GetFirstTag"
189
+ "https://github.com/adbrasi/comfydodi"
190
+ "https://github.com/omar92/ComfyUI-QualityOfLifeSuit_Omar92"
191
+ "https://github.com/Cezarsaint/blacklisto"
192
+ "https://github.com/TinyTerra/ComfyUI_tinyterraNodes"
193
+ "https://github.com/ltdrdata/ComfyUI-Impact-Subpack"
194
+ "https://github.com/Cezarsaint/rand0micoUploaderLoven"
195
+ "https://github.com/adbrasi/pixivmosaic"
196
+ "https://github.com/adbrasi/futfilter"
197
+ "https://github.com/Artificial-Sweetener/comfyui-WhiteRabbit"
198
+ "https://github.com/shiimizu/ComfyUI_smZNodes"
199
+ "https://github.com/CoreyCorza/ComfyUI-CRZnodes"
200
+ "https://github.com/MoonGoblinDev/Civicomfy"
201
+ "https://github.com/regiellis/ComfyUI-EasyIllustrious"
202
+ "https://github.com/adbrasi/captionizador"
203
+ "https://github.com/Jonseed/ComfyUI-Detail-Daemon"
204
+ "https://github.com/WASasquatch/was-node-suite-comfyui"
205
+ "https://github.com/fearnworks/ComfyUI_FearnworksNodes"
206
+ "https://github.com/aria1th/ComfyUI-LogicUtils"
207
+ "https://github.com/Extraltodeus/ComfyUI-AutomaticCFG"
208
+ "https://github.com/pythongosssss/ComfyUI-Custom-Scripts"
209
+ "https://github.com/ltdrdata/ComfyUI-Impact-Pack"
210
+ "https://github.com/ltdrdata/ComfyUI-Impact-Subpack"
211
+ "https://github.com/huchenlei/ComfyUI_DanTagGen"
212
+ "https://github.com/adbrasi/captionsaver"
213
+ "https://github.com/adbrasi/captionizador"
214
+ )
215
+
216
+ # Download HuggingFace
217
+ download_hf() {
218
+ local url="$1"
219
+ local target_dir="$2"
220
+ local filename="$3"
221
+
222
+ if [ -n "$filename" ] && [ -f "$target_dir/$filename" ]; then
223
+ log_success "Já existe: $filename"
224
+ return 0
225
+ fi
226
+
227
+ log_info "Baixando HF: $filename"
228
+
229
+ if command -v hf >/dev/null 2>&1; then
230
+ cd "$target_dir"
231
+ hf download "$(dirname "$url")" "$(basename "$url")" --local-dir . 2>/dev/null
232
+ cd - >/dev/null
233
+ else
234
+ wget -q --show-progress -c -O "$target_dir/$filename" "https://huggingface.co/$url"
235
+ fi
236
+
237
+ if [ -n "$filename" ]; then
238
+ flush_cache_if_large "$target_dir/$filename"
239
+ else
240
+ drop_caches
241
+ fi
242
+ }
243
+
244
+ # Download Mega
245
+ download_mega() {
246
+ local url="$1"
247
+ local target_dir="$2"
248
+
249
+ # Remover prefixo mega://
250
+ url="${url#mega://}"
251
+
252
+ log_info "Baixando do Mega..."
253
+
254
+ cd "$target_dir"
255
+ # Usar megadl simples sem forçar nome
256
+ if megadl "$url" 2>/dev/null; then
257
+ log_success "Mega download OK"
258
+ else
259
+ log_warn "Mega download falhou"
260
+ fi
261
+ cd - >/dev/null
262
+ drop_caches
263
+ }
264
+
265
+ # Download normal
266
+ download_file() {
267
+ local url="$1"
268
+ local target_dir="$2"
269
+ local filename="$3"
270
+
271
+ # Adicionar token Civitai se necessário
272
+ if [[ "$url" == *"civitai.com"* ]] && [[ "$url" != *"token="* ]]; then
273
+ url="${url}&token=${CIVITAI_TOKEN}"
274
+ fi
275
+
276
+ if [ -n "$filename" ] && [ -f "$target_dir/$filename" ]; then
277
+ log_success "Já existe: $filename"
278
+ return 0
279
+ fi
280
+
281
+ log_info "Baixando: ${filename:-arquivo}"
282
+
283
+ # Tentar com aria2c primeiro
284
+ if command -v aria2c >/dev/null 2>&1; then
285
+ if [ -n "$filename" ]; then
286
+ $ARIA --dir="$target_dir" --out="$filename" "$url" || \
287
+ wget -q --show-progress -c -O "$target_dir/$filename" "$url" || \
288
+ log_error "Download falhou: $filename"
289
+ else
290
+ $ARIA --dir="$target_dir" "$url" || \
291
+ (cd "$target_dir" && wget -q --show-progress -c "$url") || \
292
+ log_error "Download falhou: $url"
293
+ fi
294
+ elif [ -n "$filename" ]; then
295
+ wget -q --show-progress -c -O "$target_dir/$filename" "$url" || \
296
+ log_error "Download falhou: $filename"
297
+ else
298
+ (cd "$target_dir" && wget -q --show-progress -c "$url") || \
299
+ log_error "Download falhou: $url"
300
+ fi
301
+
302
+ if [ -n "$filename" ]; then
303
+ flush_cache_if_large "$target_dir/$filename"
304
+ else
305
+ drop_caches
306
+ fi
307
+ }
308
+
309
+ # Processar downloads
310
+ process_downloads() {
311
+ for entry in "${DOWNLOAD_FILES[@]}"; do
312
+ IFS='|' read -r url type filename <<< "$entry"
313
+
314
+ # Criar diretório
315
+ local target_dir="$MODELS_DIR/$type"
316
+ mkdir -p "$target_dir"
317
+
318
+ # Baixar arquivo
319
+ if [[ "$url" == mega://* ]]; then
320
+ download_mega "$url" "$target_dir"
321
+ elif [[ "$url" == *.huggingface.co/* ]]; then
322
+ local hf_path="${url#*huggingface.co/}"
323
+ download_hf "$hf_path" "$target_dir" "$filename"
324
+ else
325
+ download_file "$url" "$target_dir" "$filename"
326
+ fi
327
+ done
328
+ }
329
+
330
+ # Clone git repo
331
+ clone_repo() {
332
+ local url="$1"
333
+ local dest="$2"
334
+
335
+ if [ -d "$dest/.git" ]; then
336
+ git -C "$dest" pull --ff-only 2>/dev/null || true
337
+ else
338
+ git clone --depth 1 "$url" "$dest" 2>/dev/null || true
339
+ fi
340
+
341
+ # Instalar requirements se existir (comportamento original)
342
+ if [ -f "$dest/requirements.txt" ]; then
343
+ python -m pip install -q -r "$dest/requirements.txt" 2>/dev/null || true
344
+ fi
345
+ }
346
+
347
+ # ========== INSTALAÇÃO ==========
348
+
349
+ log_info "========================================="
350
+ log_info " ComfyUI Setup"
351
+ log_info "========================================="
352
+
353
+ # 1. Instalar dependências
354
+ log_info "[1/6] Instalando dependências do sistema..."
355
+
356
+ apt-get update -qq
357
+ apt-get install -y -qq --no-install-recommends python3-venv aria2 megatools git wget curl 2>/dev/null
358
+ apt-get clean
359
+ rm -rf /var/lib/apt/lists/*
360
+
361
+ log_success "Dependências do sistema instaladas"
362
+
363
+ log_info "[2/6] Preparando ambiente virtual..."
364
+
365
+ if [ ! -d "$VENV_DIR/bin" ]; then
366
+ python3 -m venv "$VENV_DIR"
367
+ log_success "Ambiente virtual criado em $VENV_DIR"
368
+ else
369
+ log_info "Ambiente virtual já existe em $VENV_DIR"
370
+ fi
371
+
372
+ . "$VENV_DIR/bin/activate"
373
+
374
+ python -m pip install ${PIP_FLAGS} -U pip wheel setuptools -q
375
+ python -m pip install ${PIP_FLAGS} -U "huggingface_hub[cli,hf_transfer]" comfy-cli -q
376
+
377
+ log_success "Ambiente virtual pronto e comfy-cli instalado"
378
+
379
+ # 3. Instalar ComfyUI
380
+ log_info "[3/6] Instalando ComfyUI..."
381
+
382
+ if [ -f "$COMFY_DIR/main.py" ]; then
383
+ log_warn "ComfyUI já existe"
384
+ else
385
+ comfy --skip-prompt --workspace "$COMFY_DIR" install --fast-deps --nvidia --version "0.3.67"
386
+ fi
387
+
388
+ log_success "ComfyUI instalado"
389
+
390
+ # 4. Corrigir PyTorch para RTX 5090 se detectado
391
+ log_info "[4/6] Verificando GPU..."
392
+
393
+ GPU_INFO=$(nvidia-smi --query-gpu=name --format=csv,noheader 2>/dev/null || echo "")
394
+
395
+ if [[ "$GPU_INFO" == *"5090"* ]] || [[ "$GPU_INFO" == *"5080"* ]]; then
396
+ log_warn "RTX 5090/5080 detectada - instalando PyTorch nightly"
397
+ python -m pip install ${PIP_FLAGS} --force-reinstall torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu128
398
+ else
399
+ log_info "GPU: ${GPU_INFO:-Não detectada}"
400
+ fi
401
+
402
+ log_success "PyTorch configurado"
403
+
404
+ # 5. Baixar modelos
405
+ log_info "[5/6] Baixando modelos..."
406
+
407
+ process_downloads
408
+
409
+ log_success "Downloads processados"
410
+
411
+ # 6. Instalar custom nodes
412
+ log_info "[6/6] Instalando custom nodes..."
413
+
414
+ CN_DIR="$COMFY_DIR/custom_nodes"
415
+ mkdir -p "$CN_DIR"
416
+
417
+ for repo in "${CUSTOM_NODES[@]}"; do
418
+ node_name=$(basename "$repo")
419
+ clone_repo "$repo" "$CN_DIR/$node_name"
420
+ done
421
+
422
+ log_success "Custom nodes instalados"
423
+
424
+ # Verificar e iniciar
425
+ log_info "========================================="
426
+ log_success "Instalação concluída!"
427
+ log_info "Iniciando ComfyUI..."
428
+ log_info "URL: http://localhost:$COMFY_PORT"
429
+ log_info "========================================="
430
+
431
+ rm -rf "$TMPDIR"
432
+ mkdir -p "$TMPDIR"
433
+
434
+ cd "$COMFY_DIR"
435
+ exec comfy --workspace "$COMFY_DIR" launch -- --listen "$COMFY_HOST" --preview-method latent2rgb --front-end-version Comfy-Org/ComfyUI_frontend@v1.28.8 --port "$COMFY_PORT"