Update setup_comfyui_wan22.sh
Browse files- setup_comfyui_wan22.sh +146 -101
setup_comfyui_wan22.sh
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
#!/usr/bin/env bash
|
| 2 |
-
#
|
| 3 |
-
# Script
|
| 4 |
|
| 5 |
set -euo pipefail
|
| 6 |
|
|
@@ -26,8 +26,9 @@ 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:-4fcb2834969399006a736ee402b061e5}"
|
|
|
|
| 29 |
|
| 30 |
-
# Configurações de performance
|
| 31 |
export MAX_JOBS=32
|
| 32 |
export NVCC_APPEND_FLAGS="--threads 8"
|
| 33 |
export UV_SYSTEM_PYTHON=1
|
|
@@ -40,40 +41,38 @@ export EXT_PARALLEL=4
|
|
| 40 |
# Lista de downloads
|
| 41 |
# -----------------------------
|
| 42 |
# Formato: "URL|TIPO|NOME_ARQUIVO_OPCIONAL"
|
| 43 |
-
# TIPO pode ser: checkpoints, loras, vae, text_encoders, clip_vision, controlnet, upscale_models
|
| 44 |
readonly DOWNLOAD_FILES=(
|
| 45 |
# Wan 2.2 models
|
| 46 |
-
"hf://Comfy-Org/Wan_2.2_ComfyUI_Repackaged/split_files/diffusion_models/wan2.2_fun_control_low_noise_14B_fp8_scaled.safetensors|
|
| 47 |
-
"hf://Comfy-Org/Wan_2.2_ComfyUI_Repackaged/split_files/diffusion_models/wan2.2_fun_control_high_noise_14B_fp8_scaled.safetensors|
|
| 48 |
-
"hf://Comfy-Org/Wan_2.2_ComfyUI_Repackaged/split_files/loras/wan2.2_i2v_lightx2v_4steps_lora_v1_high_noise.safetensors|loras|"
|
| 49 |
-
"hf://Comfy-Org/Wan_2.2_ComfyUI_Repackaged/split_files/loras/wan2.2_i2v_lightx2v_4steps_lora_v1_low_noise.safetensors|loras|"
|
| 50 |
-
"hf://Comfy-Org/Wan_2.2_ComfyUI_Repackaged/split_files/vae/wan_2.1_vae.safetensors|vae|"
|
| 51 |
-
"hf://Comfy-Org/Wan_2.2_ComfyUI_Repackaged/split_files/text_encoders/umt5_xxl_fp16.safetensors|text_encoders|"
|
| 52 |
-
|
| 53 |
# Wan 2.1 clip vision
|
| 54 |
-
"hf://Comfy-Org/Wan_2.1_ComfyUI_repackaged/split_files/clip_vision/clip_vision_h.safetensors|clip_vision|"
|
| 55 |
-
|
| 56 |
# ControlNet
|
| 57 |
"hf://xinsir/controlnet-union-sdxl-1.0/diffusion_pytorch_model_promax.safetensors|controlnet|controlnet-union.safetensors"
|
| 58 |
-
|
| 59 |
# Civitai model
|
| 60 |
-
"https://civitai.com/api/download/models/2122278?type=Model&format=SafeTensor&size=pruned&fp=fp16|
|
| 61 |
)
|
| 62 |
|
| 63 |
# Custom nodes para instalar
|
| 64 |
readonly CUSTOM_NODES=(
|
| 65 |
-
"https://github.com/kijai/ComfyUI-Florence2"
|
| 66 |
-
"https://github.com/kijai/ComfyUI-WanVideoWrapper"
|
| 67 |
-
"https://github.com/Fannovel16/ComfyUI-Frame-Interpolation"
|
| 68 |
-
"https://github.com/kijai/ComfyUI-GIMM-VFI"
|
| 69 |
-
"https://github.com/Kosinkadink/ComfyUI-VideoHelperSuite"
|
| 70 |
-
"https://github.com/kijai/ComfyUI-KJNodes"
|
| 71 |
-
"https://github.com/Fannovel16/comfyui_controlnet_aux"
|
| 72 |
-
"https://github.com/Artificial-Sweetener/comfyui-WhiteRabbit"
|
| 73 |
-
"https://github.com/
|
| 74 |
-
"https://github.com/
|
| 75 |
-
"https://github.com/yuvraj108c/ComfyUI-Dwpose-Tensorrt"
|
| 76 |
-
"https://github.com/
|
|
|
|
| 77 |
)
|
| 78 |
|
| 79 |
# -----------------------------
|
|
@@ -93,7 +92,7 @@ add_civitai_token() {
|
|
| 93 |
fi
|
| 94 |
}
|
| 95 |
|
| 96 |
-
# Download HuggingFace usando
|
| 97 |
download_hf() {
|
| 98 |
local repo="$1"
|
| 99 |
local file_path="$2"
|
|
@@ -115,32 +114,28 @@ download_hf() {
|
|
| 115 |
|
| 116 |
log_info "Baixando de HF: $filename"
|
| 117 |
|
| 118 |
-
#
|
| 119 |
-
if
|
| 120 |
-
HF_HUB_ENABLE_HF_TRANSFER=1 huggingface-cli download "$repo" "$file_path" \
|
| 121 |
-
--local-dir "$target_dir" \
|
| 122 |
-
--local-dir-use-symlinks False \
|
| 123 |
-
--resume-download 2>/dev/null && {
|
| 124 |
-
# Renomear se necessário
|
| 125 |
-
if [ "$filename" != "$(basename "$file_path")" ]; then
|
| 126 |
-
mv "$target_dir/$file_path" "$target_file" 2>/dev/null || true
|
| 127 |
-
fi
|
| 128 |
-
return 0
|
| 129 |
-
}
|
| 130 |
-
fi
|
| 131 |
-
|
| 132 |
-
# Fallback para método padrão
|
| 133 |
-
huggingface-cli download "$repo" "$file_path" \
|
| 134 |
--local-dir "$target_dir" \
|
| 135 |
--local-dir-use-symlinks False \
|
| 136 |
-
--resume-download
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
|
|
|
|
|
|
| 140 |
fi
|
| 141 |
-
|
| 142 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 143 |
|
|
|
|
| 144 |
return 1
|
| 145 |
}
|
| 146 |
|
|
@@ -185,14 +180,11 @@ download_file() {
|
|
| 185 |
if [ -n "$filename" ]; then
|
| 186 |
curl -L -# -C - -o "$target_dir/$filename" "$url" && return 0
|
| 187 |
else
|
| 188 |
-
# Tentar obter nome do arquivo do header
|
| 189 |
local headers=$(curl -sI -L "$url")
|
| 190 |
local detected_name=$(echo "$headers" | grep -i "content-disposition" | sed -n 's/.*filename="\([^"]*\)".*/\1/p' | tr -d '\r')
|
| 191 |
-
|
| 192 |
if [ -z "$detected_name" ]; then
|
| 193 |
detected_name="downloaded_$(date +%s).safetensors"
|
| 194 |
fi
|
| 195 |
-
|
| 196 |
curl -L -# -C - -o "$target_dir/$detected_name" "$url" && return 0
|
| 197 |
fi
|
| 198 |
fi
|
|
@@ -216,7 +208,7 @@ process_downloads() {
|
|
| 216 |
# Determinar diretório de destino
|
| 217 |
local target_dir="$MODELS_DIR"
|
| 218 |
case "$type" in
|
| 219 |
-
checkpoints) target_dir="$MODELS_DIR/
|
| 220 |
loras) target_dir="$MODELS_DIR/loras" ;;
|
| 221 |
vae) target_dir="$MODELS_DIR/vae" ;;
|
| 222 |
text_encoders) target_dir="$MODELS_DIR/text_encoders" ;;
|
|
@@ -233,8 +225,6 @@ process_downloads() {
|
|
| 233 |
if [[ "$url" == hf://* ]]; then
|
| 234 |
# HuggingFace download
|
| 235 |
url="${url#hf://}" # Remove prefixo hf://
|
| 236 |
-
|
| 237 |
-
# Separar repo e caminho
|
| 238 |
repo=$(echo "$url" | cut -d'/' -f1-2)
|
| 239 |
file_path=$(echo "$url" | cut -d'/' -f3-)
|
| 240 |
|
|
@@ -245,6 +235,20 @@ process_downloads() {
|
|
| 245 |
fi
|
| 246 |
done
|
| 247 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 248 |
return $failed_count
|
| 249 |
}
|
| 250 |
|
|
@@ -252,19 +256,31 @@ process_downloads() {
|
|
| 252 |
clone_or_update() {
|
| 253 |
local url="$1"
|
| 254 |
local dest="$2"
|
|
|
|
| 255 |
|
|
|
|
| 256 |
if [ -d "$dest/.git" ]; then
|
| 257 |
-
log_info "Atualizando $
|
| 258 |
-
git -C "$dest" pull --ff-only 2>/dev/null ||
|
|
|
|
|
|
|
|
|
|
| 259 |
else
|
| 260 |
-
log_info "Clonando $
|
| 261 |
-
git clone --recursive --depth 1 "$url" "$dest" 2>/dev/null ||
|
|
|
|
|
|
|
|
|
|
| 262 |
fi
|
| 263 |
|
| 264 |
-
# Instalar requirements se existir
|
| 265 |
if [ -f "$dest/requirements.txt" ]; then
|
| 266 |
-
python3 -m pip install --no-warn-script-location -q -r "$dest/requirements.txt" 2>/dev/null ||
|
|
|
|
|
|
|
| 267 |
fi
|
|
|
|
|
|
|
| 268 |
}
|
| 269 |
|
| 270 |
# -----------------------------
|
|
@@ -272,12 +288,19 @@ clone_or_update() {
|
|
| 272 |
# -----------------------------
|
| 273 |
echo ""
|
| 274 |
log_info "========================================="
|
| 275 |
-
log_info "
|
| 276 |
log_info "========================================="
|
| 277 |
echo ""
|
| 278 |
|
| 279 |
-
# [1] Verificar dependências
|
| 280 |
-
log_info "[1/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 281 |
for cmd in python3 git wget curl; do
|
| 282 |
if ! command_exists "$cmd"; then
|
| 283 |
log_error "Dependência faltando: $cmd"
|
|
@@ -287,13 +310,38 @@ done
|
|
| 287 |
log_success "Dependências OK"
|
| 288 |
|
| 289 |
# [2] Atualizar pip e instalar ferramentas
|
| 290 |
-
log_info "[2/
|
| 291 |
python3 -m pip install --upgrade pip wheel setuptools -q
|
| 292 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 293 |
log_success "Ferramentas instaladas"
|
| 294 |
|
| 295 |
-
# [3] Instalar
|
| 296 |
-
log_info "[3/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 297 |
if [ -f "$COMFY_DIR/main.py" ]; then
|
| 298 |
log_warn "ComfyUI já existe, pulando instalação base"
|
| 299 |
else
|
|
@@ -307,36 +355,31 @@ else
|
|
| 307 |
fi
|
| 308 |
log_success "ComfyUI instalado em: $COMFY_DIR"
|
| 309 |
|
| 310 |
-
# [
|
| 311 |
-
log_info "[
|
| 312 |
-
(
|
| 313 |
-
|
| 314 |
-
|
| 315 |
-
|
| 316 |
-
|
| 317 |
-
|
| 318 |
-
|
| 319 |
-
|
| 320 |
-
cd "$SAGE_DIR"
|
| 321 |
-
python3 setup.py install --quiet 2>/dev/null
|
| 322 |
-
|
| 323 |
-
log_success "SageAttention instalado"
|
| 324 |
else
|
| 325 |
-
log_warn "
|
| 326 |
fi
|
| 327 |
-
|
| 328 |
-
|
|
|
|
| 329 |
|
| 330 |
-
# [
|
| 331 |
-
log_info "[
|
| 332 |
mkdir -p "$MODELS_DIR"/{diffusion_models,loras,vae,text_encoders,clip_vision,controlnet,upscale_models}
|
| 333 |
|
| 334 |
-
# Verificar
|
| 335 |
if command_exists aria2c; then
|
| 336 |
log_success "Usando aria2c para downloads (rápido)"
|
| 337 |
else
|
| 338 |
log_warn "aria2c não encontrado, usando wget/curl (mais lento)"
|
| 339 |
-
log_info "Instale aria2c para downloads mais rápidos: apt-get install aria2"
|
| 340 |
fi
|
| 341 |
|
| 342 |
# Processar downloads
|
|
@@ -346,26 +389,22 @@ else
|
|
| 346 |
log_warn "Alguns downloads falharam, mas continuando..."
|
| 347 |
fi
|
| 348 |
|
| 349 |
-
# [
|
| 350 |
-
log_info "[
|
| 351 |
CN_DIR="$COMFY_DIR/custom_nodes"
|
| 352 |
mkdir -p "$CN_DIR"
|
| 353 |
|
|
|
|
| 354 |
for repo_url in "${CUSTOM_NODES[@]}"; do
|
| 355 |
node_name=$(basename "$repo_url")
|
| 356 |
-
clone_or_update "$repo_url" "$CN_DIR/$node_name"
|
| 357 |
done
|
| 358 |
-
wait
|
| 359 |
|
| 360 |
log_success "Custom nodes instalados"
|
| 361 |
|
| 362 |
-
#
|
| 363 |
-
wait $SAGE_PID 2>/dev/null || true
|
| 364 |
-
|
| 365 |
-
# Verificação final
|
| 366 |
echo ""
|
| 367 |
-
log_info "
|
| 368 |
-
log_info "Verificando instalação..."
|
| 369 |
|
| 370 |
# Verificar arquivos principais
|
| 371 |
check_critical_files() {
|
|
@@ -392,10 +431,11 @@ check_critical_files() {
|
|
| 392 |
|
| 393 |
if check_critical_files; then
|
| 394 |
log_success "Instalação concluída com sucesso!"
|
| 395 |
-
|
| 396 |
echo ""
|
|
|
|
| 397 |
log_info "Iniciando ComfyUI..."
|
| 398 |
log_info "URL: http://localhost:$COMFY_PORT"
|
|
|
|
| 399 |
|
| 400 |
# Tentar usar SageAttention se disponível
|
| 401 |
SAGE_FLAG=""
|
|
@@ -408,5 +448,10 @@ if check_critical_files; then
|
|
| 408 |
exec comfy launch -- $SAGE_FLAG --listen "$COMFY_HOST" --port "$COMFY_PORT"
|
| 409 |
else
|
| 410 |
log_error "Arquivos críticos faltando. Verifique os erros acima."
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 411 |
exit 1
|
| 412 |
fi
|
|
|
|
| 1 |
#!/usr/bin/env bash
|
| 2 |
+
# setup_comfyui_wan22_fixed.sh
|
| 3 |
+
# Script corrigido para instalação do ComfyUI com Wan 2.2
|
| 4 |
|
| 5 |
set -euo pipefail
|
| 6 |
|
|
|
|
| 26 |
COMFY_HOST="${COMFY_HOST:-0.0.0.0}"
|
| 27 |
COMFY_PORT="${COMFY_PORT:-8818}"
|
| 28 |
CIVITAI_TOKEN="${CIVITAI_TOKEN:-4fcb2834969399006a736ee402b061e5}"
|
| 29 |
+
HF_TOKEN="${HF_TOKEN:-}" # Token opcional do HuggingFace para login
|
| 30 |
|
| 31 |
+
# Configurações de performance
|
| 32 |
export MAX_JOBS=32
|
| 33 |
export NVCC_APPEND_FLAGS="--threads 8"
|
| 34 |
export UV_SYSTEM_PYTHON=1
|
|
|
|
| 41 |
# Lista de downloads
|
| 42 |
# -----------------------------
|
| 43 |
# Formato: "URL|TIPO|NOME_ARQUIVO_OPCIONAL"
|
|
|
|
| 44 |
readonly DOWNLOAD_FILES=(
|
| 45 |
# Wan 2.2 models
|
| 46 |
+
#"hf://Comfy-Org/Wan_2.2_ComfyUI_Repackaged/split_files/diffusion_models/wan2.2_fun_control_low_noise_14B_fp8_scaled.safetensors|diffusion_models|"
|
| 47 |
+
#"hf://Comfy-Org/Wan_2.2_ComfyUI_Repackaged/split_files/diffusion_models/wan2.2_fun_control_high_noise_14B_fp8_scaled.safetensors|diffusion_models|"
|
| 48 |
+
#"hf://Comfy-Org/Wan_2.2_ComfyUI_Repackaged/split_files/loras/wan2.2_i2v_lightx2v_4steps_lora_v1_high_noise.safetensors|loras|"
|
| 49 |
+
#"hf://Comfy-Org/Wan_2.2_ComfyUI_Repackaged/split_files/loras/wan2.2_i2v_lightx2v_4steps_lora_v1_low_noise.safetensors|loras|"
|
| 50 |
+
#"hf://Comfy-Org/Wan_2.2_ComfyUI_Repackaged/split_files/vae/wan_2.1_vae.safetensors|vae|"
|
| 51 |
+
#"hf://Comfy-Org/Wan_2.2_ComfyUI_Repackaged/split_files/text_encoders/umt5_xxl_fp16.safetensors|text_encoders|"
|
|
|
|
| 52 |
# Wan 2.1 clip vision
|
| 53 |
+
#"hf://Comfy-Org/Wan_2.1_ComfyUI_repackaged/split_files/clip_vision/clip_vision_h.safetensors|clip_vision|"
|
|
|
|
| 54 |
# ControlNet
|
| 55 |
"hf://xinsir/controlnet-union-sdxl-1.0/diffusion_pytorch_model_promax.safetensors|controlnet|controlnet-union.safetensors"
|
| 56 |
+
"https://huggingface.co/ABDALLALSWAITI/Upscalers/resolve/main/anime/2x-AnimeSharpV2_MoSR_Soft.pth|upscale_models|2x-AnimeSharpV2_MoSR_Soft.pth"
|
| 57 |
# Civitai model
|
| 58 |
+
"https://civitai.com/api/download/models/2122278?type=Model&format=SafeTensor&size=pruned&fp=fp16|checkpoints|raehoshiIllustXL_v60.safetensors"
|
| 59 |
)
|
| 60 |
|
| 61 |
# Custom nodes para instalar
|
| 62 |
readonly CUSTOM_NODES=(
|
| 63 |
+
#"https://github.com/kijai/ComfyUI-Florence2"
|
| 64 |
+
#"https://github.com/kijai/ComfyUI-WanVideoWrapper"
|
| 65 |
+
#"https://github.com/Fannovel16/ComfyUI-Frame-Interpolation"
|
| 66 |
+
#"https://github.com/kijai/ComfyUI-GIMM-VFI"
|
| 67 |
+
#"https://github.com/Kosinkadink/ComfyUI-VideoHelperSuite"
|
| 68 |
+
#"https://github.com/kijai/ComfyUI-KJNodes"
|
| 69 |
+
#"https://github.com/Fannovel16/comfyui_controlnet_aux"
|
| 70 |
+
#"https://github.com/Artificial-Sweetener/comfyui-WhiteRabbit"
|
| 71 |
+
#"https://github.com/shiimizu/ComfyUI_smZNodes"
|
| 72 |
+
"https://github.com/CoreyCorza/ComfyUI-CRZnodes"
|
| 73 |
+
#"https://github.com/yuvraj108c/ComfyUI-Dwpose-Tensorrt"
|
| 74 |
+
#"https://github.com/Suzie1/ComfyUI_Comfyroll_CustomNodes"
|
| 75 |
+
#"https://github.com/grmchn/ComfyUI-ProportionChanger"
|
| 76 |
)
|
| 77 |
|
| 78 |
# -----------------------------
|
|
|
|
| 92 |
fi
|
| 93 |
}
|
| 94 |
|
| 95 |
+
# Download HuggingFace usando huggingface-cli com hf_transfer
|
| 96 |
download_hf() {
|
| 97 |
local repo="$1"
|
| 98 |
local file_path="$2"
|
|
|
|
| 114 |
|
| 115 |
log_info "Baixando de HF: $filename"
|
| 116 |
|
| 117 |
+
# Usar huggingface-cli com hf_transfer habilitado para velocidade máxima
|
| 118 |
+
if HF_HUB_ENABLE_HF_TRANSFER=1 huggingface-cli download "$repo" "$file_path" \
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 119 |
--local-dir "$target_dir" \
|
| 120 |
--local-dir-use-symlinks False \
|
| 121 |
+
--resume-download 2>/dev/null; then
|
| 122 |
+
|
| 123 |
+
# Verificar se arquivo foi baixado
|
| 124 |
+
if [ -f "$target_file" ]; then
|
| 125 |
+
log_success "Download concluído: $filename"
|
| 126 |
+
return 0
|
| 127 |
fi
|
| 128 |
+
|
| 129 |
+
# Procurar arquivo em subdiretórios se não estiver no local esperado
|
| 130 |
+
local downloaded_file=$(find "$target_dir" -name "$filename" -type f 2>/dev/null | head -1)
|
| 131 |
+
if [ -n "$downloaded_file" ] && [ "$downloaded_file" != "$target_file" ]; then
|
| 132 |
+
mv "$downloaded_file" "$target_file"
|
| 133 |
+
log_success "Download concluído e movido: $filename"
|
| 134 |
+
return 0
|
| 135 |
+
fi
|
| 136 |
+
fi
|
| 137 |
|
| 138 |
+
log_error "Falha ao baixar: $filename"
|
| 139 |
return 1
|
| 140 |
}
|
| 141 |
|
|
|
|
| 180 |
if [ -n "$filename" ]; then
|
| 181 |
curl -L -# -C - -o "$target_dir/$filename" "$url" && return 0
|
| 182 |
else
|
|
|
|
| 183 |
local headers=$(curl -sI -L "$url")
|
| 184 |
local detected_name=$(echo "$headers" | grep -i "content-disposition" | sed -n 's/.*filename="\([^"]*\)".*/\1/p' | tr -d '\r')
|
|
|
|
| 185 |
if [ -z "$detected_name" ]; then
|
| 186 |
detected_name="downloaded_$(date +%s).safetensors"
|
| 187 |
fi
|
|
|
|
| 188 |
curl -L -# -C - -o "$target_dir/$detected_name" "$url" && return 0
|
| 189 |
fi
|
| 190 |
fi
|
|
|
|
| 208 |
# Determinar diretório de destino
|
| 209 |
local target_dir="$MODELS_DIR"
|
| 210 |
case "$type" in
|
| 211 |
+
checkpoints) target_dir="$MODELS_DIR/checkpoints" ;;
|
| 212 |
loras) target_dir="$MODELS_DIR/loras" ;;
|
| 213 |
vae) target_dir="$MODELS_DIR/vae" ;;
|
| 214 |
text_encoders) target_dir="$MODELS_DIR/text_encoders" ;;
|
|
|
|
| 225 |
if [[ "$url" == hf://* ]]; then
|
| 226 |
# HuggingFace download
|
| 227 |
url="${url#hf://}" # Remove prefixo hf://
|
|
|
|
|
|
|
| 228 |
repo=$(echo "$url" | cut -d'/' -f1-2)
|
| 229 |
file_path=$(echo "$url" | cut -d'/' -f3-)
|
| 230 |
|
|
|
|
| 235 |
fi
|
| 236 |
done
|
| 237 |
|
| 238 |
+
# Limpar arquivos órfãos em split_files (se existirem)
|
| 239 |
+
if [ -d "$MODELS_DIR/diffusion_models/split_files" ]; then
|
| 240 |
+
log_info "Movendo arquivos de split_files para diretórios corretos..."
|
| 241 |
+
find "$MODELS_DIR" -path "*/split_files/*" -name "*.safetensors" | while read -r file; do
|
| 242 |
+
local base_dir=$(dirname "$(dirname "$file")")
|
| 243 |
+
local target_name=$(basename "$file")
|
| 244 |
+
if [ ! -f "$base_dir/$target_name" ]; then
|
| 245 |
+
mv "$file" "$base_dir/" 2>/dev/null && log_success "Movido: $target_name"
|
| 246 |
+
fi
|
| 247 |
+
done
|
| 248 |
+
# Remover diretórios split_files vazios
|
| 249 |
+
find "$MODELS_DIR" -type d -name "split_files" -empty -delete 2>/dev/null
|
| 250 |
+
fi
|
| 251 |
+
|
| 252 |
return $failed_count
|
| 253 |
}
|
| 254 |
|
|
|
|
| 256 |
clone_or_update() {
|
| 257 |
local url="$1"
|
| 258 |
local dest="$2"
|
| 259 |
+
local node_name=$(basename "$dest")
|
| 260 |
|
| 261 |
+
# Timeout de 60 segundos para operações git
|
| 262 |
if [ -d "$dest/.git" ]; then
|
| 263 |
+
log_info "Atualizando $node_name..."
|
| 264 |
+
timeout 60 git -C "$dest" pull --ff-only 2>/dev/null || {
|
| 265 |
+
log_warn "Timeout ou erro ao atualizar $node_name"
|
| 266 |
+
return 0 # Não falhar, apenas avisar
|
| 267 |
+
}
|
| 268 |
else
|
| 269 |
+
log_info "Clonando $node_name..."
|
| 270 |
+
timeout 60 git clone --recursive --depth 1 "$url" "$dest" 2>/dev/null || {
|
| 271 |
+
log_warn "Falha ao clonar $node_name"
|
| 272 |
+
return 0 # Não falhar, apenas avisar
|
| 273 |
+
}
|
| 274 |
fi
|
| 275 |
|
| 276 |
+
# Instalar requirements se existir (com timeout)
|
| 277 |
if [ -f "$dest/requirements.txt" ]; then
|
| 278 |
+
timeout 120 python3 -m pip install --no-warn-script-location -q -r "$dest/requirements.txt" 2>/dev/null || {
|
| 279 |
+
log_warn "Falha ao instalar requirements para $node_name"
|
| 280 |
+
}
|
| 281 |
fi
|
| 282 |
+
|
| 283 |
+
return 0
|
| 284 |
}
|
| 285 |
|
| 286 |
# -----------------------------
|
|
|
|
| 288 |
# -----------------------------
|
| 289 |
echo ""
|
| 290 |
log_info "========================================="
|
| 291 |
+
log_info " ComfyUI + Wan 2.2 Setup (Fixed)"
|
| 292 |
log_info "========================================="
|
| 293 |
echo ""
|
| 294 |
|
| 295 |
+
# [1] Verificar e instalar dependências
|
| 296 |
+
log_info "[1/8] Verificando e instalando dependências..."
|
| 297 |
+
|
| 298 |
+
# Instalar aria2c do sistema se não existir
|
| 299 |
+
if ! command_exists aria2c; then
|
| 300 |
+
log_info "Instalando aria2c do sistema..."
|
| 301 |
+
apt-get update -qq && apt-get install -y -qq aria2 2>/dev/null
|
| 302 |
+
fi
|
| 303 |
+
|
| 304 |
for cmd in python3 git wget curl; do
|
| 305 |
if ! command_exists "$cmd"; then
|
| 306 |
log_error "Dependência faltando: $cmd"
|
|
|
|
| 310 |
log_success "Dependências OK"
|
| 311 |
|
| 312 |
# [2] Atualizar pip e instalar ferramentas
|
| 313 |
+
log_info "[2/8] Preparando ferramentas Python..."
|
| 314 |
python3 -m pip install --upgrade pip wheel setuptools -q
|
| 315 |
+
|
| 316 |
+
# Instalar huggingface_hub com CLI e hf_transfer para velocidade máxima
|
| 317 |
+
python3 -m pip install --upgrade "huggingface_hub[cli]>=0.26.0" hf_transfer comfy-cli -q
|
| 318 |
+
|
| 319 |
+
# Configurar token HF se disponível (opcional)
|
| 320 |
+
HF_TOKEN="${HF_TOKEN:-}"
|
| 321 |
+
if [ -n "$HF_TOKEN" ]; then
|
| 322 |
+
if huggingface-cli login --token "$HF_TOKEN" 2>/dev/null; then
|
| 323 |
+
log_success "Login HF configurado"
|
| 324 |
+
else
|
| 325 |
+
log_warn "Falha ao configurar login HF, continuando sem autenticação"
|
| 326 |
+
fi
|
| 327 |
+
fi
|
| 328 |
+
|
| 329 |
+
# Verificar se hf está disponível
|
| 330 |
+
if command_exists huggingface-cli; then
|
| 331 |
+
log_success "huggingface-cli disponível"
|
| 332 |
+
else
|
| 333 |
+
log_warn "huggingface-cli não encontrado"
|
| 334 |
+
fi
|
| 335 |
+
|
| 336 |
log_success "Ferramentas instaladas"
|
| 337 |
|
| 338 |
+
# [3] Instalar PyTorch com CUDA 12.8
|
| 339 |
+
log_info "[3/8] Instalando PyTorch com CUDA 12.8..."
|
| 340 |
+
python3 -m pip install --upgrade torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu128
|
| 341 |
+
log_success "PyTorch com CUDA 12.8 instalado"
|
| 342 |
+
|
| 343 |
+
# [4] Instalar ComfyUI
|
| 344 |
+
log_info "[4/8] Instalando ComfyUI..."
|
| 345 |
if [ -f "$COMFY_DIR/main.py" ]; then
|
| 346 |
log_warn "ComfyUI já existe, pulando instalação base"
|
| 347 |
else
|
|
|
|
| 355 |
fi
|
| 356 |
log_success "ComfyUI instalado em: $COMFY_DIR"
|
| 357 |
|
| 358 |
+
# [5] Instalar SageAttention (wheel pré-compilada)
|
| 359 |
+
log_info "[5/8] Instalando SageAttention..."
|
| 360 |
+
if command_exists nvcc || python3 -c "import torch; print(torch.cuda.is_available())" 2>/dev/null | grep -q "True"; then
|
| 361 |
+
log_info "Instalando SageAttention pré-compilada..."
|
| 362 |
+
python3 -m pip install "https://huggingface.co/adbrasi/comfywheel/resolve/main/sageattention-2.2.0-cp311-cp311-linux_x86_64.whl" -q
|
| 363 |
+
|
| 364 |
+
# Verificar instalação
|
| 365 |
+
if python3 -c "import sageattention" 2>/dev/null; then
|
| 366 |
+
log_success "SageAttention instalado com sucesso"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 367 |
else
|
| 368 |
+
log_warn "SageAttention instalado mas não pôde ser importado"
|
| 369 |
fi
|
| 370 |
+
else
|
| 371 |
+
log_warn "CUDA não detectado, pulando SageAttention"
|
| 372 |
+
fi
|
| 373 |
|
| 374 |
+
# [6] Baixar modelos
|
| 375 |
+
log_info "[6/8] Baixando modelos..."
|
| 376 |
mkdir -p "$MODELS_DIR"/{diffusion_models,loras,vae,text_encoders,clip_vision,controlnet,upscale_models}
|
| 377 |
|
| 378 |
+
# Verificar ferramentas de download
|
| 379 |
if command_exists aria2c; then
|
| 380 |
log_success "Usando aria2c para downloads (rápido)"
|
| 381 |
else
|
| 382 |
log_warn "aria2c não encontrado, usando wget/curl (mais lento)"
|
|
|
|
| 383 |
fi
|
| 384 |
|
| 385 |
# Processar downloads
|
|
|
|
| 389 |
log_warn "Alguns downloads falharam, mas continuando..."
|
| 390 |
fi
|
| 391 |
|
| 392 |
+
# [7] Instalar custom nodes
|
| 393 |
+
log_info "[7/8] Instalando custom nodes..."
|
| 394 |
CN_DIR="$COMFY_DIR/custom_nodes"
|
| 395 |
mkdir -p "$CN_DIR"
|
| 396 |
|
| 397 |
+
# Instalar nodes sequencialmente para evitar travamentos
|
| 398 |
for repo_url in "${CUSTOM_NODES[@]}"; do
|
| 399 |
node_name=$(basename "$repo_url")
|
| 400 |
+
clone_or_update "$repo_url" "$CN_DIR/$node_name"
|
| 401 |
done
|
|
|
|
| 402 |
|
| 403 |
log_success "Custom nodes instalados"
|
| 404 |
|
| 405 |
+
# [8] Verificação final
|
|
|
|
|
|
|
|
|
|
| 406 |
echo ""
|
| 407 |
+
log_info "[8/8] Verificando instalação..."
|
|
|
|
| 408 |
|
| 409 |
# Verificar arquivos principais
|
| 410 |
check_critical_files() {
|
|
|
|
| 431 |
|
| 432 |
if check_critical_files; then
|
| 433 |
log_success "Instalação concluída com sucesso!"
|
|
|
|
| 434 |
echo ""
|
| 435 |
+
log_info "========================================="
|
| 436 |
log_info "Iniciando ComfyUI..."
|
| 437 |
log_info "URL: http://localhost:$COMFY_PORT"
|
| 438 |
+
log_info "========================================="
|
| 439 |
|
| 440 |
# Tentar usar SageAttention se disponível
|
| 441 |
SAGE_FLAG=""
|
|
|
|
| 448 |
exec comfy launch -- $SAGE_FLAG --listen "$COMFY_HOST" --port "$COMFY_PORT"
|
| 449 |
else
|
| 450 |
log_error "Arquivos críticos faltando. Verifique os erros acima."
|
| 451 |
+
|
| 452 |
+
# Mostrar onde os arquivos podem estar
|
| 453 |
+
log_info "Procurando arquivos mal posicionados..."
|
| 454 |
+
find "$MODELS_DIR" -name "*.safetensors" -type f | head -20
|
| 455 |
+
|
| 456 |
exit 1
|
| 457 |
fi
|