adbrasi commited on
Commit
4a4ca07
·
verified ·
1 Parent(s): fc08a6d

Upload MeitabuPackreatorComfyUi3.sh

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