UmeAiRT commited on
Commit
478691d
·
verified ·
1 Parent(s): 1f695c4

Upload Download-WAN-Models.ps1

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