Update setup_comfy_wanDANCE.sh
Browse files- setup_comfy_wanDANCE.sh +78 -57
setup_comfy_wanDANCE.sh
CHANGED
|
@@ -43,13 +43,13 @@ export EXT_PARALLEL=4
|
|
| 43 |
# Formato: "URL|TIPO|NOME_ARQUIVO_OPCIONAL"
|
| 44 |
readonly DOWNLOAD_FILES=(
|
| 45 |
# Wan 2.2 models
|
| 46 |
-
"hf://Kijai/WanVideo_comfy/
|
| 47 |
-
"hf://Kijai/WanVideo_comfy/
|
| 48 |
-
"hf://Comfy-Org/Wan_2.2_ComfyUI_Repackaged/split_files/vae/wan_2.1_vae.safetensors|vae|"
|
| 49 |
-
"hf://Comfy-Org/Wan_2.2_ComfyUI_Repackaged/split_files/text_encoders/umt5_xxl_fp16.safetensors|text_encoders|"
|
| 50 |
# Wan 2.1 clip vision
|
| 51 |
-
"hf://Comfy-Org/Wan_2.1_ComfyUI_repackaged/split_files/clip_vision/clip_vision_h.safetensors|clip_vision|"
|
| 52 |
-
# ControlNet
|
| 53 |
"https://huggingface.co/Kijai/WanVideo_comfy/resolve/main/taew2_1.safetensors|vae_approx|taew2_1.safetensors"
|
| 54 |
"https://huggingface.co/Kijai/WanVideo_comfy/resolve/main/UniAnimate-Wan2.1-14B-Lora-12000-fp16.safetensors|loras|UniAnimate-Wan2.1-14B-Lora-12000-fp16.safetensors"
|
| 55 |
"hf://xinsir/controlnet-union-sdxl-1.0/diffusion_pytorch_model_promax.safetensors|controlnet|controlnet-union.safetensors"
|
|
@@ -92,14 +92,14 @@ add_civitai_token() {
|
|
| 92 |
fi
|
| 93 |
}
|
| 94 |
|
| 95 |
-
# Download HuggingFace usando
|
| 96 |
download_hf() {
|
| 97 |
local repo="$1"
|
| 98 |
local file_path="$2"
|
| 99 |
local target_dir="$3"
|
| 100 |
local filename="$4"
|
| 101 |
|
| 102 |
-
#
|
| 103 |
if [ -z "$filename" ]; then
|
| 104 |
filename=$(basename "$file_path")
|
| 105 |
fi
|
|
@@ -113,28 +113,49 @@ download_hf() {
|
|
| 113 |
fi
|
| 114 |
|
| 115 |
log_info "Baixando de HF: $filename"
|
|
|
|
|
|
|
| 116 |
|
| 117 |
-
#
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
if
|
| 125 |
-
|
| 126 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 127 |
fi
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 128 |
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
if [ -n "$downloaded_file" ] && [ "$downloaded_file" != "$target_file" ]; then
|
| 132 |
mv "$downloaded_file" "$target_file"
|
| 133 |
-
|
|
|
|
| 134 |
return 0
|
|
|
|
|
|
|
| 135 |
fi
|
| 136 |
fi
|
| 137 |
|
|
|
|
| 138 |
log_error "Falha ao baixar: $filename"
|
| 139 |
return 1
|
| 140 |
}
|
|
@@ -209,6 +230,7 @@ process_downloads() {
|
|
| 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 |
vae_approx) target_dir="$MODELS_DIR/vae_approx" ;;
|
|
@@ -226,8 +248,10 @@ process_downloads() {
|
|
| 226 |
if [[ "$url" == hf://* ]]; then
|
| 227 |
# HuggingFace download
|
| 228 |
url="${url#hf://}" # Remove prefixo hf://
|
| 229 |
-
|
| 230 |
-
|
|
|
|
|
|
|
| 231 |
|
| 232 |
download_hf "$repo" "$file_path" "$target_dir" "$filename" || ((failed_count++))
|
| 233 |
else
|
|
@@ -236,20 +260,6 @@ process_downloads() {
|
|
| 236 |
fi
|
| 237 |
done
|
| 238 |
|
| 239 |
-
# Limpar arquivos órfãos em split_files (se existirem)
|
| 240 |
-
if [ -d "$MODELS_DIR/diffusion_models/split_files" ]; then
|
| 241 |
-
log_info "Movendo arquivos de split_files para diretórios corretos..."
|
| 242 |
-
find "$MODELS_DIR" -path "*/split_files/*" -name "*.safetensors" | while read -r file; do
|
| 243 |
-
local base_dir=$(dirname "$(dirname "$file")")
|
| 244 |
-
local target_name=$(basename "$file")
|
| 245 |
-
if [ ! -f "$base_dir/$target_name" ]; then
|
| 246 |
-
mv "$file" "$base_dir/" 2>/dev/null && log_success "Movido: $target_name"
|
| 247 |
-
fi
|
| 248 |
-
done
|
| 249 |
-
# Remover diretórios split_files vazios
|
| 250 |
-
find "$MODELS_DIR" -type d -name "split_files" -empty -delete 2>/dev/null
|
| 251 |
-
fi
|
| 252 |
-
|
| 253 |
return $failed_count
|
| 254 |
}
|
| 255 |
|
|
@@ -289,7 +299,7 @@ clone_or_update() {
|
|
| 289 |
# -----------------------------
|
| 290 |
echo ""
|
| 291 |
log_info "========================================="
|
| 292 |
-
log_info " ComfyUI + Wan 2.2 Setup (Fixed)"
|
| 293 |
log_info "========================================="
|
| 294 |
echo ""
|
| 295 |
|
|
@@ -315,7 +325,7 @@ log_info "[2/8] Preparando ferramentas Python..."
|
|
| 315 |
python3 -m pip install --upgrade pip wheel setuptools -q
|
| 316 |
|
| 317 |
# Instalar huggingface_hub com CLI e hf_transfer para velocidade máxima
|
| 318 |
-
python3 -m pip install --upgrade "huggingface_hub[cli]>=0.26.0"
|
| 319 |
|
| 320 |
# Configurar token HF se disponível (opcional)
|
| 321 |
HF_TOKEN="${HF_TOKEN:-}"
|
|
@@ -327,11 +337,13 @@ if [ -n "$HF_TOKEN" ]; then
|
|
| 327 |
fi
|
| 328 |
fi
|
| 329 |
|
| 330 |
-
# Verificar
|
| 331 |
-
if command_exists
|
| 332 |
-
log_success "
|
|
|
|
|
|
|
| 333 |
else
|
| 334 |
-
|
| 335 |
fi
|
| 336 |
|
| 337 |
log_success "Ferramentas instaladas"
|
|
@@ -374,7 +386,7 @@ fi
|
|
| 374 |
|
| 375 |
# [6] Baixar modelos
|
| 376 |
log_info "[6/8] Baixando modelos..."
|
| 377 |
-
mkdir -p "$MODELS_DIR"/{diffusion_models,loras,vae,text_encoders,clip_vision,controlnet,upscale_models}
|
| 378 |
|
| 379 |
# Verificar ferramentas de download
|
| 380 |
if command_exists aria2c; then
|
|
@@ -407,14 +419,14 @@ log_success "Custom nodes instalados"
|
|
| 407 |
echo ""
|
| 408 |
log_info "[8/8] Verificando instalação..."
|
| 409 |
|
| 410 |
-
# Verificar arquivos principais
|
| 411 |
check_critical_files() {
|
| 412 |
local files=(
|
| 413 |
"$COMFY_DIR/main.py"
|
| 414 |
-
"$MODELS_DIR/diffusion_models/
|
| 415 |
-
"$MODELS_DIR/diffusion_models/wan2.2_fun_control_high_noise_14B_fp8_scaled.safetensors"
|
| 416 |
"$MODELS_DIR/vae/wan_2.1_vae.safetensors"
|
| 417 |
"$MODELS_DIR/text_encoders/umt5_xxl_fp16.safetensors"
|
|
|
|
| 418 |
)
|
| 419 |
|
| 420 |
local missing=0
|
|
@@ -422,12 +434,23 @@ check_critical_files() {
|
|
| 422 |
if [ -f "$file" ]; then
|
| 423 |
log_success "✓ $(basename "$file")"
|
| 424 |
else
|
| 425 |
-
|
| 426 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 427 |
fi
|
| 428 |
done
|
| 429 |
|
| 430 |
-
return
|
| 431 |
}
|
| 432 |
|
| 433 |
if check_critical_files; then
|
|
@@ -448,11 +471,9 @@ if check_critical_files; then
|
|
| 448 |
cd "$COMFY_DIR"
|
| 449 |
exec comfy launch -- $SAGE_FLAG --listen "$COMFY_HOST" --port "$COMFY_PORT"
|
| 450 |
else
|
| 451 |
-
log_error "
|
| 452 |
-
|
| 453 |
-
# Mostrar onde os arquivos podem estar
|
| 454 |
-
log_info "Procurando arquivos mal posicionados..."
|
| 455 |
-
find "$MODELS_DIR" -name "*.safetensors" -type f | head -20
|
| 456 |
|
| 457 |
-
|
|
|
|
| 458 |
fi
|
|
|
|
| 43 |
# Formato: "URL|TIPO|NOME_ARQUIVO_OPCIONAL"
|
| 44 |
readonly DOWNLOAD_FILES=(
|
| 45 |
# Wan 2.2 models
|
| 46 |
+
"hf://Kijai/WanVideo_comfy/Wan2_1-I2V-14B-720P_fp8_e4m3fn.safetensors|diffusion_models|Wan2_1-I2V-14B-720P_fp8_e4m3fn.safetensors"
|
| 47 |
+
"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"
|
| 48 |
+
"hf://Comfy-Org/Wan_2.2_ComfyUI_Repackaged/split_files/vae/wan_2.1_vae.safetensors|vae|wan_2.1_vae.safetensors"
|
| 49 |
+
"hf://Comfy-Org/Wan_2.2_ComfyUI_Repackaged/split_files/text_encoders/umt5_xxl_fp16.safetensors|text_encoders|umt5_xxl_fp16.safetensors"
|
| 50 |
# Wan 2.1 clip vision
|
| 51 |
+
"hf://Comfy-Org/Wan_2.1_ComfyUI_repackaged/split_files/clip_vision/clip_vision_h.safetensors|clip_vision|clip_vision_h.safetensors"
|
| 52 |
+
# ControlNet e outros modelos
|
| 53 |
"https://huggingface.co/Kijai/WanVideo_comfy/resolve/main/taew2_1.safetensors|vae_approx|taew2_1.safetensors"
|
| 54 |
"https://huggingface.co/Kijai/WanVideo_comfy/resolve/main/UniAnimate-Wan2.1-14B-Lora-12000-fp16.safetensors|loras|UniAnimate-Wan2.1-14B-Lora-12000-fp16.safetensors"
|
| 55 |
"hf://xinsir/controlnet-union-sdxl-1.0/diffusion_pytorch_model_promax.safetensors|controlnet|controlnet-union.safetensors"
|
|
|
|
| 92 |
fi
|
| 93 |
}
|
| 94 |
|
| 95 |
+
# Download HuggingFace usando hf com hf_transfer
|
| 96 |
download_hf() {
|
| 97 |
local repo="$1"
|
| 98 |
local file_path="$2"
|
| 99 |
local target_dir="$3"
|
| 100 |
local filename="$4"
|
| 101 |
|
| 102 |
+
# Se filename não foi fornecido, extrair do caminho
|
| 103 |
if [ -z "$filename" ]; then
|
| 104 |
filename=$(basename "$file_path")
|
| 105 |
fi
|
|
|
|
| 113 |
fi
|
| 114 |
|
| 115 |
log_info "Baixando de HF: $filename"
|
| 116 |
+
log_info " Repo: $repo"
|
| 117 |
+
log_info " Path: $file_path"
|
| 118 |
|
| 119 |
+
# Criar diretório temporário para download
|
| 120 |
+
local temp_dir=$(mktemp -d)
|
| 121 |
+
|
| 122 |
+
# Tentar primeiro com 'hf download' (novo comando)
|
| 123 |
+
local download_success=false
|
| 124 |
+
|
| 125 |
+
if command_exists hf; then
|
| 126 |
+
if HF_HUB_ENABLE_HF_TRANSFER=1 hf download "$repo" "$file_path" \
|
| 127 |
+
--local-dir "$temp_dir" \
|
| 128 |
+
--local-dir-use-symlinks False 2>/dev/null; then
|
| 129 |
+
download_success=true
|
| 130 |
+
fi
|
| 131 |
+
fi
|
| 132 |
+
|
| 133 |
+
# Se 'hf' não funcionou, tentar com huggingface-cli
|
| 134 |
+
if [ "$download_success" = false ] && command_exists huggingface-cli; then
|
| 135 |
+
log_warn "Tentando com huggingface-cli..."
|
| 136 |
+
if HF_HUB_ENABLE_HF_TRANSFER=1 huggingface-cli download "$repo" "$file_path" \
|
| 137 |
+
--local-dir "$temp_dir" \
|
| 138 |
+
--local-dir-use-symlinks False 2>/dev/null; then
|
| 139 |
+
download_success=true
|
| 140 |
fi
|
| 141 |
+
fi
|
| 142 |
+
|
| 143 |
+
if [ "$download_success" = true ]; then
|
| 144 |
+
# Procurar o arquivo baixado (pode estar em subdiretórios)
|
| 145 |
+
local downloaded_file=$(find "$temp_dir" -type f \( -name "*.safetensors" -o -name "*.pth" -o -name "*.pt" -o -name "*.bin" \) 2>/dev/null | head -1)
|
| 146 |
|
| 147 |
+
if [ -n "$downloaded_file" ]; then
|
| 148 |
+
# Mover para o destino correto com o nome correto
|
|
|
|
| 149 |
mv "$downloaded_file" "$target_file"
|
| 150 |
+
rm -rf "$temp_dir"
|
| 151 |
+
log_success "Download concluído: $filename"
|
| 152 |
return 0
|
| 153 |
+
else
|
| 154 |
+
log_error "Arquivo baixado mas não encontrado em $temp_dir"
|
| 155 |
fi
|
| 156 |
fi
|
| 157 |
|
| 158 |
+
rm -rf "$temp_dir"
|
| 159 |
log_error "Falha ao baixar: $filename"
|
| 160 |
return 1
|
| 161 |
}
|
|
|
|
| 230 |
local target_dir="$MODELS_DIR"
|
| 231 |
case "$type" in
|
| 232 |
checkpoints) target_dir="$MODELS_DIR/checkpoints" ;;
|
| 233 |
+
diffusion_models) target_dir="$MODELS_DIR/diffusion_models" ;;
|
| 234 |
loras) target_dir="$MODELS_DIR/loras" ;;
|
| 235 |
vae) target_dir="$MODELS_DIR/vae" ;;
|
| 236 |
vae_approx) target_dir="$MODELS_DIR/vae_approx" ;;
|
|
|
|
| 248 |
if [[ "$url" == hf://* ]]; then
|
| 249 |
# HuggingFace download
|
| 250 |
url="${url#hf://}" # Remove prefixo hf://
|
| 251 |
+
|
| 252 |
+
# Separar repo e caminho do arquivo
|
| 253 |
+
local repo=$(echo "$url" | cut -d'/' -f1-2)
|
| 254 |
+
local file_path=$(echo "$url" | cut -d'/' -f3-)
|
| 255 |
|
| 256 |
download_hf "$repo" "$file_path" "$target_dir" "$filename" || ((failed_count++))
|
| 257 |
else
|
|
|
|
| 260 |
fi
|
| 261 |
done
|
| 262 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 263 |
return $failed_count
|
| 264 |
}
|
| 265 |
|
|
|
|
| 299 |
# -----------------------------
|
| 300 |
echo ""
|
| 301 |
log_info "========================================="
|
| 302 |
+
log_info " ComfyUI + Wan 2.2 Setup (Fixed v2)"
|
| 303 |
log_info "========================================="
|
| 304 |
echo ""
|
| 305 |
|
|
|
|
| 325 |
python3 -m pip install --upgrade pip wheel setuptools -q
|
| 326 |
|
| 327 |
# Instalar huggingface_hub com CLI e hf_transfer para velocidade máxima
|
| 328 |
+
python3 -m pip install --upgrade "huggingface_hub[cli,hf_transfer]>=0.26.0" comfy-cli -q
|
| 329 |
|
| 330 |
# Configurar token HF se disponível (opcional)
|
| 331 |
HF_TOKEN="${HF_TOKEN:-}"
|
|
|
|
| 337 |
fi
|
| 338 |
fi
|
| 339 |
|
| 340 |
+
# Verificar comandos disponíveis
|
| 341 |
+
if command_exists hf; then
|
| 342 |
+
log_success "Comando 'hf' disponível (recomendado)"
|
| 343 |
+
elif command_exists huggingface-cli; then
|
| 344 |
+
log_warn "Usando 'huggingface-cli' (deprecated, mas funcional)"
|
| 345 |
else
|
| 346 |
+
log_error "Nenhum comando HF disponível!"
|
| 347 |
fi
|
| 348 |
|
| 349 |
log_success "Ferramentas instaladas"
|
|
|
|
| 386 |
|
| 387 |
# [6] Baixar modelos
|
| 388 |
log_info "[6/8] Baixando modelos..."
|
| 389 |
+
mkdir -p "$MODELS_DIR"/{diffusion_models,loras,vae,vae_approx,text_encoders,clip_vision,controlnet,upscale_models,checkpoints}
|
| 390 |
|
| 391 |
# Verificar ferramentas de download
|
| 392 |
if command_exists aria2c; then
|
|
|
|
| 419 |
echo ""
|
| 420 |
log_info "[8/8] Verificando instalação..."
|
| 421 |
|
| 422 |
+
# Verificar arquivos principais (ajustado para os modelos que você está baixando)
|
| 423 |
check_critical_files() {
|
| 424 |
local files=(
|
| 425 |
"$COMFY_DIR/main.py"
|
| 426 |
+
"$MODELS_DIR/diffusion_models/Wan2_1-I2V-14B-720P_fp8_e4m3fn.safetensors"
|
|
|
|
| 427 |
"$MODELS_DIR/vae/wan_2.1_vae.safetensors"
|
| 428 |
"$MODELS_DIR/text_encoders/umt5_xxl_fp16.safetensors"
|
| 429 |
+
"$MODELS_DIR/clip_vision/clip_vision_h.safetensors"
|
| 430 |
)
|
| 431 |
|
| 432 |
local missing=0
|
|
|
|
| 434 |
if [ -f "$file" ]; then
|
| 435 |
log_success "✓ $(basename "$file")"
|
| 436 |
else
|
| 437 |
+
log_warn "✗ $(basename "$file") não encontrado (opcional)"
|
| 438 |
+
fi
|
| 439 |
+
done
|
| 440 |
+
|
| 441 |
+
# Listar modelos baixados
|
| 442 |
+
echo ""
|
| 443 |
+
log_info "Modelos disponíveis:"
|
| 444 |
+
for dir in diffusion_models loras vae vae_approx text_encoders clip_vision controlnet upscale_models checkpoints; do
|
| 445 |
+
if [ -d "$MODELS_DIR/$dir" ]; then
|
| 446 |
+
local count=$(find "$MODELS_DIR/$dir" -type f \( -name "*.safetensors" -o -name "*.pth" -o -name "*.pt" \) 2>/dev/null | wc -l)
|
| 447 |
+
if [ $count -gt 0 ]; then
|
| 448 |
+
log_success " $dir: $count arquivo(s)"
|
| 449 |
+
fi
|
| 450 |
fi
|
| 451 |
done
|
| 452 |
|
| 453 |
+
return 0
|
| 454 |
}
|
| 455 |
|
| 456 |
if check_critical_files; then
|
|
|
|
| 471 |
cd "$COMFY_DIR"
|
| 472 |
exec comfy launch -- $SAGE_FLAG --listen "$COMFY_HOST" --port "$COMFY_PORT"
|
| 473 |
else
|
| 474 |
+
log_error "Alguns arquivos não foram encontrados, mas a instalação pode funcionar."
|
| 475 |
+
log_info "Iniciando ComfyUI mesmo assim..."
|
|
|
|
|
|
|
|
|
|
| 476 |
|
| 477 |
+
cd "$COMFY_DIR"
|
| 478 |
+
exec comfy launch -- --listen "$COMFY_HOST" --port "$COMFY_PORT"
|
| 479 |
fi
|