File size: 12,448 Bytes
478691d 0b4783d 478691d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 |
param(
# Accepte le chemin d'installation du script principal.
# Par défaut, utilise son propre dossier s'il est lancé seul.
[string]$InstallPath = $PSScriptRoot
)
<#
.SYNOPSIS
A PowerShell script to interactively download WAN 2.1 models for ComfyUI.
#>
#===========================================================================
# SECTION 1: HELPER FUNCTIONS & SETUP
#===========================================================================
$InstallPath = $InstallPath.Trim('"')
function Write-Log {
param([string]$Message, [string]$Color = "White")
$logFile = Join-Path $InstallPath "logs\install_log.txt"
$formattedMessage = "[$([DateTime]::Now.ToString('yyyy-MM-dd HH:mm:ss'))] [ModelDownloader-WAN] $Message"
Write-Host $Message -ForegroundColor $Color
Add-Content -Path $logFile -Value $formattedMessage -ErrorAction SilentlyContinue
}
function Invoke-AndLog {
param([string]$File, [string]$Arguments)
$logFile = Join-Path $InstallPath "logs\install_log.txt"
$commandToRun = "`"$File`" $Arguments"
$cmdArguments = "/C `"$commandToRun >> `"`"$logFile`"`" 2>&1`""
try {
Start-Process -FilePath "cmd.exe" -ArgumentList $cmdArguments -Wait -WindowStyle Hidden
} catch {
Write-Log "FATAL ERROR trying to execute command: $commandToRun" -Color Red
}
}
function Download-File {
param([string]$Uri, [string]$OutFile)
if (Test-Path $OutFile) {
Write-Log "Skipping: $((Split-Path $OutFile -Leaf)) (already exists)." -Color Gray
} else {
$fileName = Split-Path -Path $Uri -Leaf
if (Get-Command 'aria2c' -ErrorAction SilentlyContinue) {
Write-Log "Downloading: $fileName"
$aria_args = "-c -x 16 -s 16 -k 1M --dir=`"$((Split-Path $OutFile -Parent))`" --out=`"$((Split-Path $OutFile -Leaf))`" `"$Uri`""
Invoke-AndLog "aria2c" $aria_args
} else {
Write-Log "Aria2 not found. Falling back to standard download: $fileName" -Color Yellow
Invoke-WebRequest -Uri $Uri -OutFile $OutFile
}
}
}
function Ask-Question {
param([string]$Prompt, [string[]]$Choices, [string[]]$ValidAnswers)
$choice = ''
while ($choice -notin $ValidAnswers) {
Write-Log "`n$Prompt" -Color Yellow
foreach ($line in $Choices) {
Write-Host " $line" -ForegroundColor Green
}
$choice = (Read-Host "Enter your choice and press Enter").ToUpper()
if ($choice -notin $ValidAnswers) {
Write-Log "Invalid choice. Please try again." -Color Red
}
}
return $choice
}
#===========================================================================
# SECTION 2: SCRIPT EXECUTION
#===========================================================================
$InstallPath = $InstallPath.Trim('"')
$comfyPath = Join-Path $InstallPath "ComfyUI"
$modelsPath = Join-Path $comfyPath "models"
if (-not (Test-Path $modelsPath)) { Write-Log "Could not find ComfyUI models path at '$modelsPath'. Exiting." -Color Red; Read-Host "Press Enter to exit."; exit }
# --- GPU Detection ---
Write-Log "-------------------------------------------------------------------------------"
Write-Log "Checking for NVIDIA GPU to provide model recommendations..." -Color Yellow
if (Get-Command 'nvidia-smi' -ErrorAction SilentlyContinue) {
try {
$gpuInfoCsv = nvidia-smi --query-gpu=name,memory.total --format=csv,noheader
if ($gpuInfoCsv) {
$gpuInfoParts = $gpuInfoCsv.Split(','); $gpuName = $gpuInfoParts[0].Trim(); $gpuMemoryMiB = ($gpuInfoParts[1] -replace ' MiB').Trim(); $gpuMemoryGiB = [math]::Round([int]$gpuMemoryMiB / 1024)
Write-Log "GPU : $gpuName" -Color Green; Write-Log "VRAM : $gpuMemoryGiB GB" -Color Green
if ($gpuMemoryGiB -ge 24) { Write-Log "Recommandation: bf16/fp16 ou GGUF Q8_0." -Color Cyan } elseif ($gpuMemoryGiB -ge 16) { Write-Log "Recommandation: fp8 ou GGUF Q5_K_M." -Color Cyan } else { Write-Log "Recommandation: GGUF Q3_K_S." -Color Cyan }
}
} catch { Write-Log "Impossible de récupérer les informations GPU. Erreur: $($_.Exception.Message)" -Color Red }
} else { Write-Log "Aucun GPU NVIDIA detecte (nvidia-smi introuvable). Choisissez selon votre matériel." -Color Gray }
Write-Log "-------------------------------------------------------------------------------"
# --- Ask all questions ---
$baseChoice = Ask-Question "Do you want to download WAN base models?" @("A) bf16", "B) fp16", "C) fp8", "D) All", "E) No") @("A", "B", "C", "D", "E")
$ggufT2VChoice = Ask-Question "Do you want to download WAN text-to-video GGUF models?" @("A) Q8_0", "B) Q5_K_M", "C) Q3_K_S", "D) All", "E) No") @("A", "B", "C", "D", "E")
$gguf480Choice = Ask-Question "Do you want to download WAN image-to-video 480p GGUF models?" @("A) Q8_0", "B) Q5_K_M", "C) Q3_K_S", "D) All", "E) No") @("A", "B", "C", "D", "E")
$gguf720Choice = Ask-Question "Do you want to download WAN image-to-video 720p GGUF models?" @("A) Q8_0", "B) Q5_K_M", "C) Q3_K_S", "D) All", "E) No") @("A", "B", "C", "D", "E")
$controlChoice = Ask-Question "Do you want to download WAN FUN CONTROL base models?" @("A) bf16", "B) fp8", "C) All", "D) No") @("A", "B", "C", "D")
$controlGgufChoice = Ask-Question "Do you want to download WAN FUN CONTROL GGUF models?" @("A) Q8_0", "B) Q5_K_M", "C) Q3_K_S", "D) All", "E) No") @("A", "B", "C", "D", "E")
$vaceChoice = Ask-Question "Do you want to download WAN VACE base models?" @("A) fp16", "B) fp8", "C) All", "D) No") @("A", "B", "C", "D")
$vaceGgufChoice = Ask-Question "Do you want to download WAN VACE GGUF models?" @("A) Q8_0", "B) Q5_K_M", "C) Q4_K_S", "D) All", "E) No") @("A", "B", "C", "D", "E")
# --- Download files based on answers ---
Write-Log "`nStarting WAN model downloads..." -Color Cyan
$baseUrl = "https://huggingface.co/UmeAiRT/ComfyUI-Auto_installer/resolve/main/models"
$wanDiffDir = Join-Path $modelsPath "diffusion_models\WAN"; $wanUnetDir = Join-Path $modelsPath "unet\WAN"; $clipDir = Join-Path $modelsPath "clip"; $vaeDir = Join-Path $modelsPath "vae"
New-Item -Path $wanDiffDir, $wanUnetDir, $clipDir, $vaeDir -ItemType Directory -Force | Out-Null
$doDownload = ($baseChoice -ne 'E' -or $ggufT2VChoice -ne 'E' -or $gguf480Choice -ne 'E' -or $gguf720Choice -ne 'E' -or $controlChoice -ne 'D' -or $controlGgufChoice -ne 'E' -or $vaceChoice -ne 'D' -or $vaceGgufChoice -ne 'E')
if($doDownload) {
Download-File -Uri "$baseUrl/vae/wan_2.1_vae.safetensors" -OutFile (Join-Path $vaeDir "wan_2.1_vae.safetensors")
Download-File -Uri "$baseUrl/clip/umt5_xxl_fp8_e4m3fn_scaled.safetensors" -OutFile (Join-Path $clipDir "umt5_xxl_fp8_e4m3fn_scaled.safetensors")
}
if ($baseChoice -in 'A','D') { Download-File -Uri "$baseUrl/diffusion_models/WAN/wan2.1_t2v_14B_bf16.safetensors" -OutFile (Join-Path $wanDiffDir "wan2.1_t2v_14B_bf16.safetensors"); Download-File -Uri "$baseUrl/diffusion_models/WAN/wan2.1_t2v_1.3B_bf16.safetensors" -OutFile (Join-Path $wanDiffDir "wan2.1_t2v_1.3B_bf16.safetensors"); Download-File -Uri "$baseUrl/diffusion_models/WAN/wan2.1_i2v_720p_14B_bf16.safetensors" -OutFile (Join-Path $wanDiffDir "wan2.1_i2v_720p_14B_bf16.safetensors"); Download-File -Uri "$baseUrl/diffusion_models/WAN/wan2.1_i2v_480p_14B_bf16.safetensors" -OutFile (Join-Path $wanDiffDir "wan2.1_i2v_480p_14B_bf16.safetensors") }
if ($baseChoice -in 'B','D') { Download-File -Uri "$baseUrl/diffusion_models/WAN/wan2.1_t2v_14B_fp16.safetensors" -OutFile (Join-Path $wanDiffDir "wan2.1_t2v_14B_fp16.safetensors"); Download-File -Uri "$baseUrl/diffusion_models/WAN/wan2.1_t2v_1.3B_fp16.safetensors" -OutFile (Join-Path $wanDiffDir "wan2.1_t2v_1.3B_fp16.safetensors"); Download-File -Uri "$baseUrl/diffusion_models/WAN/wan2.1_i2v_720p_14B_fp16.safetensors" -OutFile (Join-Path $wanDiffDir "wan2.1_i2v_720p_14B_fp16.safetensors"); Download-File -Uri "$baseUrl/diffusion_models/WAN/wan2.1_i2v_480p_14B_fp16.safetensors" -OutFile (Join-Path $wanDiffDir "wan2.1_i2v_480p_14B_fp16.safetensors") }
if ($baseChoice -in 'C','D') { Download-File -Uri "$baseUrl/diffusion_models/WAN/wan2.1_t2v_14B_fp8_e4m3fn.safetensors" -OutFile (Join-Path $wanDiffDir "wan2.1_t2v_14B_fp8_e4m3fn.safetensors"); Download-File -Uri "$baseUrl/diffusion_models/WAN/wan2.1_t2v_1.3B_fp8_e4m3fn.safetensors" -OutFile (Join-Path $wanDiffDir "wan2.1_t2v_1.3B_fp8_e4m3fn.safetensors"); Download-File -Uri "$baseUrl/diffusion_models/WAN/wan2.1_i2v_720p_14B_fp8_e4m3fn.safetensors" -OutFile (Join-Path $wanDiffDir "wan2.1_i2v_720p_14B_fp8_e4m3fn.safetensors"); Download-File -Uri "$baseUrl/diffusion_models/WAN/wan2.1_i2v_480p_14B_fp8_e4m3fn.safetensors" -OutFile (Join-Path $wanDiffDir "wan2.1_i2v_480p_14B_fp8_e4m3fn.safetensors") }
if ($ggufT2VChoice -in 'A','D') { Download-File -Uri "$baseUrl/unet/WAN/wan2.1-t2v-14b-Q8_0.gguf" -OutFile (Join-Path $wanUnetDir "wan2.1-t2v-14b-Q8_0.gguf") }
if ($ggufT2VChoice -in 'B','D') { Download-File -Uri "$baseUrl/unet/WAN/wan2.1-t2v-14b-Q5_K_M.gguf" -OutFile (Join-Path $wanUnetDir "wan2.1-t2v-14b-Q5_K_M.gguf") }
if ($ggufT2VChoice -in 'C','D') { Download-File -Uri "$baseUrl/unet/WAN/wan2.1-t2v-14b-Q3_K_S.gguf" -OutFile (Join-Path $wanUnetDir "wan2.1-t2v-14b-Q3_K_S.gguf") }
if ($gguf480Choice -in 'A','D') { Download-File -Uri "$baseUrl/unet/WAN/wan2.1-i2v-14b-480p-Q8_0.gguf" -OutFile (Join-Path $wanUnetDir "wan2.1-i2v-14b-480p-Q8_0.gguf") }
if ($gguf480Choice -in 'B','D') { Download-File -Uri "$baseUrl/unet/WAN/wan2.1-i2v-14b-480p-Q5_K_M.gguf" -OutFile (Join-Path $wanUnetDir "wan2.1-i2v-14b-480p-Q5_K_M.gguf") }
if ($gguf480Choice -in 'C','D') { Download-File -Uri "$baseUrl/unet/WAN/wan2.1-i2v-14b-480p-Q3_K_S.gguf" -OutFile (Join-Path $wanUnetDir "wan2.1-i2v-14b-480p-Q3_K_S.gguf") }
if ($gguf720Choice -in 'A','D') { Download-File -Uri "$baseUrl/unet/WAN/wan2.1-i2v-14b-720p-Q8_0.gguf" -OutFile (Join-Path $wanUnetDir "wan2.1-i2v-14b-720p-Q8_0.gguf") }
if ($gguf720Choice -in 'B','D') { Download-File -Uri "$baseUrl/unet/WAN/wan2.1-i2v-14b-720p-Q5_K_M.gguf" -OutFile (Join-Path $wanUnetDir "wan2.1-i2v-14b-720p-Q5_K_M.gguf") }
if ($gguf720Choice -in 'C','D') { Download-File -Uri "$baseUrl/unet/WAN/wan2.1-i2v-14b-720p-Q3_K_S.gguf" -OutFile (Join-Path $wanUnetDir "wan2.1-i2v-14b-720p-Q3_K_S.gguf") }
if ($controlChoice -in 'A','C') { Download-File -Uri "$baseUrl/diffusion_models/WAN/wan2.1-fun-14B-control.safetensors" -OutFile (Join-Path $wanDiffDir "wan2.1-fun-14B-control.safetensors") }
if ($controlChoice -in 'B','C') { Download-File -Uri "https://huggingface.co/TFMC/Wan2.1-Fun-V1.1-14B-InP-FP8/resolve/main/Wan2.1-Fun-V1_1-InP-14B_fp8_e4m3fn.safetensors" -OutFile (Join-Path $wanDiffDir "Wan2.1-Fun-V1_1-InP-14B_fp8_e4m3fn.safetensors") }
if ($controlGgufChoice -in 'A','D') { Download-File -Uri "$baseUrl/unet/WAN/wan2.1-fun-14b-control-Q8_0.gguf" -OutFile (Join-Path $wanUnetDir "wan2.1-fun-14b-control-Q8_0.gguf") }
if ($controlGgufChoice -in 'B','D') { Download-File -Uri "$baseUrl/unet/WAN/wan2.1-fun-14b-control-Q5_K_M.gguf" -OutFile (Join-Path $wanUnetDir "wan2.1-fun-14b-control-Q5_K_M.gguf") }
if ($controlGgufChoice -in 'C','D') { Download-File -Uri "$baseUrl/unet/WAN/wan2.1-fun-14b-control-Q3_K_S.gguf" -OutFile (Join-Path $wanUnetDir "wan2.1-fun-14b-control-Q3_K_S.gguf") }
if ($vaceChoice -in 'A','C') { Download-File -Uri "$baseUrl/diffusion_models/WAN/wan2.1_vace_14B_fp16.safetensors" -OutFile (Join-Path $wanDiffDir "wan2.1_vace_14B_fp16.safetensors") }
if ($vaceChoice -in 'B','C') { Download-File -Uri "https://huggingface.co/Kamikaze-88/Wan2.1-VACE-14B-fp8/resolve/main/wan2.1_vace_14B_fp8_e4m3fn.safetensors" -OutFile (Join-Path $wanDiffDir "wan2.1_vace_14B_fp8_e4m3fn.safetensors") }
if ($vaceGgufChoice -in 'A','D') { Download-File -Uri "$baseUrl/unet/WAN/Wan2.1-VACE-14B-Q8_0.gguf" -OutFile (Join-Path $wanUnetDir "Wan2.1-VACE-14B-Q8_0.gguf") }
if ($vaceGgufChoice -in 'B','D') { Download-File -Uri "$baseUrl/unet/WAN/Wan2.1-VACE-14B-Q5_K_S.gguf" -OutFile (Join-Path $wanUnetDir "Wan2.1-VACE-14B-Q5_K_S.gguf") }
if ($vaceGgufChoice -in 'C','D') { Download-File -Uri "$baseUrl/unet/WAN/Wan2.1-VACE-14B-Q4_K_S.gguf" -OutFile (Join-Path $wanUnetDir "Wan2.1-VACE-14B-Q4_K_S.gguf") }
Write-Log "`nWAN model downloads complete." -Color Green
Read-Host "Press Enter to return to the main installer." |