adbrasi commited on
Commit
a4c7ee6
·
verified ·
1 Parent(s): b3c18ef

Upload MeitabuPackreatorComfyUi2.sh

Browse files
Files changed (1) hide show
  1. MeitabuPackreatorComfyUi2.sh +458 -0
MeitabuPackreatorComfyUi2.sh ADDED
@@ -0,0 +1,458 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ # ComfyUI Automated Setup Script
4
+ # Supports LightningAI, RunPod, VastAI, and generic Linux environments
5
+ # Author: Generated for automated ComfyUI deployment
6
+ # Modified based on user request.
7
+
8
+ set -e
9
+ set -o pipefail
10
+
11
+ # ============================================================================
12
+ # GLOBAL CONFIGURATIONS
13
+ # ============================================================================
14
+
15
+ # Civitai API Token
16
+ readonly CIVITAI_TOKEN="0b698de03658fb8df2eeef90bad3ab9a"
17
+
18
+ # Custom Nodes to Install (from Git, handled by comfy-cli)
19
+ readonly CUSTOM_NODES=(
20
+ "https://github.com/adbrasi/huggpackreator"
21
+ "https://github.com/adbrasi/packreator_processor"
22
+ "https://github.com/Cezarsaint/Packreator_managerMEita"
23
+ "https://github.com/adbrasi/cezarsave34"
24
+ "https://github.com/adbrasi/pageonetor"
25
+ "https://github.com/adbrasi/pakreatorio"
26
+ "https://github.com/adbrasi/WaterMark_bumbumzin"
27
+ "https://github.com/adbrasi/marcadaguita"
28
+ "https://github.com/adbrasi/randomico"
29
+ "https://github.com/adbrasi/groqrouter"
30
+ "https://github.com/adbrasi/find_charakito"
31
+ "https://github.com/adbrasi/randomsizito"
32
+ "https://github.com/1038lab/ComfyUI-RMBG"
33
+ "https://github.com/Suzie1/ComfyUI_Comfyroll_CustomNodes"
34
+ "https://github.com/sipherxyz/comfyui-art-venture"
35
+ "https://github.com/pamparamm/sd-perturbed-attention"
36
+ "https://github.com/KoreTeknology/ComfyUI-Universal-Styler"
37
+ "https://github.com/WASasquatch/was-node-suite-comfyui"
38
+ "https://github.com/chflame163/ComfyUI_LayerStyle"
39
+ "https://github.com/ltdrdata/ComfyUI-Impact-Pack"
40
+ "https://github.com/pythongosssss/ComfyUI-Custom-Scripts"
41
+ "https://github.com/rgthree/rgthree-comfy"
42
+ "https://github.com/ssitu/ComfyUI_UltimateSDUpscale"
43
+ )
44
+
45
+ # Custom Nodes from Registry
46
+ readonly REGISTRY_NODES=(
47
+ "civicomfy"
48
+ "ComfyUI-RMBG"
49
+ )
50
+
51
+ # Files to Download - Format: "URL|target_subdir|filename"
52
+ readonly DOWNLOAD_FILES=(
53
+ "https://civitai.com/api/download/models/1761560?type=Model&format=SafeTensor&size=pruned&fp=fp16|checkpoints|"
54
+ "https://civitai.com/api/download/models/1268294?type=Model&format=SafeTensor|loras|"
55
+ "https://civitai.com/api/download/models/1715330?type=Model&format=SafeTensor|loras|"
56
+ "https://civitai.com/api/download/models/1499397?type=Model&format=SafeTensor|loras|"
57
+ "https://huggingface.co/Kim2091/AnimeSharp/resolve/main/4x-AnimeSharp.pth|upscale_models|4x-AnimeSharp.pth"
58
+ "https://huggingface.co/Kim2091/AnimeSharpV3/resolve/main/2x-AnimeSharpV3.pth|upscale_models|2x-AnimeSharpV3.pth"
59
+ "https://huggingface.co/adbrasi/testedownload/resolve/main/99coins_anime_girl_face_m_seg.pt|ultralytics/bbox|99coins_anime_girl_face_m_seg.pt"
60
+ )
61
+
62
+ # Model directories to create
63
+ readonly MODEL_DIRS=(
64
+ "checkpoints"
65
+ "loras"
66
+ "upscale_models"
67
+ "ultralytics/bbox"
68
+ "Nudenet" # ### NOVO ### Adicionado para garantir que a pasta exista
69
+ )
70
+
71
+ # Workflow configuration
72
+ readonly WORKFLOW_URL="https://huggingface.co/adbrasi/testedownload/resolve/main/packreator_setup.json"
73
+
74
+ # Global variables
75
+ BASE_DIR=""
76
+ COMFY_INSTALL_DIR=""
77
+ MODELS_DIR=""
78
+ WORKFLOW_FILE=""
79
+ SUDO_PREFIX=""
80
+ ARIA2C_AVAILABLE=false
81
+ ENV_NAME=""
82
+
83
+ # ============================================================================
84
+ # UTILITY FUNCTIONS
85
+ # ============================================================================
86
+
87
+ log_info() {
88
+ echo "INFO: $1" >&2
89
+ }
90
+
91
+ log_warning() {
92
+ echo "WARNING: $1" >&2
93
+ }
94
+
95
+ log_error() {
96
+ echo "ERROR: $1" >&2
97
+ }
98
+
99
+ command_exists() {
100
+ command -v "$1" >/dev/null 2>&1
101
+ }
102
+
103
+ is_root() {
104
+ [ "$(id -u)" -eq 0 ]
105
+ }
106
+
107
+ # ============================================================================
108
+ # ENVIRONMENT DETECTION
109
+ # ============================================================================
110
+
111
+ detect_environment() {
112
+ log_info "Detecting environment..."
113
+
114
+ if [ -d "/teamspace/studios/this_studio" ]; then
115
+ BASE_DIR="/teamspace/studios/this_studio"
116
+ ENV_NAME="lightning"
117
+ elif [ -d "/workspace" ] && [ ! -d "/teamspace/studios/this_studio" ]; then
118
+ BASE_DIR="/workspace"
119
+ ENV_NAME="runpod"
120
+ elif is_root && [ ! -d "/teamspace/studios/this_studio" ] && [ ! -d "/workspace" ]; then
121
+ BASE_DIR="/root"
122
+ ENV_NAME="vastai"
123
+ else
124
+ BASE_DIR="$HOME"
125
+ ENV_NAME="generic"
126
+ fi
127
+
128
+ COMFY_INSTALL_DIR="${BASE_DIR}/my_comfy_setup"
129
+ MODELS_DIR="${COMFY_INSTALL_DIR}/models"
130
+ WORKFLOW_FILE="${COMFY_INSTALL_DIR}/workflow.json"
131
+
132
+ log_info "Environment detected: $ENV_NAME"
133
+ log_info "Base directory: $BASE_DIR"
134
+ log_info "ComfyUI install directory: $COMFY_INSTALL_DIR"
135
+ log_info "Models directory: $MODELS_DIR"
136
+ }
137
+
138
+ # ============================================================================
139
+ # PERMISSION MANAGEMENT
140
+ # ============================================================================
141
+
142
+ setup_permissions() {
143
+ log_info "Setting up permissions..."
144
+
145
+ if is_root; then
146
+ SUDO_PREFIX=""
147
+ log_info "Running as root, no sudo needed"
148
+ elif command_exists sudo; then
149
+ SUDO_PREFIX="sudo "
150
+ log_info "Non-root user with sudo available"
151
+ else
152
+ SUDO_PREFIX=""
153
+ log_warning "Non-root user without sudo, some system operations may fail"
154
+ fi
155
+ }
156
+
157
+ # ============================================================================
158
+ # SYSTEM DEPENDENCIES
159
+ # ============================================================================
160
+
161
+ install_system_dependencies() {
162
+ log_info "Installing system dependencies..."
163
+
164
+ if command_exists apt-get; then
165
+ ${SUDO_PREFIX}apt-get update -qq || log_warning "Failed to update package list"
166
+ ${SUDO_PREFIX}apt-get install -y -qq python3 python3-pip git || { log_error "Failed to install basic dependencies (python3, pip, git)"; exit 1; }
167
+ if ${SUDO_PREFIX}apt-get install -y -qq aria2 >/dev/null 2>&1; then ARIA2C_AVAILABLE=true; log_info "aria2c installed successfully"; else ARIA2C_AVAILABLE=false; log_info "aria2c installation failed, will use wget/curl as fallback"; fi
168
+ else
169
+ log_warning "apt-get not available, skipping system package installation"
170
+ if command_exists aria2c; then ARIA2C_AVAILABLE=true; log_info "aria2c already available"; fi
171
+ fi
172
+ }
173
+
174
+ # ============================================================================
175
+ # COMFY-CLI INSTALLATION
176
+ # ============================================================================
177
+
178
+ install_comfy_cli() {
179
+ log_info "Installing comfy-cli..."
180
+
181
+ python3 -m pip install --upgrade comfy-cli || { log_error "Failed to install comfy-cli"; exit 1; }
182
+
183
+ if ! command_exists comfy; then
184
+ if [ -d "$HOME/.local/bin" ]; then export PATH="$HOME/.local/bin:$PATH"; log_info "Added $HOME/.local/bin to PATH"; fi
185
+ if ! command_exists comfy; then log_error "comfy command not found in PATH after installation"; exit 1; fi
186
+ fi
187
+
188
+ log_info "comfy-cli version: $(comfy --version 2>/dev/null || echo 'unknown')"
189
+ }
190
+
191
+ # ============================================================================
192
+ # COMFYUI CORE INSTALLATION
193
+ # ============================================================================
194
+
195
+ install_comfyui_core() {
196
+ log_info "Installing ComfyUI core..."
197
+ comfy --workspace "$COMFY_INSTALL_DIR" --skip-prompt install --nvidia || { log_error "Failed to install ComfyUI core"; exit 1; }
198
+ log_info "ComfyUI core installed successfully"
199
+ }
200
+
201
+ # ============================================================================
202
+ # DIRECTORY STRUCTURE
203
+ # ============================================================================
204
+
205
+ create_model_directories() {
206
+ log_info "Creating model directories..."
207
+ for dir in "${MODEL_DIRS[@]}"; do mkdir -p "$MODELS_DIR/$dir"; log_info "Created directory: $MODELS_DIR/$dir"; done
208
+ mkdir -p "$COMFY_INSTALL_DIR"
209
+ }
210
+
211
+ # ============================================================================
212
+ # CUSTOM NODES INSTALLATION
213
+ # ============================================================================
214
+
215
+ install_custom_nodes() {
216
+ log_info "Installing custom nodes..."
217
+
218
+ # Install nodes from registry
219
+ for node in "${REGISTRY_NODES[@]}"; do
220
+ log_info "Installing custom node from registry: $node"
221
+ comfy --workspace "$COMFY_INSTALL_DIR" node registry-install "$node" || { log_warning "Failed to install custom node from registry: $node"; }
222
+ done
223
+
224
+ # Install nodes from Git repositories
225
+ for node_url in "${CUSTOM_NODES[@]}"; do
226
+ log_info "Installing custom node from Git: $node_url"
227
+ comfy --workspace "$COMFY_INSTALL_DIR" node install "$node_url" || { log_warning "Failed to install custom node: $node_url"; }
228
+ done
229
+ }
230
+
231
+ # ============================================================================
232
+ # SPECIAL NODE: WD14 TAGGER (GIT CLONE METHOD)
233
+ # ============================================================================
234
+
235
+ install_wd14_tagger_node() {
236
+ log_info "Installing WD14 Tagger node via git clone..."
237
+ local node_repo="https://github.com/pythongosssss/ComfyUI-WD14-Tagger.git"
238
+ local node_name="ComfyUI-WD14-Tagger"
239
+ local custom_nodes_dir="${COMFY_INSTALL_DIR}/custom_nodes"
240
+ local target_dir="${custom_nodes_dir}/${node_name}"
241
+ local requirements_file="${target_dir}/requirements.txt"
242
+
243
+ # Ensure custom nodes directory exists
244
+ mkdir -p "$custom_nodes_dir"
245
+
246
+ if [ -d "$target_dir" ]; then
247
+ log_info "WD14 Tagger node already exists. Skipping clone."
248
+ else
249
+ log_info "Cloning WD14 Tagger repository into $target_dir"
250
+ if ! git clone "$node_repo" "$target_dir"; then
251
+ log_error "Failed to clone WD14 Tagger repository."
252
+ return 1
253
+ fi
254
+ fi
255
+
256
+ if [ -f "$requirements_file" ]; then
257
+ log_info "Installing WD14 Tagger dependencies from $requirements_file..."
258
+ if ! python3 -m pip install -r "$requirements_file"; then
259
+ log_warning "Failed to install WD14 Tagger dependencies. This might cause issues."
260
+ else
261
+ log_info "WD14 Tagger dependencies installed successfully."
262
+ fi
263
+ else
264
+ log_info "No requirements.txt found for WD14 Tagger. Skipping dependency installation."
265
+ fi
266
+ }
267
+
268
+ # ============================================================================
269
+ # SPECIAL NODE: STORY DIFFUSION
270
+ # ============================================================================
271
+
272
+ install_story_diffusion_node() {
273
+ log_info "Installing special node: StoryDiffusion..."
274
+ local node_repo="https://github.com/smthemex/ComfyUI_StoryDiffusion.git"
275
+ local node_name="ComfyUI_StoryDiffusion"
276
+ local custom_nodes_dir="${COMFY_INSTALL_DIR}/custom_nodes"
277
+ local target_dir="${custom_nodes_dir}/${node_name}"
278
+ local requirements_file="${target_dir}/requirements.txt"
279
+
280
+ # Garante que o diretório de nós customizados exista
281
+ mkdir -p "$custom_nodes_dir"
282
+
283
+ if [ -d "$target_dir" ]; then
284
+ log_info "StoryDiffusion node already exists. Skipping clone."
285
+ else
286
+ log_info "Cloning StoryDiffusion repository into $target_dir"
287
+ if ! git clone "$node_repo" "$target_dir"; then
288
+ log_error "Failed to clone StoryDiffusion repository."
289
+ # Continuar mesmo com falha, apenas avisar
290
+ return 1
291
+ fi
292
+ fi
293
+
294
+ if [ -f "$requirements_file" ]; then
295
+ log_info "Installing StoryDiffusion dependencies from $requirements_file..."
296
+ if ! python3 -m pip install -r "$requirements_file"; then
297
+ log_warning "Failed to install StoryDiffusion dependencies. This might cause issues."
298
+ else
299
+ log_info "StoryDiffusion dependencies installed successfully."
300
+ fi
301
+ else
302
+ log_info "No requirements.txt found for StoryDiffusion. Skipping dependency installation."
303
+ fi
304
+ }
305
+
306
+ # ============================================================================
307
+ # ### NOVO ### SPECIAL NODE: NUDENET
308
+ # ============================================================================
309
+
310
+ install_nudenet_node() {
311
+ log_info "Installing special node: NudeNet..."
312
+ local node_repo="https://github.com/phuvinh010701/ComfyUI-NudeNet.git"
313
+ local node_name="ComfyUI-NudeNet"
314
+ local custom_nodes_dir="${COMFY_INSTALL_DIR}/custom_nodes"
315
+ local target_dir="${custom_nodes_dir}/${node_name}"
316
+ local requirements_file="${target_dir}/requirements.txt"
317
+
318
+ # Etapa 1: Clonar o repositório se não existir
319
+ mkdir -p "$custom_nodes_dir"
320
+ if [ -d "$target_dir" ]; then
321
+ log_info "NudeNet node directory already exists. Skipping clone."
322
+ else
323
+ log_info "Cloning NudeNet repository into $target_dir"
324
+ if ! git clone "$node_repo" "$target_dir"; then
325
+ log_error "Failed to clone NudeNet repository."
326
+ return 1 # Abortar a instalação deste node específico
327
+ fi
328
+ fi
329
+
330
+ # Etapa 2: Instalar dependências do requirements.txt
331
+ if [ -f "$requirements_file" ]; then
332
+ log_info "Installing NudeNet dependencies from $requirements_file..."
333
+ if ! python3 -m pip install -r "$requirements_file"; then
334
+ log_warning "Failed to install NudeNet dependencies. This might cause issues."
335
+ else
336
+ log_info "NudeNet dependencies installed successfully."
337
+ fi
338
+ else
339
+ log_info "No requirements.txt found for NudeNet. Skipping dependency installation."
340
+ fi
341
+
342
+ # Etapa 3: Baixar o modelo .onnx para a pasta correta
343
+ log_info "Setting up NudeNet model..."
344
+ local nudenet_model_dir="${MODELS_DIR}/Nudenet"
345
+ local nudenet_model_url="https://d2xl8ijk56kv4u.cloudfront.net/models/nudenet.onnx"
346
+ local nudenet_model_filename="nudenet.onnx"
347
+ local nudenet_model_path="${nudenet_model_dir}/${nudenet_model_filename}"
348
+
349
+ mkdir -p "$nudenet_model_dir" # Garante que o diretório de destino exista
350
+
351
+ if [ -f "$nudenet_model_path" ]; then
352
+ log_info "NudeNet model already exists at $nudenet_model_path. Skipping download."
353
+ else
354
+ log_info "Downloading NudeNet model to $nudenet_model_path..."
355
+ if ! download_file "$nudenet_model_url" "$nudenet_model_dir" "$nudenet_model_filename"; then
356
+ log_error "Failed to download the NudeNet model. The node may not work correctly."
357
+ else
358
+ log_info "NudeNet model downloaded successfully."
359
+ fi
360
+ fi
361
+ }
362
+
363
+ # ============================================================================
364
+ # DOWNLOAD FUNCTIONS
365
+ # ============================================================================
366
+
367
+ add_civitai_token() { local url="$1"; if [[ "$url" == *"civitai.com/api/download"* ]] && [[ "$url" != *"token="* ]]; then echo "${url}&token=${CIVITAI_TOKEN}"; else echo "$url"; fi; }
368
+
369
+ download_file() {
370
+ local url="$1"; local target_dir="$2"; local filename="$3"; url=$(add_civitai_token "$url"); local download_cmd=""; local success=false
371
+ if $ARIA2C_AVAILABLE && command_exists aria2c; then local aria_opts="-c -s 16 -x 16 -k 1M --console-log-level=warn --summary-interval=0"; if [ -n "$filename" ]; then download_cmd="aria2c $aria_opts --dir=\"$target_dir\" --out=\"$filename\" \"$url\""; else download_cmd="aria2c $aria_opts --dir=\"$target_dir\" --content-disposition=true \"$url\""; fi; if eval "$download_cmd" >/dev/null 2>&1; then success=true; fi; fi
372
+ if ! $success && command_exists wget; then local wget_opts="-q --show-progress -c"; if [ -n "$filename" ]; then download_cmd="wget $wget_opts -O \"$target_dir/$filename\" \"$url\""; else download_cmd="wget $wget_opts --content-disposition -P \"$target_dir\" \"$url\""; fi; if eval "$download_cmd"; then success=true; fi; fi
373
+ if ! $success && command_exists curl; then log_warning "Using curl fallback for $url"; if [ -n "$filename" ]; then download_cmd="curl -L -C - -o \"$target_dir/$filename\" \"$url\""; else if curl --help 2>/dev/null | grep -q "output-dir"; then download_cmd="curl -L -J -O --output-dir \"$target_dir\" \"$url\""; else local fallback_name; fallback_name=$(basename "$url" | cut -d'?' -f1); [ -z "$fallback_name" ] && fallback_name="downloaded_file"; download_cmd="curl -L -C - -o \"$target_dir/$fallback_name\" \"$url\""; fi; fi; if eval "$download_cmd"; then success=true; fi; fi
374
+ if ! $success; then log_error "Failed to download: $url"; return 1; fi; return 0
375
+ }
376
+
377
+ # ============================================================================
378
+ # PARALLEL DOWNLOADS
379
+ # ============================================================================
380
+
381
+ download_all_files() {
382
+ log_info "Starting parallel downloads..."; local pids=(); local download_logs=()
383
+ for file_spec in "${DOWNLOAD_FILES[@]}"; do IFS='|' read -r url target_subdir filename <<< "$file_spec"; local target_dir="$MODELS_DIR/$target_subdir"; local display_name="${filename:-$(basename "$url" | cut -d'?' -f1)}"; log_info "Starting download: $display_name -> $target_dir"; local log_file; log_file=$(mktemp); download_logs+=("$log_file"); ( if download_file "$url" "$target_dir" "$filename" >"$log_file" 2>&1; then echo "SUCCESS: Downloaded $display_name" >> "$log_file"; else echo "FAILED: Failed to download $display_name" >> "$log_file"; exit 1; fi ) & pids+=($!); done
384
+ local failed_count=0; for i in "${!pids[@]}"; do if wait "${pids[$i]}"; then log_info "Download completed successfully"; else failed_count=$((failed_count + 1)); log_warning "Download failed - check logs"; fi; if [ -f "${download_logs[$i]}" ]; then cat "${download_logs[$i]}" >&2; rm -f "${download_logs[$i]}"; fi; done
385
+ if [ $failed_count -gt 0 ]; then log_warning "$failed_count downloads failed, but continuing..."; else log_info "All downloads completed successfully"; fi
386
+ }
387
+
388
+ # ============================================================================
389
+ # WORKFLOW DOWNLOAD
390
+ # ============================================================================
391
+
392
+ download_workflow() {
393
+ log_info "Baixando o workflow de: $WORKFLOW_URL"; log_info "Salvando como: $WORKFLOW_FILE"; local success=false
394
+ if command_exists wget; then if wget -q --show-progress -O "$WORKFLOW_FILE" "$WORKFLOW_URL"; then success=true; fi; fi
395
+ if ! $success && command_exists curl; then if curl -L -o "$WORKFLOW_FILE" "$WORKFLOW_URL"; then success=true; fi; fi
396
+ if ! $success && command_exists aria2c; then if aria2c -q -o "$(basename "$WORKFLOW_FILE")" -d "$(dirname "$WORKFLOW_FILE")" "$WORKFLOW_URL"; then success=true; fi; fi
397
+ if ! $success; then log_error "Nenhuma ferramenta de download (wget, curl, aria2c) funcionou ou está disponível."; exit 1; fi
398
+ if [ ! -f "$WORKFLOW_FILE" ]; then log_error "O arquivo do workflow não foi baixado com sucesso."; exit 1; fi; log_info "Workflow baixado com sucesso."
399
+ }
400
+
401
+ # ============================================================================
402
+ # WORKFLOW DEPENDENCIES
403
+ # ============================================================================
404
+
405
+ install_workflow_dependencies() {
406
+ log_info "Instalando dependências do workflow a partir de: $WORKFLOW_FILE"
407
+ if [ ! -f "$WORKFLOW_FILE" ]; then log_error "Arquivo de workflow não encontrado: $WORKFLOW_FILE"; return 1; fi
408
+ comfy --workspace "$COMFY_INSTALL_DIR" node install-deps --workflow="$WORKFLOW_FILE" || { log_warning "Algumas dependências do workflow podem ter falhado ao instalar."; log_info "Isso pode ser normal. O ComfyUI mostrará os nós ausentes ao iniciar."; }
409
+ log_info "Instalação de dependências do workflow concluída."
410
+ }
411
+
412
+ # ============================================================================
413
+ # COMFYUI LAUNCH
414
+ # ============================================================================
415
+
416
+ launch_comfyui() {
417
+ log_info "Launching ComfyUI on port 8818..."; log_info "ComfyUI will be accessible at: http://0.0.0.0:8818"
418
+ exec comfy --workspace "$COMFY_INSTALL_DIR" launch -- --fast --highvram --preview-method latent2rgb --listen 0.0.0.0 --port 8818
419
+ }
420
+
421
+ # ============================================================================
422
+ # MAIN EXECUTION
423
+ # ============================================================================
424
+
425
+ main() {
426
+ log_info "Starting ComfyUI automated setup..."
427
+ log_info "========================================"
428
+
429
+ detect_environment
430
+ setup_permissions
431
+ install_system_dependencies
432
+ install_comfy_cli
433
+ install_comfyui_core
434
+ create_model_directories
435
+ install_custom_nodes
436
+
437
+ # Install special nodes and their dependencies
438
+ install_wd14_tagger_node
439
+ install_story_diffusion_node
440
+ install_nudenet_node # ### NOVO ### Chamada para a nova função
441
+
442
+ download_all_files
443
+ download_workflow
444
+ install_workflow_dependencies
445
+
446
+ log_info "========================================"
447
+ log_info "Setup completed successfully!"
448
+ log_info "========================================"
449
+ launch_comfyui
450
+ }
451
+
452
+ # ============================================================================
453
+ # SCRIPT EXECUTION
454
+ # ============================================================================
455
+
456
+ trap 'log_error "Script interrupted"; exit 1' INT TERM
457
+
458
+ main "$@"