UmeAiRT commited on
Commit
8d6d7c0
·
verified ·
1 Parent(s): 42a2c3a

Upload Install-ComfyUI.ps1

Browse files
Files changed (1) hide show
  1. scripts/ComfyUI/Install-ComfyUI.ps1 +384 -0
scripts/ComfyUI/Install-ComfyUI.ps1 ADDED
@@ -0,0 +1,384 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #Requires -RunAsAdministrator
2
+
3
+ <#
4
+ .SYNOPSIS
5
+ A complete, all-in-one installer for ComfyUI and its environment.
6
+ .DESCRIPTION
7
+ This single, robust script handles everything:
8
+ - Sets the required TLS 1.2 security protocol.
9
+ - Directly installs the Aria2 binary for accelerated downloads.
10
+ - Installs Git and 7-Zip if they are missing.
11
+ - Downloads and extracts the latest portable version of ComfyUI.
12
+ - Installs a comprehensive list of custom nodes and their Python dependencies.
13
+ It is designed to be fully compatible with PowerShell 5.1 (standard on Windows 10).
14
+ .NOTES
15
+ Author: Code Partner (based on original scripts and user feedback)
16
+ Version: 4.1 (Compatibility Fix)
17
+ #>
18
+
19
+ #===========================================================================
20
+ # SECTION 1: SCRIPT CONFIGURATION & HELPER FUNCTIONS
21
+ #===========================================================================
22
+
23
+ # --- Force TLS 1.2 for all web requests (Crucial Fix) ---
24
+ [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
25
+
26
+ # --- Path & Log Variables ---
27
+ $installPath = $PSScriptRoot
28
+ $basePath = Join-Path $installPath "ComfyUI_windows_portable"
29
+ $comfyPath = Join-Path $basePath "ComfyUI"
30
+ $pythonExecutable = Join-Path $basePath "python_embeded\python.exe"
31
+ $customNodesPath = Join-Path $comfyPath "custom_nodes"
32
+ $logPath = Join-Path $installPath "logs"
33
+ $logFile = Join-Path $logPath "install_log.txt"
34
+ $sevenZipPath = "C:\Program Files\7-Zip\7z.exe" # Default path
35
+
36
+ # --- Create Log Directory ---
37
+ if (-not (Test-Path $logPath)) {
38
+ New-Item -ItemType Directory -Force -Path $logPath | Out-Null
39
+ }
40
+
41
+ # --- Helper function to write to console and log file ---
42
+ function Write-Log {
43
+ param([string]$Message, [string]$Color = "White")
44
+ $timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
45
+ $formattedMessage = "[$timestamp] $Message"
46
+ Write-Host $Message -ForegroundColor $Color
47
+ Add-Content -Path $logFile -Value $formattedMessage
48
+ }
49
+
50
+ # --- Helper function to execute a command and log its output (VERSION-COMPATIBLE) ---
51
+ function Invoke-AndLog {
52
+ param(
53
+ [string]$File,
54
+ [string]$Arguments
55
+ )
56
+ # This method is compatible with all PowerShell versions, including 5.1.
57
+ # It uses cmd.exe to run the command and handle output redirection.
58
+ # The structure is: cmd /c "full command >> "path/to/log.txt" 2>&1"
59
+ $commandToRun = "`"$File`" $Arguments"
60
+ $cmdArguments = "/C `"$commandToRun >> `"`"$logFile`"`" 2>&1`""
61
+
62
+ try {
63
+ Start-Process -FilePath "cmd.exe" -ArgumentList $cmdArguments -Wait -WindowStyle Hidden
64
+ } catch {
65
+ Write-Log "FATAL ERROR trying to execute command: $commandToRun" -Color Red
66
+ }
67
+ }
68
+
69
+ # --- Function to install the aria2 binary directly ---
70
+ function Install-Aria2-Binary {
71
+ Write-Log "--- Starting Aria2 binary installation ---" -Color Magenta
72
+ $destFolder = "C:\Tools\aria2"
73
+ if (-not (Test-Path $destFolder)) { New-Item -ItemType Directory -Force -Path $destFolder | Out-Null }
74
+
75
+ $aria2Url = "https://github.com/aria2/aria2/releases/download/release-1.36.0/aria2-1.36.0-win-64bit-build1.zip"
76
+ $zipPath = Join-Path $env:TEMP "aria2_temp.zip"
77
+ Write-Log "Downloading aria2 from $aria2Url..."
78
+ Invoke-WebRequest -Uri $aria2Url -OutFile $zipPath
79
+
80
+ Write-Log "Extracting zip file to $destFolder..."
81
+ Expand-Archive -Path $zipPath -DestinationPath $destFolder -Force
82
+
83
+ $extractedSubfolder = Join-Path $destFolder "aria2-1.36.0-win-64bit-build1"
84
+ if (Test-Path $extractedSubfolder) {
85
+ Move-Item -Path (Join-Path $extractedSubfolder "*") -Destination $destFolder -Force
86
+ Remove-Item -Path $extractedSubfolder -Recurse -Force
87
+ }
88
+
89
+ $configFile = Join-Path $destFolder "aria2.conf"
90
+ $configContent = "continue=true`nmax-connection-per-server=16`nsplit=16`nmin-split-size=1M`nfile-allocation=none"
91
+ $configContent | Out-File $configFile -Encoding UTF8
92
+
93
+ $envScope = "User"
94
+ $oldPath = [System.Environment]::GetEnvironmentVariable("Path", $envScope)
95
+ if ($oldPath -notlike "*$destFolder*") {
96
+ Write-Log "Adding '$destFolder' to user PATH..."
97
+ $newPath = $oldPath + ";$destFolder"
98
+ [System.Environment]::SetEnvironmentVariable("Path", $newPath, $envScope)
99
+ $env:Path = $newPath
100
+ Write-Log "PATH updated. Aria2 will be available immediately."
101
+ }
102
+ Write-Log "--- Aria2 binary installation complete ---" -Color Magenta
103
+ }
104
+
105
+
106
+ # --- Smart Download Function with fallback ---
107
+ function Download-File {
108
+ param(
109
+ [string]$Uri,
110
+ [string]$OutFile
111
+ )
112
+ # Extrait juste le nom du fichier de l'URL pour un affichage plus propre
113
+ $fileName = Split-Path -Path $Uri -Leaf
114
+
115
+ if (Get-Command 'aria2c' -ErrorAction SilentlyContinue) {
116
+ Write-Log " - Downloading $fileName"
117
+ $aria_args = "-c -x 16 -s 16 -k 1M --dir=`"$((Split-Path $OutFile -Parent))`" --out=`"$((Split-Path $OutFile -Leaf))`" `"$Uri`""
118
+ Invoke-AndLog "aria2c" $aria_args
119
+ } else {
120
+ Write-Log "Aria2 not found. Falling back to standard download: $fileName" -Color Yellow
121
+ Invoke-WebRequest -Uri $Uri -OutFile $OutFile
122
+ }
123
+ }
124
+
125
+
126
+ #===========================================================================
127
+ # SECTION 2: MAIN SCRIPT EXECUTION
128
+ #===========================================================================
129
+
130
+ Clear-Host
131
+ # --- Banner ---
132
+ # The ASCII art is now embedded directly in the script for simplicity and reliability.
133
+ Write-Log "-------------------------------------------------------------------------------"
134
+ $asciiBanner = @'
135
+ __ __ ___ _ ____ ______
136
+ / / / /___ ___ ___ / | (_) __ \/_ __/
137
+ / / / / __ `__ \/ _ \/ /| | / / /_/ / / /
138
+ / /_/ / / / / / / __/ ___ |/ / _, _/ / /
139
+ \____/_/ /_/ /_/\___/_/ |_/_/_/ |_| /_/
140
+ '@
141
+ Write-Host $asciiBanner -ForegroundColor Cyan
142
+ Write-Log "-------------------------------------------------------------------------------"
143
+ Write-Log " ComfyUI - All-in-One Installer " -Color Yellow
144
+ Write-Log " Version 3.0 " -Color White
145
+ Write-Log "-------------------------------------------------------------------------------"
146
+
147
+ # --- Step 1: Install Dependencies (Aria2, 7-Zip, Git) ---
148
+ Write-Log "Step 1: Checking for required tools..." -Color Yellow
149
+
150
+ # Aria2
151
+ if (-not (Get-Command 'aria2c' -ErrorAction SilentlyContinue)) {
152
+ Write-Log "Aria2 not found. Proceeding with direct installation."
153
+ Install-Aria2-Binary
154
+ } else {
155
+ Write-Log "Aria2 is already installed." -Color Green
156
+ }
157
+
158
+ # 7-Zip
159
+ if (-not (Test-Path $sevenZipPath)) {
160
+ Write-Log "7-Zip not found. Downloading and installing..."
161
+ $sevenZipInstaller = Join-Path $env:TEMP "7z-installer.exe"
162
+ Download-File -Uri "https://www.7-zip.org/a/7z2201-x64.exe" -OutFile $sevenZipInstaller
163
+ Start-Process -FilePath $sevenZipInstaller -ArgumentList "/S" -Wait
164
+ Remove-Item $sevenZipInstaller
165
+ } else {
166
+ Write-Log "7-Zip is already installed." -Color Green
167
+ }
168
+
169
+ # Git
170
+ if (-not (Get-Command git.exe -ErrorAction SilentlyContinue)) {
171
+ Write-Log "Git not found. Downloading and installing..."
172
+ $gitInstaller = Join-Path $env:TEMP "Git-Installer.exe"
173
+ Download-File -Uri "https://github.com/git-for-windows/git/releases/download/v2.41.0.windows.3/Git-2.41.0.3-64-bit.exe" -OutFile $gitInstaller
174
+ Start-Process -FilePath $gitInstaller -ArgumentList "/VERYSILENT" -Wait
175
+ Remove-Item $gitInstaller
176
+ }
177
+ Invoke-AndLog "git" "config --system core.longpaths true"
178
+ Write-Log "Git is ready." -Color Green
179
+
180
+ # --- Step 2: Download and Extract ComfyUI ---
181
+ Write-Log "`nStep 2: Downloading and setting up ComfyUI..." -Color Yellow
182
+ if (-not (Test-Path $basePath)) {
183
+ $comfyArchive = Join-Path $installPath "ComfyUI_windows_portable_nvidia.7z"
184
+ Download-File -Uri "https://github.com/comfyanonymous/ComfyUI/releases/download/v0.3.43/ComfyUI_windows_portable_nvidia.7z" -OutFile $comfyArchive
185
+ Write-Log " - Extracting ComfyUI..."
186
+ Invoke-AndLog "$sevenZipPath" "x `"$comfyArchive`" -o`"$installPath`" -y"
187
+ Remove-Item $comfyArchive
188
+ } else {
189
+ Write-Log "ComfyUI folder already exists. Skipping download." -Color Green
190
+ }
191
+
192
+ # --- Step 3: Update ComfyUI and Install Custom Nodes ---
193
+ Write-Log "`nStep 3: Updating ComfyUI and installing custom nodes..." -Color Yellow
194
+ # Update pip and ComfyUI itself
195
+ Invoke-AndLog "$pythonExecutable" "-m pip install --upgrade pip"
196
+ Invoke-AndLog "$pythonExecutable" "`"$basePath\update\update.py`" `"$comfyPath`""
197
+ Invoke-AndLog "$pythonExecutable" "-s -m pip install -r `"$comfyPath\requirements.txt`""
198
+ # Install special Python dependencies
199
+ Write-Log " - Installing special Python dependencies" -Color White
200
+ Invoke-AndLog "$pythonExecutable" "-s -m pip install ultralytics --no-warn-script-location"
201
+ $insightfaceWheel = Join-Path $basePath "python_embeded\insightface-0.7.3-cp312-cp312-win_amd64.whl"
202
+ Download-File -Uri "https://huggingface.co/UmeAiRT/ComfyUI-Auto_installer/resolve/main/whl/insightface-0.7.3-cp312-cp312-win_amd64.whl" -OutFile $insightfaceWheel
203
+ Invoke-AndLog "$pythonExecutable" "-m pip install --use-pep517 facexlib"
204
+ Invoke-AndLog "$pythonExecutable" "-m pip install git+https://github.com/rodjjo/filterpy.git"
205
+ Invoke-AndLog "$pythonExecutable" "-m pip install onnxruntime==1.19.2 onnxruntime-gpu==1.17.1"
206
+ Invoke-AndLog "$pythonExecutable" "-s -m pip install $insightfaceWheel --no-warn-script-location"
207
+
208
+ # Define all custom nodes in one place
209
+ $customNodes = @(
210
+ @{Name="ComfyUI-Manager"; Repo="https://github.com/ltdrdata/ComfyUI-Manager.git"; HasRequirements=$false},
211
+ @{Name="ComfyUI-Impact-Pack"; Repo="https://github.com/ltdrdata/ComfyUI-Impact-Pack"; HasRequirements=$true},
212
+ @{Name="ComfyUI-Impact-Subpack"; Repo="https://github.com/ltdrdata/ComfyUI-Impact-Subpack"; Subfolder="ComfyUI-Impact-Pack/impact_subpack"; HasRequirements=$true},
213
+ @{Name="ComfyUI-GGUF"; Repo="https://github.com/city96/ComfyUI-GGUF"; HasRequirements=$true},
214
+ @{Name="ComfyUI-mxToolkit"; Repo="https://github.com/Smirnov75/ComfyUI-mxToolkit"; HasRequirements=$false},
215
+ @{Name="ComfyUI-Custom-Scripts"; Repo="https://github.com/pythongosssss/ComfyUI-Custom-Scripts"; HasRequirements=$false},
216
+ @{Name="ComfyUI-KJNodes"; Repo="https://github.com/kijai/ComfyUI-KJNodes"; HasRequirements=$true},
217
+ @{Name="ComfyUI-WanVideoWrapper"; Repo="https://github.com/kijai/ComfyUI-WanVideoWrapper"; HasRequirements=$true},
218
+ @{Name="ComfyUI-VideoHelperSuite"; Repo="https://github.com/Kosinkadink/ComfyUI-VideoHelperSuite"; HasRequirements=$true},
219
+ @{Name="ComfyUI-Frame-Interpolation"; Repo="https://github.com/Fannovel16/ComfyUI-Frame-Interpolation"; RequirementsFile="requirements-with-cupy.txt"; HasRequirements=$true},
220
+ @{Name="rgthree-comfy"; Repo="https://github.com/rgthree/rgthree-comfy"; HasRequirements=$true},
221
+ @{Name="ComfyUI-Easy-Use"; Repo="https://github.com/yolain/ComfyUI-Easy-Use"; HasRequirements=$true},
222
+ @{Name="ComfyUI_PuLID_Flux_ll"; Repo="https://github.com/lldacing/ComfyUI_PuLID_Flux_ll"; HasRequirements=$true},
223
+ @{Name="ComfyUI-HunyuanVideoMultiLora"; Repo="https://github.com/facok/ComfyUI-HunyuanVideoMultiLora"; HasRequirements=$false},
224
+ @{Name="was-node-suite-comfyui"; Repo="https://github.com/WASasquatch/was-node-suite-comfyui"; HasRequirements=$true},
225
+ @{Name="ComfyUI-Florence2"; Repo="https://github.com/kijai/ComfyUI-Florence2"; HasRequirements=$true},
226
+ @{Name="ComfyUI-MultiGPU"; Repo="https://github.com/pollockjj/ComfyUI-MultiGPU"; HasRequirements=$false},
227
+ @{Name="ComfyUI-WanStartEndFramesNative"; Repo="https://github.com/Flow-two/ComfyUI-WanStartEndFramesNative"; HasRequirements=$false},
228
+ @{Name="ComfyUI-Image-Saver"; Repo="https://github.com/alexopus/ComfyUI-Image-Saver"; HasRequirements=$true},
229
+ @{Name="ComfyUI_UltimateSDUpscale"; Repo="https://github.com/ssitu/ComfyUI_UltimateSDUpscale"; HasRequirements=$false},
230
+ @{Name="comfyui_controlnet_aux"; Repo="https://github.com/Fannovel16/comfyui_controlnet_aux"; HasRequirements=$true},
231
+ @{Name="x-flux-comfyui"; Repo="https://github.com/XLabs-AI/x-flux-comfyui"; HasRequirements=$true},
232
+ @{Name="ComfyUI-RMBG"; Repo="https://github.com/1038lab/ComfyUI-RMBG"; HasRequirements=$true},
233
+ @{Name="ComfyUI-Detail-Daemon"; Repo="https://github.com/Jonseed/ComfyUI-Detail-Daemon"; HasRequirements=$true},
234
+ @{Name="ComfyUI-TeaCache"; Repo="https://github.com/welltop-cn/ComfyUI-TeaCache"; HasRequirements=$true},
235
+ @{Name="ComfyUI-Crystools"; Repo="https://github.com/crystian/ComfyUI-Crystools"; HasRequirements=$true}
236
+ )
237
+
238
+ # Loop through and install each custom node
239
+ foreach ($node in $customNodes) {
240
+ $nodePath = if ($node.Subfolder) { Join-Path $customNodesPath $node.Subfolder } else { Join-Path $customNodesPath $node.Name }
241
+
242
+ if (-not (Test-Path $nodePath)) {
243
+ Write-Log " - Installing $($node.Name)..."
244
+ # For sub-repositories, clone into the parent directory
245
+ $cloneTargetPath = if ($node.Subfolder) { (Split-Path $nodePath -Parent) } else { $nodePath }
246
+ # Special case for subpack which needs a specific final directory name
247
+ $finalDirName = if ($node.Name -eq 'ComfyUI-Impact-Subpack') { 'impact_subpack' } else { $node.Name }
248
+ $cloneCommand = "clone $($node.Repo) `"$((Join-Path (Split-Path $cloneTargetPath -Parent) $finalDirName))`""
249
+
250
+ Invoke-AndLog "git" "clone $($node.Repo) `"$cloneTargetPath`""
251
+
252
+ if ($node.HasRequirements) {
253
+ $requirementsFile = if ($node.RequirementsFile) { $node.RequirementsFile } else { "requirements.txt" }
254
+ $reqPath = Join-Path $nodePath $requirementsFile
255
+ if (Test-Path $reqPath) {
256
+ Invoke-AndLog "$pythonExecutable" "-s -m pip install -r `"$reqPath`" --no-warn-script-location"
257
+ }
258
+ }
259
+ } else {
260
+ Write-Log " - $($node.Name) (already exists, skipping)" -Color Green
261
+ }
262
+ }
263
+
264
+ # Install supplementary performance modules
265
+ Write-Log "`nStep 4: Installing supplementary performance modules..." -Color Yellow
266
+
267
+ # Triton
268
+ Write-Log " - Installing Triton..."
269
+ $tritonWheel = Join-Path $basePath "python_embeded\triton-3.3.0-py3-none-any.whl"
270
+ Download-File -Uri "https://github.com/woct0rdho/triton-windows/releases/download/empty/triton-3.3.0-py3-none-any.whl" -OutFile $tritonWheel
271
+ Invoke-AndLog "$pythonExecutable" "-m pip install `"$tritonWheel`""
272
+ Invoke-AndLog "$pythonExecutable" "-s -m pip install triton-windows"
273
+
274
+ # xformers
275
+ Write-Log " - Installing xformers..."
276
+ Invoke-AndLog "$pythonExecutable" "-m pip install -U xformers --index-url https://download.pytorch.org/whl/cu128"
277
+ Write-Log " - Checking xformers files for compatibility (looking for file named 'pyd')..."
278
+
279
+ $xformersBaseDir = Join-Path $basePath "python_embeded\Lib\site-packages\xformers"
280
+ $dirsToProcess = @(
281
+ $xformersBaseDir,
282
+ (Join-Path $xformersBaseDir "flash_attn_3")
283
+ )
284
+
285
+ foreach ($dir in $dirsToProcess) {
286
+ Write-Log " - Checking directory: $dir"
287
+ if (Test-Path $dir) {
288
+ # On vérifie l'existence d'un fichier nommé EXACTEMENT "pyd"
289
+ $exactFilePath = Join-Path $dir "pyd"
290
+ if (Test-Path $exactFilePath) {
291
+ # Le fichier existe, on le renomme.
292
+ Write-Log " - Found file named 'pyd'. Renaming to '_C.pyd'..." -Color Yellow
293
+ $newName = "_C.pyd"
294
+ try {
295
+ Rename-Item -Path $exactFilePath -NewName $newName -Force -ErrorAction Stop
296
+ Write-Log " - SUCCESS: Renamed 'pyd' to '$newName'" -Color Green
297
+ } catch {
298
+ Write-Log " - FAILED to rename. Error: $($_.Exception.Message)" -Color Red
299
+ }
300
+ } else {
301
+ # Le fichier 'pyd' n'a pas été trouvé. On vérifie si '_C.pyd' existe déjà.
302
+ $finalFilePath = Join-Path $dir "_C.pyd"
303
+ if (Test-Path $finalFilePath) {
304
+ Write-Log " - File '_C.pyd' already exists. No action needed." -Color Green
305
+ } else {
306
+ Write-Log " - No file named 'pyd' or '_C.pyd' found in this directory." -Color Gray
307
+ }
308
+ }
309
+ } else {
310
+ # Le répertoire lui-même n'existe pas.
311
+ Write-Log " - Directory not found. Skipping." -Color Gray
312
+ }
313
+ }
314
+
315
+ # SageAttention
316
+ Write-Log " - Installing SageAttention..."
317
+ $sageWheel = Join-Path $basePath "python_embeded\sageattention-2.1.1+cu128torch2.7.0-cp312-cp312-win_amd64.whl"
318
+ Download-File -Uri "https://huggingface.co/UmeAiRT/ComfyUI-Auto_installer/resolve/main/whl/sageattention-2.1.1+cu128torch2.7.0-cp312-cp312-win_amd64.whl" -OutFile $sageWheel
319
+ Invoke-AndLog "$pythonExecutable" "-m pip install `"$sageWheel`""
320
+
321
+ # --- Step 5: Download Custom Workflows ---
322
+ Write-Log "`nStep 5: Downloading UmeAiRT Workflows..." -Color Yellow
323
+
324
+ $workflowPath = Join-Path $comfyPath "user\default\workflows"
325
+ $cloneDest = Join-Path $workflowPath "UmeAiRT-Workflow"
326
+
327
+ # Create the target directory if it doesn't exist
328
+ if (-not (Test-Path $workflowPath)) {
329
+ Write-Log " - Creating workflow directory: $workflowPath"
330
+ New-Item -Path $workflowPath -ItemType Directory -Force | Out-Null
331
+ }
332
+
333
+ # Clone the workflow repository if it doesn't already exist
334
+ if (-not (Test-Path $cloneDest)) {
335
+ Write-Log " - Cloning workflows from GitHub into '$cloneDest'..."
336
+ Invoke-AndLog "git" "clone https://github.com/UmeAiRT/ComfyUI-Workflows `"$cloneDest`""
337
+ Write-Log " - Workflows downloaded successfully." -Color Green
338
+ } else {
339
+ Write-Log " - Workflow directory already exists. Skipping download." -Color Green
340
+ }
341
+
342
+ # --- Step 6: Optional Model Pack Downloads ---
343
+ Write-Log "`nStep 6: Optional Model Pack Downloads..." -Color Yellow
344
+
345
+ # Définition des packs de modèles et de leurs scripts PowerShell correspondants
346
+ $modelPacks = @(
347
+ @{Name="FLUX"; ScriptName="Download-FLUX-Models.ps1"}
348
+ # Ajoutez ici les autres packs de modèles (WAN, HIDREAM, etc.) quand vous les aurez convertis
349
+ )
350
+ # (Vous devrez créer les scripts Download-WAN-Models.ps1, etc., sur le même modèle)
351
+
352
+ # Boucle pour chaque pack de modèles
353
+ foreach ($pack in $modelPacks) {
354
+ # On pourrait télécharger le script ici si nécessaire, mais pour l'instant on assume qu'il est local
355
+ $scriptPath = Join-Path $installPath $pack.ScriptName
356
+ if (-not (Test-Path $scriptPath)) {
357
+ Write-Log "Model downloader script not found: $($pack.ScriptName). Skipping." -Color Red
358
+ continue # Passe au pack suivant
359
+ }
360
+
361
+ $validInput = $false
362
+ while (-not $validInput) {
363
+ Write-Host "`nWould you like to download $($pack.Name) models? (Y/N)"
364
+ $choice = Read-Host
365
+
366
+ if ($choice -eq 'Y' -or $choice -eq 'y') {
367
+ Write-Log " - Launching downloader for $($pack.Name) models..." -Color Green
368
+ # Exécute le script PowerShell de téléchargement
369
+ & $scriptPath
370
+ $validInput = $true
371
+ } elseif ($choice -eq 'N' -or $choice -eq 'n') {
372
+ Write-Log " - Skipping download for $($pack.Name) models." -Color Gray
373
+ $validInput = $true
374
+ } else {
375
+ Write-Host " Invalid choice. Please enter Y or N."
376
+ }
377
+ }
378
+ }
379
+
380
+ #===========================================================================
381
+ # SECTION 7: FINALIZATION
382
+ #===========================================================================
383
+ Write-Log "-------------------------------------------------------------------------------" -Color Green
384
+ Write-Log "Installation of ComfyUI and all nodes is complete!" -Color Green