Upload Download-FLUX-Models.ps1
Browse files
scripts/Model_downloader/Download-FLUX-Models.ps1
CHANGED
@@ -8,7 +8,8 @@ param(
|
|
8 |
.SYNOPSIS
|
9 |
A fully refactored and corrected PowerShell script to interactively download FLUX models for ComfyUI.
|
10 |
.DESCRIPTION
|
11 |
-
This version corrects
|
|
|
12 |
#>
|
13 |
|
14 |
#===========================================================================
|
@@ -16,15 +17,17 @@ param(
|
|
16 |
#===========================================================================
|
17 |
function Write-Log {
|
18 |
param([string]$Message, [string]$Color = "White")
|
19 |
-
|
|
|
20 |
$formattedMessage = "[$([DateTime]::Now.ToString('yyyy-MM-dd HH:mm:ss'))] [ModelDownloader] $Message"
|
21 |
Write-Host $Message -ForegroundColor $Color
|
22 |
-
Add-Content -Path $logFile -Value $formattedMessage
|
23 |
}
|
24 |
|
25 |
function Invoke-AndLog {
|
26 |
param([string]$File, [string]$Arguments)
|
27 |
-
$
|
|
|
28 |
$commandToRun = "`"$File`" $Arguments"
|
29 |
$cmdArguments = "/C `"$commandToRun >> `"`"$logFile`"`" 2>&1`""
|
30 |
try {
|
@@ -67,7 +70,6 @@ function Ask-Question {
|
|
67 |
return $choice
|
68 |
}
|
69 |
|
70 |
-
|
71 |
#===========================================================================
|
72 |
# SECTION 2: SCRIPT EXECUTION
|
73 |
#===========================================================================
|
@@ -88,7 +90,40 @@ if (-not (Test-Path $modelsPath)) {
|
|
88 |
# --- GPU Detection ---
|
89 |
Write-Log "-------------------------------------------------------------------------------"
|
90 |
Write-Log "Checking for NVIDIA GPU to provide model recommendations..." -Color Yellow
|
91 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
92 |
Write-Log "-------------------------------------------------------------------------------"
|
93 |
|
94 |
# --- Ask all questions first ---
|
@@ -99,13 +134,10 @@ $controlnetChoice = Ask-Question -Prompt "Do you want to download FLUX ControlNe
|
|
99 |
$pulidChoice = Ask-Question -Prompt "Do you want to download FLUX PuLID and REDUX Models?" -Choices @("A) Yes", "B) No") -ValidAnswers @("A", "B")
|
100 |
$loraChoice = Ask-Question -Prompt "Do you want to download UmeAiRT LoRAs?" -Choices @("A) Yes", "B) No") -ValidAnswers @("A", "B")
|
101 |
|
102 |
-
|
103 |
-
# ===========================================================================
|
104 |
-
# === SECTION DE TÉLÉCHARGEMENT CORRIGÉE ===
|
105 |
-
# ===========================================================================
|
106 |
Write-Log "`nStarting downloads based on your choices..." -Color Cyan
|
107 |
|
108 |
-
#
|
109 |
$baseUrl = "https://huggingface.co/UmeAiRT/ComfyUI-Auto_installer/resolve/main/models"
|
110 |
$fluxDir = Join-Path $modelsPath "diffusion_models\FLUX"
|
111 |
$clipDir = Join-Path $modelsPath "clip"
|
@@ -116,7 +148,7 @@ $pulidDir = Join-Path $modelsPath "pulid"
|
|
116 |
$styleDir = Join-Path $modelsPath "style_models"
|
117 |
$loraDir = Join-Path $modelsPath "loras\FLUX"
|
118 |
|
119 |
-
#
|
120 |
$requiredDirs = @($fluxDir, $clipDir, $vaeDir, $unetFluxDir, $controlnetDir, $pulidDir, $styleDir, $loraDir)
|
121 |
foreach ($dir in $requiredDirs) {
|
122 |
if (-not (Test-Path $dir)) {
|
@@ -124,10 +156,11 @@ foreach ($dir in $requiredDirs) {
|
|
124 |
}
|
125 |
}
|
126 |
|
127 |
-
#
|
|
|
128 |
|
129 |
-
|
130 |
-
|
131 |
Download-File -Uri "$baseUrl/vae/ae.safetensors" -OutFile (Join-Path $vaeDir "ae.safetensors")
|
132 |
Download-File -Uri "$baseUrl/clip/clip_l.safetensors" -OutFile (Join-Path $clipDir "clip_l.safetensors")
|
133 |
}
|
@@ -157,7 +190,7 @@ if ($schnellChoice -eq 'A') {
|
|
157 |
|
158 |
# ControlNet Models
|
159 |
if ($controlnetChoice -ne 'G') {
|
160 |
-
if ($controlnetChoice -in 'A','B','F') {
|
161 |
Download-File -Uri "$baseUrl/xlabs/controlnets/flux-canny-controlnet-v3.safetensors" -OutFile (Join-Path $controlnetDir "flux-canny-controlnet-v3.safetensors")
|
162 |
Download-File -Uri "$baseUrl/xlabs/controlnets/flux-depth-controlnet-v3.safetensors" -OutFile (Join-Path $controlnetDir "flux-depth-controlnet-v3.safetensors")
|
163 |
}
|
|
|
8 |
.SYNOPSIS
|
9 |
A fully refactored and corrected PowerShell script to interactively download FLUX models for ComfyUI.
|
10 |
.DESCRIPTION
|
11 |
+
This version corrects logging paths when called from a parent script, fixes all download logic,
|
12 |
+
and provides user guidance based on GPU VRAM.
|
13 |
#>
|
14 |
|
15 |
#===========================================================================
|
|
|
17 |
#===========================================================================
|
18 |
function Write-Log {
|
19 |
param([string]$Message, [string]$Color = "White")
|
20 |
+
# Utilise $InstallPath (passé en argument) pour trouver le bon dossier de logs
|
21 |
+
$logFile = Join-Path $InstallPath "logs\install_log.txt"
|
22 |
$formattedMessage = "[$([DateTime]::Now.ToString('yyyy-MM-dd HH:mm:ss'))] [ModelDownloader] $Message"
|
23 |
Write-Host $Message -ForegroundColor $Color
|
24 |
+
Add-Content -Path $logFile -Value $formattedMessage -ErrorAction SilentlyContinue
|
25 |
}
|
26 |
|
27 |
function Invoke-AndLog {
|
28 |
param([string]$File, [string]$Arguments)
|
29 |
+
# Utilise $InstallPath pour trouver le bon dossier de logs
|
30 |
+
$logFile = Join-Path $InstallPath "logs\install_log.txt"
|
31 |
$commandToRun = "`"$File`" $Arguments"
|
32 |
$cmdArguments = "/C `"$commandToRun >> `"`"$logFile`"`" 2>&1`""
|
33 |
try {
|
|
|
70 |
return $choice
|
71 |
}
|
72 |
|
|
|
73 |
#===========================================================================
|
74 |
# SECTION 2: SCRIPT EXECUTION
|
75 |
#===========================================================================
|
|
|
90 |
# --- GPU Detection ---
|
91 |
Write-Log "-------------------------------------------------------------------------------"
|
92 |
Write-Log "Checking for NVIDIA GPU to provide model recommendations..." -Color Yellow
|
93 |
+
if (Get-Command 'nvidia-smi' -ErrorAction SilentlyContinue) {
|
94 |
+
try {
|
95 |
+
$gpuInfoCsv = nvidia-smi --query-gpu=name,memory.total --format=csv,noheader
|
96 |
+
if ($gpuInfoCsv) {
|
97 |
+
$gpuInfoParts = $gpuInfoCsv.Split(',')
|
98 |
+
$gpuName = $gpuInfoParts[0].Trim()
|
99 |
+
$gpuMemoryMiB = ($gpuInfoParts[1] -replace ' MiB').Trim()
|
100 |
+
$gpuMemoryGiB = [math]::Round([int]$gpuMemoryMiB / 1024)
|
101 |
+
|
102 |
+
Write-Log "GPU : $gpuName" -Color Green
|
103 |
+
Write-Log "VRAM : $gpuMemoryGiB GB" -Color Green
|
104 |
+
|
105 |
+
if ($gpuMemoryGiB -ge 30) {
|
106 |
+
Write-Log "Recommandation: fp16" -Color Cyan
|
107 |
+
} elseif ($gpuMemoryGiB -ge 18) {
|
108 |
+
Write-Log "Recommandation: fp8 or GGUF Q8" -Color Cyan
|
109 |
+
} elseif ($gpuMemoryGiB -ge 14) {
|
110 |
+
Write-Log "Recommandation: GGUF Q6" -Color Cyan
|
111 |
+
}elseif ($gpuMemoryGiB -ge 12) {
|
112 |
+
Write-Log "Recommandation: GGUF Q5" -Color Cyan
|
113 |
+
}elseif ($gpuMemoryGiB -ge 10) {
|
114 |
+
Write-Log "Recommandation: GGUF Q4" -Color Cyan
|
115 |
+
}elseif ($gpuMemoryGiB -ge 8) {
|
116 |
+
Write-Log "Recommandation: GGUF Q3" -Color Cyan
|
117 |
+
}else {
|
118 |
+
Write-Log "Recommandation: GGUF Q2" -Color Cyan
|
119 |
+
}
|
120 |
+
}
|
121 |
+
} catch {
|
122 |
+
Write-Log "Impossible de récupérer les informations GPU. Erreur: $($_.Exception.Message)" -Color Red
|
123 |
+
}
|
124 |
+
} else {
|
125 |
+
Write-Log "Aucun GPU NVIDIA detecte (nvidia-smi introuvable). Choisissez selon votre matériel." -Color Gray
|
126 |
+
}
|
127 |
Write-Log "-------------------------------------------------------------------------------"
|
128 |
|
129 |
# --- Ask all questions first ---
|
|
|
134 |
$pulidChoice = Ask-Question -Prompt "Do you want to download FLUX PuLID and REDUX Models?" -Choices @("A) Yes", "B) No") -ValidAnswers @("A", "B")
|
135 |
$loraChoice = Ask-Question -Prompt "Do you want to download UmeAiRT LoRAs?" -Choices @("A) Yes", "B) No") -ValidAnswers @("A", "B")
|
136 |
|
137 |
+
# --- Download files based on answers ---
|
|
|
|
|
|
|
138 |
Write-Log "`nStarting downloads based on your choices..." -Color Cyan
|
139 |
|
140 |
+
# Définir tous les chemins une seule fois
|
141 |
$baseUrl = "https://huggingface.co/UmeAiRT/ComfyUI-Auto_installer/resolve/main/models"
|
142 |
$fluxDir = Join-Path $modelsPath "diffusion_models\FLUX"
|
143 |
$clipDir = Join-Path $modelsPath "clip"
|
|
|
148 |
$styleDir = Join-Path $modelsPath "style_models"
|
149 |
$loraDir = Join-Path $modelsPath "loras\FLUX"
|
150 |
|
151 |
+
# Créer tous les dossiers nécessaires en une seule fois
|
152 |
$requiredDirs = @($fluxDir, $clipDir, $vaeDir, $unetFluxDir, $controlnetDir, $pulidDir, $styleDir, $loraDir)
|
153 |
foreach ($dir in $requiredDirs) {
|
154 |
if (-not (Test-Path $dir)) {
|
|
|
156 |
}
|
157 |
}
|
158 |
|
159 |
+
# Vérifier si un téléchargement est nécessaire pour télécharger les fichiers communs
|
160 |
+
$doDownload = ($fluxChoice -ne 'D' -or $ggufChoice -ne 'H' -or $schnellChoice -eq 'A' -or $controlnetChoice -ne 'G' -or $pulidChoice -eq 'A' -or $loraChoice -eq 'A')
|
161 |
|
162 |
+
if ($doDownload) {
|
163 |
+
Write-Log "`nDownloading common support models (VAE, CLIP)..."
|
164 |
Download-File -Uri "$baseUrl/vae/ae.safetensors" -OutFile (Join-Path $vaeDir "ae.safetensors")
|
165 |
Download-File -Uri "$baseUrl/clip/clip_l.safetensors" -OutFile (Join-Path $clipDir "clip_l.safetensors")
|
166 |
}
|
|
|
190 |
|
191 |
# ControlNet Models
|
192 |
if ($controlnetChoice -ne 'G') {
|
193 |
+
if ($controlnetChoice -in 'A','B','F') {
|
194 |
Download-File -Uri "$baseUrl/xlabs/controlnets/flux-canny-controlnet-v3.safetensors" -OutFile (Join-Path $controlnetDir "flux-canny-controlnet-v3.safetensors")
|
195 |
Download-File -Uri "$baseUrl/xlabs/controlnets/flux-depth-controlnet-v3.safetensors" -OutFile (Join-Path $controlnetDir "flux-depth-controlnet-v3.safetensors")
|
196 |
}
|