Update wanFullForTest.sh
Browse files- wanFullForTest.sh +324 -445
wanFullForTest.sh
CHANGED
|
@@ -13,10 +13,10 @@ YELLOW='\033[1;33m'
|
|
| 13 |
BLUE='\033[0;34m'
|
| 14 |
NC='\033[0m'
|
| 15 |
|
| 16 |
-
log_info()
|
| 17 |
log_success() { echo -e "${GREEN}[✓]${NC} $1"; }
|
| 18 |
-
log_warn()
|
| 19 |
-
log_error()
|
| 20 |
|
| 21 |
# -----------------------------
|
| 22 |
# Configuração
|
|
@@ -25,8 +25,8 @@ COMFY_DIR="/root/comfy/ComfyUI"
|
|
| 25 |
MODELS_DIR="$COMFY_DIR/models"
|
| 26 |
COMFY_HOST="${COMFY_HOST:-0.0.0.0}"
|
| 27 |
COMFY_PORT="${COMFY_PORT:-8818}"
|
| 28 |
-
CIVITAI_TOKEN="${CIVITAI_TOKEN:-
|
| 29 |
-
HF_TOKEN="${HF_TOKEN:-}"
|
| 30 |
|
| 31 |
# Configurações de performance
|
| 32 |
export MAX_JOBS=32
|
|
@@ -38,328 +38,231 @@ export HF_TRANSFER_CONCURRENCY=16
|
|
| 38 |
export EXT_PARALLEL=4
|
| 39 |
|
| 40 |
# -----------------------------
|
| 41 |
-
#
|
| 42 |
# -----------------------------
|
| 43 |
-
# Formato: "URL|TIPO|NOME_ARQUIVO_OPCIONAL"
|
| 44 |
readonly DOWNLOAD_FILES=(
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
)
|
| 64 |
|
| 65 |
-
|
| 66 |
-
# Mega.nz LoRA models
|
| 67 |
readonly MEGA_LORAS=(
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
)
|
| 80 |
|
| 81 |
-
# Mega.nz Upscale models
|
| 82 |
readonly MEGA_UPSCALE=(
|
| 83 |
-
|
| 84 |
-
|
| 85 |
)
|
| 86 |
|
| 87 |
-
#
|
| 88 |
-
readonly
|
| 89 |
-
"https://github.com/kijai/ComfyUI-Florence2"
|
| 90 |
-
"https://github.com/adbrasi/groqrouter"
|
| 91 |
-
"https://github.com/kijai/ComfyUI-WanVideoWrapper"
|
| 92 |
-
"https://github.com/Fannovel16/ComfyUI-Frame-Interpolation"
|
| 93 |
-
"https://github.com/kijai/ComfyUI-GIMM-VFI"
|
| 94 |
-
"https://github.com/Kosinkadink/ComfyUI-VideoHelperSuite"
|
| 95 |
-
"https://github.com/kijai/ComfyUI-KJNodes"
|
| 96 |
-
"https://github.com/Fannovel16/comfyui_controlnet_aux"
|
| 97 |
-
"https://github.com/Artificial-Sweetener/comfyui-WhiteRabbit"
|
| 98 |
-
"https://github.com/shiimizu/ComfyUI_smZNodes"
|
| 99 |
-
"https://github.com/CoreyCorza/ComfyUI-CRZnodes"
|
| 100 |
-
"https://github.com/pythongosssss/ComfyUI-Custom-Scripts"
|
| 101 |
-
"https://github.com/pythongosssss/ComfyUI-WD14-Tagger"
|
| 102 |
-
"https://github.com/WASasquatch/was-node-suite-comfyui"
|
| 103 |
-
"https://github.com/justUmen/Bjornulf_custom_nodes"
|
| 104 |
-
"https://github.com/mingsky-ai/ComfyUI-MingNodes"
|
| 105 |
-
"https://github.com/numz/ComfyUI-SeedVR2_VideoUpscaler"
|
| 106 |
-
"https://github.com/1038lab/ComfyUI-RMBG"
|
| 107 |
-
"https://github.com/wallish77/wlsh_nodes"
|
| 108 |
-
"https://github.com/yuvraj108c/ComfyUI-Upscaler-Tensorrt"
|
| 109 |
-
"https://github.com/raindrop313/ComfyUI-WanVideoStartEndFrames"
|
| 110 |
-
"https://github.com/MushroomFleet/DJZ-Nodes"
|
| 111 |
-
"https://github.com/Suzie1/ComfyUI_Comfyroll_CustomNodes"
|
| 112 |
-
"https://github.com/grmchn/ComfyUI-ProportionChanger"
|
| 113 |
-
)
|
| 114 |
|
| 115 |
# -----------------------------
|
| 116 |
# Funções auxiliares
|
| 117 |
# -----------------------------
|
| 118 |
-
command_exists() {
|
| 119 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 120 |
}
|
| 121 |
|
| 122 |
-
# Adicionar token do Civitai se necessário
|
| 123 |
add_civitai_token() {
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
|
|
|
| 127 |
else
|
| 128 |
-
|
| 129 |
fi
|
|
|
|
|
|
|
|
|
|
| 130 |
}
|
| 131 |
|
| 132 |
-
# Download HuggingFace
|
| 133 |
download_hf() {
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
local
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
download_success=true
|
| 167 |
-
fi
|
| 168 |
-
fi
|
| 169 |
-
|
| 170 |
-
# Se 'hf' não funcionou, tentar com huggingface-cli
|
| 171 |
-
if [ "$download_success" = false ] && command_exists huggingface-cli; then
|
| 172 |
-
log_warn "Tentando com huggingface-cli..."
|
| 173 |
-
if HF_HUB_ENABLE_HF_TRANSFER=1 huggingface-cli download "$repo" "$file_path" \
|
| 174 |
-
--local-dir "$temp_dir" \
|
| 175 |
-
--local-dir-use-symlinks False 2>/dev/null; then
|
| 176 |
-
download_success=true
|
| 177 |
-
fi
|
| 178 |
-
fi
|
| 179 |
-
|
| 180 |
-
if [ "$download_success" = true ]; then
|
| 181 |
-
# Procurar o arquivo baixado (pode estar em subdiretórios)
|
| 182 |
-
local downloaded_file=$(find "$temp_dir" -type f \( -name "*.safetensors" -o -name "*.pth" -o -name "*.pt" -o -name "*.bin" \) 2>/dev/null | head -1)
|
| 183 |
-
|
| 184 |
-
if [ -n "$downloaded_file" ]; then
|
| 185 |
-
# Mover para o destino correto com o nome correto
|
| 186 |
-
mv "$downloaded_file" "$target_file"
|
| 187 |
-
rm -rf "$temp_dir"
|
| 188 |
-
log_success "Download concluído: $filename"
|
| 189 |
-
return 0
|
| 190 |
-
else
|
| 191 |
-
log_error "Arquivo baixado mas não encontrado em $temp_dir"
|
| 192 |
-
fi
|
| 193 |
fi
|
| 194 |
-
|
| 195 |
-
|
| 196 |
-
|
| 197 |
-
|
|
|
|
| 198 |
}
|
| 199 |
|
| 200 |
# Download genérico com aria2c, wget ou curl
|
| 201 |
download_file() {
|
| 202 |
-
|
| 203 |
-
|
| 204 |
-
|
| 205 |
-
|
| 206 |
-
|
| 207 |
-
|
| 208 |
-
|
| 209 |
-
|
| 210 |
-
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
|
| 214 |
-
|
| 215 |
-
log_info "Baixando: ${filename:-$(basename "$url" | cut -d'?' -f1)}"
|
| 216 |
-
|
| 217 |
-
# Tentar com aria2c primeiro (mais rápido)
|
| 218 |
-
if command_exists aria2c; then
|
| 219 |
-
local aria_opts="-c -s 16 -x 16 -k 1M --console-log-level=warn --summary-interval=10"
|
| 220 |
-
if [ -n "$filename" ]; then
|
| 221 |
-
aria2c $aria_opts --dir="$target_dir" --out="$filename" "$url" && return 0
|
| 222 |
-
else
|
| 223 |
-
aria2c $aria_opts --dir="$target_dir" "$url" && return 0
|
| 224 |
-
fi
|
| 225 |
fi
|
| 226 |
-
|
| 227 |
-
|
| 228 |
-
if
|
| 229 |
-
|
| 230 |
-
wget -q --show-progress -c -O "$target_dir/$filename" "$url" && return 0
|
| 231 |
-
else
|
| 232 |
-
wget -q --show-progress -c --content-disposition -P "$target_dir" "$url" && return 0
|
| 233 |
-
fi
|
| 234 |
fi
|
| 235 |
-
|
| 236 |
-
|
| 237 |
-
if
|
| 238 |
-
|
| 239 |
-
|
| 240 |
-
|
| 241 |
-
|
| 242 |
-
|
| 243 |
-
|
| 244 |
-
|
| 245 |
-
fi
|
| 246 |
-
curl -L -# -C - -o "$target_dir/$detected_name" "$url" && return 0
|
| 247 |
-
fi
|
| 248 |
fi
|
| 249 |
-
|
| 250 |
-
|
| 251 |
-
|
|
|
|
| 252 |
}
|
| 253 |
|
| 254 |
-
# Download
|
| 255 |
download_mega() {
|
| 256 |
-
|
| 257 |
-
|
| 258 |
-
|
| 259 |
-
|
| 260 |
-
|
| 261 |
-
|
| 262 |
-
|
| 263 |
-
|
| 264 |
-
|
| 265 |
-
|
| 266 |
-
fi
|
| 267 |
-
|
| 268 |
-
log_info "Baixando de Mega.nz: $url"
|
| 269 |
|
| 270 |
-
|
| 271 |
-
|
| 272 |
-
|
| 273 |
-
|
| 274 |
-
cd - > /dev/null
|
| 275 |
-
return 0
|
| 276 |
-
else
|
| 277 |
-
log_error "Falha ao baixar de Mega.nz: $url"
|
| 278 |
-
cd - > /dev/null
|
| 279 |
-
return 1
|
| 280 |
-
fi
|
| 281 |
}
|
| 282 |
|
| 283 |
# Processar lista de downloads
|
| 284 |
process_downloads() {
|
| 285 |
-
|
| 286 |
-
|
| 287 |
-
|
| 288 |
-
|
| 289 |
-
|
| 290 |
-
|
| 291 |
-
|
| 292 |
-
|
| 293 |
-
|
| 294 |
-
|
| 295 |
-
|
| 296 |
-
|
| 297 |
-
|
| 298 |
-
|
| 299 |
-
|
| 300 |
-
|
| 301 |
-
|
| 302 |
-
|
| 303 |
-
|
| 304 |
-
|
| 305 |
-
|
| 306 |
-
|
| 307 |
-
tensorrt) target_dir="$MODELS_DIR/tensorrt" ;;
|
| 308 |
-
tensorrt_rife) target_dir="$MODELS_DIR/tensorrt/rife" ;;
|
| 309 |
-
*) target_dir="$MODELS_DIR/$type" ;;
|
| 310 |
-
esac
|
| 311 |
-
|
| 312 |
-
# Criar diretório se não existir
|
| 313 |
-
mkdir -p "$target_dir"
|
| 314 |
-
|
| 315 |
-
# Processar URL
|
| 316 |
-
if [[ "$url" == hf://* ]]; then
|
| 317 |
-
# HuggingFace download
|
| 318 |
-
url="${url#hf://}" # Remove prefixo hf://
|
| 319 |
-
|
| 320 |
-
# Separar repo e caminho do arquivo
|
| 321 |
-
local repo=$(echo "$url" | cut -d'/' -f1-2)
|
| 322 |
-
local file_path=$(echo "$url" | cut -d'/' -f3-)
|
| 323 |
-
|
| 324 |
-
download_hf "$repo" "$file_path" "$target_dir" "$filename" || ((failed_count++))
|
| 325 |
-
else
|
| 326 |
-
# Download normal (HTTP/HTTPS)
|
| 327 |
-
download_file "$url" "$target_dir" "$filename" || ((failed_count++))
|
| 328 |
-
fi
|
| 329 |
-
done
|
| 330 |
-
|
| 331 |
-
return $failed_count
|
| 332 |
}
|
| 333 |
|
| 334 |
# Clonar ou atualizar repositório git
|
| 335 |
clone_or_update() {
|
| 336 |
-
|
| 337 |
-
|
| 338 |
-
|
| 339 |
-
|
| 340 |
-
|
| 341 |
-
|
| 342 |
-
|
| 343 |
-
|
| 344 |
-
|
| 345 |
-
|
| 346 |
-
|
| 347 |
-
|
| 348 |
-
|
| 349 |
-
|
| 350 |
-
log_warn "Falha ao clonar $node_name"
|
| 351 |
-
return 0 # Não falhar, apenas avisar
|
| 352 |
-
}
|
| 353 |
-
fi
|
| 354 |
-
|
| 355 |
-
# Instalar requirements se existir (com timeout)
|
| 356 |
-
if [ -f "$dest/requirements.txt" ]; then
|
| 357 |
-
timeout 120 python3 -m pip install --no-warn-script-location -q -r "$dest/requirements.txt" 2>/dev/null || {
|
| 358 |
-
log_warn "Falha ao instalar requirements para $node_name"
|
| 359 |
-
}
|
| 360 |
-
fi
|
| 361 |
-
|
| 362 |
-
return 0
|
| 363 |
}
|
| 364 |
|
| 365 |
# -----------------------------
|
|
@@ -367,66 +270,49 @@ clone_or_update() {
|
|
| 367 |
# -----------------------------
|
| 368 |
echo ""
|
| 369 |
log_info "========================================="
|
| 370 |
-
log_info " ComfyUI + Wan 2.2 Setup (Fixed
|
| 371 |
log_info "========================================="
|
| 372 |
echo ""
|
| 373 |
|
| 374 |
# [1] Verificar e instalar dependências
|
| 375 |
log_info "[1/10] Verificando e instalando dependências..."
|
| 376 |
|
| 377 |
-
# Instalar aria2c e megatools se não existirem
|
| 378 |
if ! command_exists aria2c || ! command_exists megadl; then
|
| 379 |
-
|
| 380 |
-
|
| 381 |
-
|
| 382 |
-
|
| 383 |
-
apt-get install -y -qq aria2 2>/dev/null
|
| 384 |
-
log_success "aria2c instalado"
|
| 385 |
-
fi
|
| 386 |
-
|
| 387 |
-
if ! command_exists megadl; then
|
| 388 |
-
apt-get install -y -qq megatools 2>/dev/null
|
| 389 |
-
log_success "megatools instalado"
|
| 390 |
-
fi
|
| 391 |
fi
|
| 392 |
|
| 393 |
for cmd in python3 git wget curl; do
|
| 394 |
-
|
| 395 |
-
|
| 396 |
-
|
| 397 |
-
|
| 398 |
done
|
| 399 |
log_success "Dependências OK"
|
| 400 |
|
| 401 |
# [2] Atualizar pip e instalar ferramentas
|
| 402 |
log_info "[2/10] Preparando ferramentas Python..."
|
| 403 |
python3 -m pip install --upgrade pip wheel setuptools -q
|
| 404 |
-
|
| 405 |
-
# Instalar huggingface_hub com CLI e hf_transfer para velocidade máxima
|
| 406 |
python3 -m pip install --upgrade "huggingface_hub[cli,hf_transfer]>=0.26.0" comfy-cli -q
|
| 407 |
|
| 408 |
-
# Configurar token HF se disponível (opcional)
|
| 409 |
-
HF_TOKEN="${HF_TOKEN:-}"
|
| 410 |
if [ -n "$HF_TOKEN" ]; then
|
| 411 |
-
|
| 412 |
-
|
| 413 |
-
|
| 414 |
-
log_warn "Falha ao configurar login HF, continuando sem autenticação"
|
| 415 |
-
fi
|
| 416 |
fi
|
| 417 |
|
| 418 |
-
# Verificar comandos disponíveis
|
| 419 |
if command_exists hf; then
|
| 420 |
-
|
| 421 |
elif command_exists huggingface-cli; then
|
| 422 |
-
|
| 423 |
else
|
| 424 |
-
|
| 425 |
fi
|
| 426 |
-
|
| 427 |
log_success "Ferramentas instaladas"
|
| 428 |
|
| 429 |
-
# [3]
|
| 430 |
log_info "[3/10] Instalando PyTorch com CUDA 12.8..."
|
| 431 |
python3 -m pip install --upgrade torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu128
|
| 432 |
log_success "PyTorch com CUDA 12.8 instalado"
|
|
@@ -434,166 +320,159 @@ log_success "PyTorch com CUDA 12.8 instalado"
|
|
| 434 |
# [4] Instalar ComfyUI
|
| 435 |
log_info "[4/10] Instalando ComfyUI..."
|
| 436 |
if [ -f "$COMFY_DIR/main.py" ]; then
|
| 437 |
-
|
| 438 |
else
|
| 439 |
-
|
| 440 |
-
|
| 441 |
-
|
| 442 |
-
|
| 443 |
-
|
| 444 |
-
exit 1
|
| 445 |
-
fi
|
| 446 |
fi
|
| 447 |
log_success "ComfyUI instalado em: $COMFY_DIR"
|
| 448 |
|
| 449 |
-
# [5]
|
| 450 |
log_info "[5/10] Instalando SageAttention..."
|
| 451 |
-
if
|
| 452 |
-
|
| 453 |
-
|
| 454 |
-
|
| 455 |
-
|
| 456 |
-
|
| 457 |
-
|
| 458 |
-
|
| 459 |
-
|
| 460 |
-
fi
|
| 461 |
else
|
| 462 |
-
|
| 463 |
fi
|
| 464 |
|
| 465 |
# [6] Baixar modelos principais
|
| 466 |
log_info "[6/10] Baixando modelos principais..."
|
| 467 |
mkdir -p "$MODELS_DIR"/{diffusion_models,loras,vae,vae_approx,text_encoders,clip_vision,controlnet,upscale_models,checkpoints}
|
| 468 |
-
|
| 469 |
-
# Verificar ferramentas de download
|
| 470 |
if command_exists aria2c; then
|
| 471 |
-
|
| 472 |
else
|
| 473 |
-
|
| 474 |
fi
|
| 475 |
-
|
| 476 |
-
# Processar downloads
|
| 477 |
if process_downloads; then
|
| 478 |
-
|
| 479 |
else
|
| 480 |
-
|
| 481 |
fi
|
| 482 |
|
| 483 |
-
# [7]
|
| 484 |
-
log_info "[7/10] Baixando modelos RIFE..."
|
| 485 |
-
RIFE_DIR="$MODELS_DIR/tensorrt/rife"
|
| 486 |
-
|
| 487 |
-
|
| 488 |
-
|
| 489 |
-
filename
|
| 490 |
-
|
| 491 |
-
log_success "RIFE modelo já existe: $filename"
|
| 492 |
else
|
| 493 |
-
|
| 494 |
-
|
| 495 |
fi
|
| 496 |
-
done
|
| 497 |
-
log_success "Modelos RIFE instalados"
|
| 498 |
-
|
| 499 |
-
# [8] Baixar modelos Mega.nz LoRAs
|
| 500 |
-
log_info "[8/10] Baixando LoRAs do Mega.nz..."
|
| 501 |
-
LORA_DIR="$MODELS_DIR/loras"
|
| 502 |
-
mkdir -p "$LORA_DIR"
|
| 503 |
-
|
| 504 |
-
if command_exists megadl; then
|
| 505 |
-
for mega_url in "${MEGA_LORAS[@]}"; do
|
| 506 |
-
log_info "Processando LoRA: $mega_url"
|
| 507 |
-
download_mega "$mega_url" "$LORA_DIR" || log_warn "Falha ao baixar: $mega_url"
|
| 508 |
-
done
|
| 509 |
-
log_success "LoRAs do Mega.nz concluídos"
|
| 510 |
-
|
| 511 |
-
# Baixar Upscale models do Mega.nz
|
| 512 |
-
log_info "Baixando Upscale models do Mega.nz..."
|
| 513 |
-
UPSCALE_DIR="$MODELS_DIR/upscale_models"
|
| 514 |
-
mkdir -p "$UPSCALE_DIR"
|
| 515 |
-
|
| 516 |
-
for mega_url in "${MEGA_UPSCALE[@]}"; do
|
| 517 |
-
log_info "Processando Upscale: $mega_url"
|
| 518 |
-
download_mega "$mega_url" "$UPSCALE_DIR" || log_warn "Falha ao baixar: $mega_url"
|
| 519 |
-
done
|
| 520 |
-
log_success "Upscale models do Mega.nz concluídos"
|
| 521 |
else
|
| 522 |
-
|
| 523 |
fi
|
| 524 |
|
| 525 |
-
# [
|
| 526 |
-
log_info "[
|
| 527 |
-
|
| 528 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 529 |
|
| 530 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 531 |
for repo_url in "${CUSTOM_NODES[@]}"; do
|
| 532 |
-
|
| 533 |
-
|
| 534 |
done
|
| 535 |
-
|
| 536 |
log_success "Custom nodes instalados"
|
| 537 |
|
| 538 |
# [10] Verificação final
|
| 539 |
echo ""
|
| 540 |
log_info "[10/10] Verificando instalação..."
|
| 541 |
-
|
| 542 |
-
# Verificar arquivos principais (ajustado para os modelos que você está baixando)
|
| 543 |
check_critical_files() {
|
| 544 |
-
|
| 545 |
-
|
| 546 |
-
|
| 547 |
-
|
| 548 |
-
|
| 549 |
-
|
| 550 |
-
|
| 551 |
-
|
| 552 |
-
|
| 553 |
-
|
| 554 |
-
|
| 555 |
-
|
| 556 |
-
|
| 557 |
-
|
| 558 |
-
|
| 559 |
-
|
| 560 |
-
|
| 561 |
-
|
| 562 |
-
|
| 563 |
-
|
| 564 |
-
|
| 565 |
-
|
| 566 |
-
|
| 567 |
-
|
| 568 |
-
|
| 569 |
-
|
| 570 |
-
fi
|
| 571 |
-
done
|
| 572 |
-
|
| 573 |
-
return 0
|
| 574 |
}
|
| 575 |
|
| 576 |
if check_critical_files; then
|
| 577 |
-
|
| 578 |
-
|
| 579 |
-
|
| 580 |
-
|
| 581 |
-
|
| 582 |
-
|
| 583 |
-
|
| 584 |
-
|
| 585 |
-
|
| 586 |
-
|
| 587 |
-
|
| 588 |
-
|
| 589 |
-
|
| 590 |
-
|
| 591 |
-
cd "$COMFY_DIR"
|
| 592 |
-
exec comfy launch -- $SAGE_FLAG --listen "$COMFY_HOST" --port "$COMFY_PORT"
|
| 593 |
else
|
| 594 |
-
|
| 595 |
-
|
| 596 |
-
|
| 597 |
-
|
| 598 |
-
exec comfy launch -- --listen "$COMFY_HOST" --port "$COMFY_PORT"
|
| 599 |
-
fi
|
|
|
|
| 13 |
BLUE='\033[0;34m'
|
| 14 |
NC='\033[0m'
|
| 15 |
|
| 16 |
+
log_info() { echo -e "${BLUE}[INFO]${NC} $1"; }
|
| 17 |
log_success() { echo -e "${GREEN}[✓]${NC} $1"; }
|
| 18 |
+
log_warn() { echo -e "${YELLOW}[!]${NC} $1"; }
|
| 19 |
+
log_error() { echo -e "${RED}[✗]${NC} $1"; }
|
| 20 |
|
| 21 |
# -----------------------------
|
| 22 |
# Configuração
|
|
|
|
| 25 |
MODELS_DIR="$COMFY_DIR/models"
|
| 26 |
COMFY_HOST="${COMFY_HOST:-0.0.0.0}"
|
| 27 |
COMFY_PORT="${COMFY_PORT:-8818}"
|
| 28 |
+
CIVITAI_TOKEN="${CIVITAI_TOKEN:-}" # NÃO deixe token hardcoded. Defina via env var.
|
| 29 |
+
HF_TOKEN="${HF_TOKEN:-}" # Token opcional do HuggingFace
|
| 30 |
|
| 31 |
# Configurações de performance
|
| 32 |
export MAX_JOBS=32
|
|
|
|
| 38 |
export EXT_PARALLEL=4
|
| 39 |
|
| 40 |
# -----------------------------
|
| 41 |
+
# Listas de download
|
| 42 |
# -----------------------------
|
|
|
|
| 43 |
readonly DOWNLOAD_FILES=(
|
| 44 |
+
# Wan 2.2 models
|
| 45 |
+
"hf://Kijai/WanVideo_comfy/Wan22-Lightning/Wan2.2-Lightning_T2V-v1.1-A14B-4steps-lora_HIGH_fp16.safetensors|loras|Wan2.2-Lightning_T2V-v1.1-A14B-4steps-lora_HIGH_fp16.safetensors"
|
| 46 |
+
"hf://Kijai/WanVideo_comfy/Wan22-Lightning/Wan2.2-Lightning_T2V-v1.1-A14B-4steps-lora_LOW_fp16.safetensors|loras|Wan2.2-Lightning_T2V-v1.1-A14B-4steps-lora_LOW_fp16.safetensors"
|
| 47 |
+
"hf://Kijai/WanVideo_comfy_fp8_scaled/I2V/Wan2_2-I2V-A14B-HIGH_fp8_e5m2_scaled_KJ.safetensors|diffusion_models|Wan2_2-I2V-A14B-HIGH_fp8_e5m2_scaled_KJ.safetensors"
|
| 48 |
+
"hf://Kijai/WanVideo_comfy_fp8_scaled/I2V/Wan2_2-I2V-A14B-LOW_fp8_e5m2_scaled_KJ.safetensors|diffusion_models|Wan2_2-I2V-A14B-LOW_fp8_e5m2_scaled_KJ.safetensors"
|
| 49 |
+
"hf://Kijai/WanVideo_comfy/Wan22-Lightning/Wan2.2-Lightning_I2V-A14B-4steps-lora_HIGH_fp16.safetensors|loras|Wan2.2-Lightning_I2V-A14B-4steps-lora_HIGH_fp16.safetensors"
|
| 50 |
+
"hf://Kijai/WanVideo_comfy/Wan22-Lightning/Wan2.2-Lightning_I2V-A14B-4steps-lora_LOW_fp16.safetensors|loras|Wan2.2-Lightning_I2V-A14B-4steps-lora_LOW_fp16.safetensors"
|
| 51 |
+
"hf://Kijai/WanVideo_comfy/Wan2_1_VAE_fp32.safetensors|vae|Wan2_1_VAE_fp32.safetensors"
|
| 52 |
+
"hf://Kijai/WanVideo_comfy/umt5-xxl-enc-bf16.safetensors|text_encoders|umt5-xxl-enc-bf16.safetensors"
|
| 53 |
+
# Wan 2.1 models
|
| 54 |
+
"hf://Kijai/WanVideo_comfy/Lightx2v/lightx2v_I2V_14B_480p_cfg_step_distill_rank256_bf16.safetensors|loras|lightx2v_I2V_14B_480p_cfg_step_distill_rank256_bf16.safetensors"
|
| 55 |
+
"hf://Comfy-Org/Wan_2.2_ComfyUI_Repackaged/split_files/vae/wan_2.1_vae.safetensors|vae|wan_2.1_vae.safetensors"
|
| 56 |
+
"hf://Comfy-Org/Wan_2.2_ComfyUI_Repackaged/split_files/text_encoders/umt5_xxl_fp16.safetensors|text_encoders|umt5_xxl_fp16.safetensors"
|
| 57 |
+
# Wan 2.1 clip vision
|
| 58 |
+
"hf://Kijai/WanVideo_comfy/open-clip-xlm-roberta-large-vit-huge-14_visual_fp32.safetensors|clip_vision|open-clip-xlm-roberta-large-vit-huge-14_visual_fp32.safetensors"
|
| 59 |
+
"hf://Comfy-Org/Wan_2.1_ComfyUI_repackaged/split_files/clip_vision/clip_vision_h.safetensors|clip_vision|clip_vision_h.safetensors"
|
| 60 |
+
# Upscaler extra
|
| 61 |
+
"https://huggingface.co/ABDALLALSWAITI/Upscalers/resolve/main/anime/2x-AnimeSharpV2_MoSR_Soft.pth|upscale_models|2x-AnimeSharpV2_MoSR_Soft.pth"
|
| 62 |
)
|
| 63 |
|
|
|
|
|
|
|
| 64 |
readonly MEGA_LORAS=(
|
| 65 |
+
"https://mega.nz/file/QFxREJpZ#0dge8TyRgb52lMFKdsk-Ac-rwcoG49hvBHvaqNsZkuk"
|
| 66 |
+
"https://mega.nz/file/lIhQETjT#nKlQ01Euw6fUxo8P5bfwlQrxAkWEedXQQOqHv5u4yrM"
|
| 67 |
+
"https://mega.nz/file/UIAESACY#Qlei1Pj5Nwno3Sz-wsTekvD-YgCkN1A5QbFKoRHXG9E"
|
| 68 |
+
"https://mega.nz/file/cdAg1Q7D#tQVrer2sB-M7XdYiKAqr7kRRfJw4pXCdliOg2aPJUGE"
|
| 69 |
+
"https://mega.nz/file/5RQFiAAJ#QCWrHkuJjXlFufR18g5R9YXJGqJ1pQp7xbqNRgSYUjc"
|
| 70 |
+
"https://mega.nz/file/tABgxLTS#NNlPV8NPc7R52MIjABMFUb41EOFDxFoszBxOrPMN13Q"
|
| 71 |
+
"https://mega.nz/file/4MxBgJ5Y#R8OSby0u-t-QFBnpnOtdjN3xuiVRvHa4_OEzTwWoGKQ"
|
| 72 |
+
"https://mega.nz/file/dJJxiSRR#o3XsYfSvb04xg7gNVdfHb3XTVHgvx0ZyXe9N8VQ9Lfw"
|
| 73 |
+
"https://mega.nz/file/wcAFhRJZ#ifZcckts0wPq1FG693tYLkpFrvjXvab1ZQeL6DuL1T8"
|
| 74 |
+
"https://mega.nz/file/wNIgmRwb#vn6rKM3QuTDpWVTLEBDsKjIkNkaX2wLKeauKNeVkcFs"
|
| 75 |
+
"https://mega.nz/file/hZhhhCQS#4je0Im2g1kEvTCuPotjVWkA-g6XICkqMb-mKxMt6R3Y"
|
| 76 |
)
|
| 77 |
|
|
|
|
| 78 |
readonly MEGA_UPSCALE=(
|
| 79 |
+
"https://mega.nz/file/qdQwAJSC#rPY2Hg4x-_RbHiHUBFW-YU8xZUqPpq5Gpl1uPFiJvW4"
|
| 80 |
+
"https://mega.nz/file/KIh2marA#CehVNXxQhGfp1bqUL0K1YPWNqrCUoLPCZGq2W6XqmWo"
|
| 81 |
)
|
| 82 |
|
| 83 |
+
# Declarado (vazio) para não quebrar com set -u; preencha se quiser baixar RIFE TensorRT
|
| 84 |
+
readonly RIFE_MODELS=()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 85 |
|
| 86 |
# -----------------------------
|
| 87 |
# Funções auxiliares
|
| 88 |
# -----------------------------
|
| 89 |
+
command_exists() { command -v "$1" >/dev/null 2>&1; }
|
| 90 |
+
|
| 91 |
+
# APT helpers com tolerância a falhas
|
| 92 |
+
apt_update_safe() {
|
| 93 |
+
if command_exists apt-get; then
|
| 94 |
+
export DEBIAN_FRONTEND=noninteractive
|
| 95 |
+
apt-get update -y || { log_warn "apt-get update falhou; tentando continuar mesmo assim."; return 0; }
|
| 96 |
+
else
|
| 97 |
+
log_warn "apt-get não disponível; pulando update."
|
| 98 |
+
fi
|
| 99 |
+
}
|
| 100 |
+
|
| 101 |
+
apt_install_safe() {
|
| 102 |
+
# uso: apt_install_safe pkg1 pkg2 ...
|
| 103 |
+
if command_exists apt-get; then
|
| 104 |
+
export DEBIAN_FRONTEND=noninteractive
|
| 105 |
+
apt-get install -y "$@" || log_warn "Falha ao instalar: $* (continuando)."
|
| 106 |
+
else
|
| 107 |
+
log_warn "apt-get não disponível; não foi possível instalar: $*"
|
| 108 |
+
fi
|
| 109 |
}
|
| 110 |
|
| 111 |
+
# Adicionar token do Civitai se necessário (usa ? ou & corretamente)
|
| 112 |
add_civitai_token() {
|
| 113 |
+
local url="$1"
|
| 114 |
+
if [[ "$url" == *"civitai.com/api/download"* ]] && [[ "$url" != *"token="* ]] && [[ -n "$CIVITAI_TOKEN" ]]; then
|
| 115 |
+
if [[ "$url" == *"?"* ]]; then
|
| 116 |
+
echo "${url}&token=${CIVITAI_TOKEN}"
|
| 117 |
else
|
| 118 |
+
echo "${url}?token=${CIVITAI_TOKEN}"
|
| 119 |
fi
|
| 120 |
+
else
|
| 121 |
+
echo "$url"
|
| 122 |
+
fi
|
| 123 |
}
|
| 124 |
|
| 125 |
+
# Download HuggingFace com hf/huggingface-cli + hf_transfer
|
| 126 |
download_hf() {
|
| 127 |
+
local repo="$1"; local file_path="$2"; local target_dir="$3"; local filename="$4"
|
| 128 |
+
if [ -z "$filename" ]; then filename=$(basename "$file_path"); fi
|
| 129 |
+
local target_file="$target_dir/$filename"
|
| 130 |
+
|
| 131 |
+
if [ -f "$target_file" ] && [ "$(stat -c%s "$target_file" 2>/dev/null || echo 0)" -gt 1000000 ]; then
|
| 132 |
+
log_success "Arquivo já existe: $filename"; return 0
|
| 133 |
+
fi
|
| 134 |
+
|
| 135 |
+
log_info "Baixando de HF: $filename"
|
| 136 |
+
local temp_dir; temp_dir="$(mktemp -d)"
|
| 137 |
+
local download_success=false
|
| 138 |
+
|
| 139 |
+
if command_exists hf; then
|
| 140 |
+
HF_HUB_ENABLE_HF_TRANSFER=1 hf download "$repo" "$file_path" \
|
| 141 |
+
--local-dir "$temp_dir" --local-dir-use-symlinks False && download_success=true || true
|
| 142 |
+
fi
|
| 143 |
+
if [ "$download_success" = false ] && command_exists huggingface-cli; then
|
| 144 |
+
log_warn "Tentando com huggingface-cli..."
|
| 145 |
+
HF_HUB_ENABLE_HF_TRANSFER=1 huggingface-cli download "$repo" "$file_path" \
|
| 146 |
+
--local-dir "$temp_dir" --local-dir-use-symlinks False && download_success=true || true
|
| 147 |
+
fi
|
| 148 |
+
|
| 149 |
+
if [ "$download_success" = true ]; then
|
| 150 |
+
local downloaded_file
|
| 151 |
+
downloaded_file="$(find "$temp_dir" -type f \( -name "*.safetensors" -o -name "*.pth" -o -name "*.pt" -o -name "*.bin" \) | head -1)"
|
| 152 |
+
if [ -n "$downloaded_file" ]; then
|
| 153 |
+
mv "$downloaded_file" "$target_file"
|
| 154 |
+
rm -rf "$temp_dir"
|
| 155 |
+
log_success "Download concluído: $filename"
|
| 156 |
+
return 0
|
| 157 |
+
else
|
| 158 |
+
log_error "Arquivo baixado mas não encontrado em $temp_dir"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 159 |
fi
|
| 160 |
+
fi
|
| 161 |
+
|
| 162 |
+
rm -rf "$temp_dir"
|
| 163 |
+
log_error "Falha ao baixar: $filename"
|
| 164 |
+
return 1
|
| 165 |
}
|
| 166 |
|
| 167 |
# Download genérico com aria2c, wget ou curl
|
| 168 |
download_file() {
|
| 169 |
+
local url="$1"; local target_dir="$2"; local filename="$3"
|
| 170 |
+
url=$(add_civitai_token "$url")
|
| 171 |
+
|
| 172 |
+
if [ -n "$filename" ] && [ -f "$target_dir/$filename" ] && [ "$(stat -c%s "$target_dir/$filename" 2>/dev/null || echo 0)" -gt 1000000 ]; then
|
| 173 |
+
log_success "Arquivo já existe: $filename"; return 0
|
| 174 |
+
fi
|
| 175 |
+
|
| 176 |
+
log_info "Baixando: ${filename:-$(basename "$url" | cut -d'?' -f1)}"
|
| 177 |
+
|
| 178 |
+
if command_exists aria2c; then
|
| 179 |
+
local aria_opts="-c -s 16 -x 16 -k 1M --console-log-level=warn --summary-interval=10"
|
| 180 |
+
if [ -n "$filename" ]; then aria2c $aria_opts --dir="$target_dir" --out="$filename" "$url" && return 0 || true
|
| 181 |
+
else aria2c $aria_opts --dir="$target_dir" "$url" && return 0 || true
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 182 |
fi
|
| 183 |
+
fi
|
| 184 |
+
if command_exists wget; then
|
| 185 |
+
if [ -n "$filename" ]; then wget -q --show-progress -c -O "$target_dir/$filename" "$url" && return 0 || true
|
| 186 |
+
else wget -q --show-progress -c --content-disposition -P "$target_dir" "$url" && return 0 || true
|
|
|
|
|
|
|
|
|
|
|
|
|
| 187 |
fi
|
| 188 |
+
fi
|
| 189 |
+
if command_exists curl; then
|
| 190 |
+
if [ -n "$filename" ]; then
|
| 191 |
+
curl -L -# -C - -o "$target_dir/$filename" "$url" && return 0 || true
|
| 192 |
+
else
|
| 193 |
+
local headers detected_name
|
| 194 |
+
headers="$(curl -sI -L "$url")"
|
| 195 |
+
detected_name="$(echo "$headers" | grep -i "content-disposition" | sed -n 's/.*filename="\([^"]*\)".*/\1/p' | tr -d '\r')"
|
| 196 |
+
[ -z "$detected_name" ] && detected_name="downloaded_$(date +%s).bin"
|
| 197 |
+
curl -L -# -C - -o "$target_dir/$detected_name" "$url" && return 0 || true
|
|
|
|
|
|
|
|
|
|
| 198 |
fi
|
| 199 |
+
fi
|
| 200 |
+
|
| 201 |
+
log_error "Falha ao baixar: $url"
|
| 202 |
+
return 1
|
| 203 |
}
|
| 204 |
|
| 205 |
+
# Download de Mega.nz usando megatools (megadl)
|
| 206 |
download_mega() {
|
| 207 |
+
local url="$1"; local target_dir="$2"
|
| 208 |
+
if ! command_exists megadl; then
|
| 209 |
+
log_warn "megadl não está instalado. Tentando instalar megatools..."
|
| 210 |
+
apt_update_safe
|
| 211 |
+
apt_install_safe megatools
|
| 212 |
+
fi
|
| 213 |
+
if ! command_exists megadl; then
|
| 214 |
+
log_warn "megadl indisponível. Pulando download de Mega.nz: $url"
|
| 215 |
+
return 1
|
| 216 |
+
fi
|
|
|
|
|
|
|
|
|
|
| 217 |
|
| 218 |
+
log_info "Baixando de Mega.nz: $url"
|
| 219 |
+
( cd "$target_dir" && megadl "$url" ) && { log_success "Download Mega.nz concluído"; return 0; } || {
|
| 220 |
+
log_warn "Falha ao baixar de Mega.nz: $url"; return 1;
|
| 221 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 222 |
}
|
| 223 |
|
| 224 |
# Processar lista de downloads
|
| 225 |
process_downloads() {
|
| 226 |
+
local failed_count=0
|
| 227 |
+
for entry in "${DOWNLOAD_FILES[@]}"; do
|
| 228 |
+
IFS='|' read -r url type filename <<< "$entry"
|
| 229 |
+
url="$(echo "$url" | xargs)"; type="$(echo "$type" | xargs)"; filename="$(echo "$filename" | xargs)"
|
| 230 |
+
|
| 231 |
+
local target_dir="$MODELS_DIR/$type"
|
| 232 |
+
case "$type" in
|
| 233 |
+
checkpoints|diffusion_models|loras|vae|vae_approx|text_encoders|clip_vision|controlnet|upscale_models|tensorrt|tensorrt_rife) ;;
|
| 234 |
+
*) target_dir="$MODELS_DIR/$type" ;;
|
| 235 |
+
esac
|
| 236 |
+
mkdir -p "$target_dir"
|
| 237 |
+
|
| 238 |
+
if [[ "$url" == hf://* ]]; then
|
| 239 |
+
url="${url#hf://}"
|
| 240 |
+
local repo="$(echo "$url" | cut -d'/' -f1-2)"
|
| 241 |
+
local file_path="$(echo "$url" | cut -d'/' -f3-)"
|
| 242 |
+
download_hf "$repo" "$file_path" "$target_dir" "$filename" || ((failed_count++))
|
| 243 |
+
else
|
| 244 |
+
download_file "$url" "$target_dir" "$filename" || ((failed_count++))
|
| 245 |
+
fi
|
| 246 |
+
done
|
| 247 |
+
return $failed_count
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 248 |
}
|
| 249 |
|
| 250 |
# Clonar ou atualizar repositório git
|
| 251 |
clone_or_update() {
|
| 252 |
+
local url="$1"; local dest="$2"; local node_name
|
| 253 |
+
node_name="$(basename "$dest")"
|
| 254 |
+
|
| 255 |
+
if [ -d "$dest/.git" ]; then
|
| 256 |
+
log_info "Atualizando $node_name..."
|
| 257 |
+
timeout 60 git -C "$dest" pull --ff-only || log_warn "Timeout/erro ao atualizar $node_name"
|
| 258 |
+
else
|
| 259 |
+
log_info "Clonando $node_name..."
|
| 260 |
+
timeout 60 git clone --recursive --depth 1 "$url" "$dest" || log_warn "Falha ao clonar $node_name"
|
| 261 |
+
fi
|
| 262 |
+
|
| 263 |
+
if [ -f "$dest/requirements.txt" ]; then
|
| 264 |
+
timeout 180 python3 -m pip install --no-warn-script-location -q -r "$dest/requirements.txt" || log_warn "Falha ao instalar requirements para $node_name"
|
| 265 |
+
fi
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 266 |
}
|
| 267 |
|
| 268 |
# -----------------------------
|
|
|
|
| 270 |
# -----------------------------
|
| 271 |
echo ""
|
| 272 |
log_info "========================================="
|
| 273 |
+
log_info " ComfyUI + Wan 2.2 Setup (Fixed v3)"
|
| 274 |
log_info "========================================="
|
| 275 |
echo ""
|
| 276 |
|
| 277 |
# [1] Verificar e instalar dependências
|
| 278 |
log_info "[1/10] Verificando e instalando dependências..."
|
| 279 |
|
|
|
|
| 280 |
if ! command_exists aria2c || ! command_exists megadl; then
|
| 281 |
+
log_info "Instalando ferramentas de download..."
|
| 282 |
+
apt_update_safe
|
| 283 |
+
command_exists aria2c || apt_install_safe aria2
|
| 284 |
+
command_exists megadl || apt_install_safe megatools
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 285 |
fi
|
| 286 |
|
| 287 |
for cmd in python3 git wget curl; do
|
| 288 |
+
if ! command_exists "$cmd"; then
|
| 289 |
+
log_error "Dependência faltando: $cmd"
|
| 290 |
+
exit 1
|
| 291 |
+
fi
|
| 292 |
done
|
| 293 |
log_success "Dependências OK"
|
| 294 |
|
| 295 |
# [2] Atualizar pip e instalar ferramentas
|
| 296 |
log_info "[2/10] Preparando ferramentas Python..."
|
| 297 |
python3 -m pip install --upgrade pip wheel setuptools -q
|
|
|
|
|
|
|
| 298 |
python3 -m pip install --upgrade "huggingface_hub[cli,hf_transfer]>=0.26.0" comfy-cli -q
|
| 299 |
|
|
|
|
|
|
|
| 300 |
if [ -n "$HF_TOKEN" ]; then
|
| 301 |
+
if command_exists huggingface-cli; then
|
| 302 |
+
huggingface-cli login --token "$HF_TOKEN" --add-to-git-credential || log_warn "Falha no login HF (seguindo sem auth)"
|
| 303 |
+
fi
|
|
|
|
|
|
|
| 304 |
fi
|
| 305 |
|
|
|
|
| 306 |
if command_exists hf; then
|
| 307 |
+
log_success "Comando 'hf' disponível (recomendado)"
|
| 308 |
elif command_exists huggingface-cli; then
|
| 309 |
+
log_warn "Usando 'huggingface-cli' (funcional)"
|
| 310 |
else
|
| 311 |
+
log_warn "Nenhum comando HF disponível — downloads HF podem falhar."
|
| 312 |
fi
|
|
|
|
| 313 |
log_success "Ferramentas instaladas"
|
| 314 |
|
| 315 |
+
# [3] PyTorch CUDA 12.8
|
| 316 |
log_info "[3/10] Instalando PyTorch com CUDA 12.8..."
|
| 317 |
python3 -m pip install --upgrade torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu128
|
| 318 |
log_success "PyTorch com CUDA 12.8 instalado"
|
|
|
|
| 320 |
# [4] Instalar ComfyUI
|
| 321 |
log_info "[4/10] Instalando ComfyUI..."
|
| 322 |
if [ -f "$COMFY_DIR/main.py" ]; then
|
| 323 |
+
log_warn "ComfyUI já existe, pulando instalação base"
|
| 324 |
else
|
| 325 |
+
comfy --skip-prompt install --fast-deps --nvidia
|
| 326 |
+
if [ ! -f "$COMFY_DIR/main.py" ]; then
|
| 327 |
+
log_error "ComfyUI não foi instalado corretamente!"
|
| 328 |
+
exit 1
|
| 329 |
+
fi
|
|
|
|
|
|
|
| 330 |
fi
|
| 331 |
log_success "ComfyUI instalado em: $COMFY_DIR"
|
| 332 |
|
| 333 |
+
# [5] SageAttention (wheel pré-compilada)
|
| 334 |
log_info "[5/10] Instalando SageAttention..."
|
| 335 |
+
if python3 - <<'PY' 2>/dev/null | grep -q True; then
|
| 336 |
+
import torch; print(torch.cuda.is_available())
|
| 337 |
+
PY
|
| 338 |
+
then
|
| 339 |
+
python3 -m pip install "https://huggingface.co/adbrasi/comfywheel/resolve/main/sageattention-2.2.0-cp311-cp311-linux_x86_64.whl" -q || log_warn "Falha ao instalar SageAttention"
|
| 340 |
+
python3 - <<'PY' >/dev/null 2>&1 || log_warn "SageAttention não pôde ser importado (seguindo sem)"
|
| 341 |
+
import sageattention
|
| 342 |
+
PY
|
| 343 |
+
log_success "SageAttention etapa concluída"
|
|
|
|
| 344 |
else
|
| 345 |
+
log_warn "CUDA não detectado, pulando SageAttention"
|
| 346 |
fi
|
| 347 |
|
| 348 |
# [6] Baixar modelos principais
|
| 349 |
log_info "[6/10] Baixando modelos principais..."
|
| 350 |
mkdir -p "$MODELS_DIR"/{diffusion_models,loras,vae,vae_approx,text_encoders,clip_vision,controlnet,upscale_models,checkpoints}
|
|
|
|
|
|
|
| 351 |
if command_exists aria2c; then
|
| 352 |
+
log_success "Usando aria2c para downloads (rápido)"
|
| 353 |
else
|
| 354 |
+
log_warn "aria2c não encontrado, usando wget/curl (mais lento)"
|
| 355 |
fi
|
|
|
|
|
|
|
| 356 |
if process_downloads; then
|
| 357 |
+
log_success "Todos os modelos baixados (ou já presentes)"
|
| 358 |
else
|
| 359 |
+
log_warn "Alguns downloads falharam; você pode reexecutar depois."
|
| 360 |
fi
|
| 361 |
|
| 362 |
+
# [7] Modelos RIFE (opcional)
|
| 363 |
+
log_info "[7/10] Baixando modelos RIFE (opcional)..."
|
| 364 |
+
RIFE_DIR="$MODELS_DIR/tensorrt/rife"; mkdir -p "$RIFE_DIR"
|
| 365 |
+
if [ ${#RIFE_MODELS[@]} -gt 0 ]; then
|
| 366 |
+
for url in "${RIFE_MODELS[@]}"; do
|
| 367 |
+
filename="$(basename "$url")"
|
| 368 |
+
if [ -f "$RIFE_DIR/$filename" ] && [ "$(stat -c%s "$RIFE_DIR/$filename" 2>/dev/null || echo 0)" -gt 100000 ]; then
|
| 369 |
+
log_success "RIFE já existe: $filename"
|
|
|
|
| 370 |
else
|
| 371 |
+
log_info "Baixando RIFE: $filename"
|
| 372 |
+
download_file "$url" "$RIFE_DIR" "$filename" || log_warn "Falha ao baixar RIFE: $filename"
|
| 373 |
fi
|
| 374 |
+
done
|
| 375 |
+
log_success "Modelos RIFE instalados"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 376 |
else
|
| 377 |
+
log_warn "RIFE_MODELS vazio — pulando etapa (ok)."
|
| 378 |
fi
|
| 379 |
|
| 380 |
+
# [8] Mega.nz LoRAs e Upscale
|
| 381 |
+
log_info "[8/10] Baixando LoRAs/UpScales do Mega.nz..."
|
| 382 |
+
LORA_DIR="$MODELS_DIR/loras"; mkdir -p "$LORA_DIR"
|
| 383 |
+
for mega_url in "${MEGA_LORAS[@]}"; do
|
| 384 |
+
download_mega "$mega_url" "$LORA_DIR" || log_warn "Falha ao baixar: $mega_url"
|
| 385 |
+
done
|
| 386 |
+
UPSCALE_DIR="$MODELS_DIR/upscale_models"; mkdir -p "$UPSCALE_DIR"
|
| 387 |
+
for mega_url in "${MEGA_UPSCALE[@]}"; do
|
| 388 |
+
download_mega "$mega_url" "$UPSCALE_DIR" || log_warn "Falha ao baixar: $mega_url"
|
| 389 |
+
done
|
| 390 |
+
log_success "Downloads do Mega.nz concluídos (quando possível)."
|
| 391 |
|
| 392 |
+
# [9] Custom nodes
|
| 393 |
+
log_info "[9/10] Instalando custom nodes..."
|
| 394 |
+
CN_DIR="$COMFY_DIR/custom_nodes"; mkdir -p "$CN_DIR"
|
| 395 |
+
readonly CUSTOM_NODES=(
|
| 396 |
+
"https://github.com/kijai/ComfyUI-Florence2"
|
| 397 |
+
"https://github.com/adbrasi/groqrouter"
|
| 398 |
+
"https://github.com/kijai/ComfyUI-WanVideoWrapper"
|
| 399 |
+
"https://github.com/Fannovel16/ComfyUI-Frame-Interpolation"
|
| 400 |
+
"https://github.com/kijai/ComfyUI-GIMM-VFI"
|
| 401 |
+
"https://github.com/Kosinkadink/ComfyUI-VideoHelperSuite"
|
| 402 |
+
"https://github.com/kijai/ComfyUI-KJNodes"
|
| 403 |
+
"https://github.com/Fannovel16/comfyui_controlnet_aux"
|
| 404 |
+
"https://github.com/Artificial-Sweetener/comfyui-WhiteRabbit"
|
| 405 |
+
"https://github.com/shiimizu/ComfyUI_smZNodes"
|
| 406 |
+
"https://github.com/CoreyCorza/ComfyUI-CRZnodes"
|
| 407 |
+
"https://github.com/pythongosssss/ComfyUI-Custom-Scripts"
|
| 408 |
+
"https://github.com/pythongosssss/ComfyUI-WD14-Tagger"
|
| 409 |
+
"https://github.com/WASasquatch/was-node-suite-comfyui"
|
| 410 |
+
"https://github.com/justUmen/Bjornulf_custom_nodes"
|
| 411 |
+
"https://github.com/mingsky-ai/ComfyUI-MingNodes"
|
| 412 |
+
"https://github.com/numz/ComfyUI-SeedVR2_VideoUpscaler"
|
| 413 |
+
"https://github.com/1038lab/ComfyUI-RMBG"
|
| 414 |
+
"https://github.com/wallish77/wlsh_nodes"
|
| 415 |
+
"https://github.com/yuvraj108c/ComfyUI-Upscaler-Tensorrt"
|
| 416 |
+
"https://github.com/raindrop313/ComfyUI-WanVideoStartEndFrames"
|
| 417 |
+
"https://github.com/MushroomFleet/DJZ-Nodes"
|
| 418 |
+
"https://github.com/Suzie1/ComfyUI_Comfyroll_CustomNodes"
|
| 419 |
+
"https://github.com/grmchn/ComfyUI-ProportionChanger"
|
| 420 |
+
)
|
| 421 |
for repo_url in "${CUSTOM_NODES[@]}"; do
|
| 422 |
+
node_name="$(basename "$repo_url")"
|
| 423 |
+
clone_or_update "$repo_url" "$CN_DIR/$node_name"
|
| 424 |
done
|
|
|
|
| 425 |
log_success "Custom nodes instalados"
|
| 426 |
|
| 427 |
# [10] Verificação final
|
| 428 |
echo ""
|
| 429 |
log_info "[10/10] Verificando instalação..."
|
|
|
|
|
|
|
| 430 |
check_critical_files() {
|
| 431 |
+
local files=(
|
| 432 |
+
"$COMFY_DIR/main.py"
|
| 433 |
+
"$MODELS_DIR/vae/wan_2.1_vae.safetensors"
|
| 434 |
+
"$MODELS_DIR/vae/Wan2_1_VAE_fp32.safetensors"
|
| 435 |
+
"$MODELS_DIR/text_encoders/umt5_xxl_fp16.safetensors"
|
| 436 |
+
"$MODELS_DIR/text_encoders/umt5-xxl-enc-bf16.safetensors"
|
| 437 |
+
"$MODELS_DIR/clip_vision/clip_vision_h.safetensors"
|
| 438 |
+
)
|
| 439 |
+
for file in "${files[@]}"; do
|
| 440 |
+
if [ -f "$file" ]; then
|
| 441 |
+
log_success "✓ $(basename "$file")"
|
| 442 |
+
else
|
| 443 |
+
log_warn "✗ $(basename "$file") não encontrado (pode ser opcional)"
|
| 444 |
+
fi
|
| 445 |
+
done
|
| 446 |
+
|
| 447 |
+
echo ""
|
| 448 |
+
log_info "Modelos disponíveis:"
|
| 449 |
+
for dir in diffusion_models loras vae vae_approx text_encoders clip_vision controlnet upscale_models checkpoints; do
|
| 450 |
+
if [ -d "$MODELS_DIR/$dir" ]; then
|
| 451 |
+
local count
|
| 452 |
+
count=$(find "$MODELS_DIR/$dir" -type f \( -name "*.safetensors" -o -name "*.pth" -o -name "*.pt" -o -name "*.bin" \) 2>/dev/null | wc -l)
|
| 453 |
+
if [ "$count" -gt 0 ]; then log_success " $dir: $count arquivo(s)"; fi
|
| 454 |
+
fi
|
| 455 |
+
done
|
| 456 |
+
return 0
|
|
|
|
|
|
|
|
|
|
|
|
|
| 457 |
}
|
| 458 |
|
| 459 |
if check_critical_files; then
|
| 460 |
+
log_success "Instalação concluída com sucesso!"
|
| 461 |
+
echo ""
|
| 462 |
+
log_info "========================================="
|
| 463 |
+
log_info "Iniciando ComfyUI..."
|
| 464 |
+
log_info "URL: http://localhost:$COMFY_PORT"
|
| 465 |
+
log_info "========================================="
|
| 466 |
+
|
| 467 |
+
SAGE_FLAG=""
|
| 468 |
+
python3 - <<'PY' >/dev/null 2>&1 && SAGE_FLAG="--use-sage-attention" || true
|
| 469 |
+
import sageattention
|
| 470 |
+
PY
|
| 471 |
+
|
| 472 |
+
cd "$COMFY_DIR"
|
| 473 |
+
exec comfy launch -- ${SAGE_FLAG:+$SAGE_FLAG} --listen "$COMFY_HOST" --port "$COMFY_PORT"
|
|
|
|
|
|
|
| 474 |
else
|
| 475 |
+
log_warn "Alguns arquivos não foram encontrados; iniciando ComfyUI mesmo assim..."
|
| 476 |
+
cd "$COMFY_DIR"
|
| 477 |
+
exec comfy launch -- --listen "$COMFY_HOST" --port "$COMFY_PORT"
|
| 478 |
+
fi
|
|
|
|
|
|