mirror of
https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
synced 2025-02-07 06:02:53 +08:00
add back powershell scripts
parent
0dc9b024ac
commit
1bedbd9bc1
@ -15,6 +15,159 @@ https://user-images.githubusercontent.com/98228077/223032534-c5dd5b13-a4b6-47a7-
|
|||||||
|
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
|
<details><summary>Alternative Powershell launch scripts:</summary>
|
||||||
|
|
||||||
|
**webui.ps1**
|
||||||
|
|
||||||
|
```
|
||||||
|
if ($env:PYTHON -eq "" -or $env:PYTHON -eq $null) {
|
||||||
|
$PYTHON = "Python.exe"
|
||||||
|
} else {
|
||||||
|
$PYTHON = $env:PYTHON
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($env:VENV_DIR -eq "" -or $env:VENV_DIR -eq $null) {
|
||||||
|
$VENV_DIR = "$PSScriptRoot\venv"
|
||||||
|
} else {
|
||||||
|
$VENV_DIR = $env:VENV_DIR
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($env:LAUNCH_SCRIPT -eq "" -or $env:LAUNCH_SCRIPT -eq $null) {
|
||||||
|
$LAUNCH_SCRIPT = "$PSScriptRoot\launch.py"
|
||||||
|
} else {
|
||||||
|
$LAUNCH_SCRIPT = $env:LAUNCH_SCRIPT
|
||||||
|
}
|
||||||
|
|
||||||
|
$ERROR_REPORTING = $false
|
||||||
|
|
||||||
|
mkdir tmp 2>$null
|
||||||
|
|
||||||
|
function Start-Venv {
|
||||||
|
if ($VENV_DIR -eq '-') {
|
||||||
|
Skip-Venv
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Test-Path -Path "$VENV_DIR\Scripts\$python") {
|
||||||
|
Activate-Venv
|
||||||
|
} else {
|
||||||
|
$PYTHON_FULLNAME = & $PYTHON -c "import sys; print(sys.executable)"
|
||||||
|
Write-Output "Creating venv in directory $VENV_DIR using python $PYTHON_FULLNAME"
|
||||||
|
Invoke-Expression "$PYTHON_FULLNAME -m venv $VENV_DIR > tmp/stdout.txt 2> tmp/stderr.txt"
|
||||||
|
if ($LASTEXITCODE -eq 0) {
|
||||||
|
Activate-Venv
|
||||||
|
} else {
|
||||||
|
Write-Output "Unable to create venv in directory $VENV_DIR"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function Activate-Venv {
|
||||||
|
$PYTHON = "$VENV_DIR\Scripts\Python.exe"
|
||||||
|
$ACTIVATE = "$VENV_DIR\Scripts\activate.bat"
|
||||||
|
Invoke-Expression "cmd.exe /c $ACTIVATE"
|
||||||
|
Write-Output "Venv set to $VENV_DIR."
|
||||||
|
if ($ACCELERATE -eq 'True') {
|
||||||
|
Check-Accelerate
|
||||||
|
} else {
|
||||||
|
Launch-App
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function Skip-Venv {
|
||||||
|
Write-Output "Venv set to $VENV_DIR."
|
||||||
|
if ($ACCELERATE -eq 'True') {
|
||||||
|
Check-Accelerate
|
||||||
|
} else {
|
||||||
|
Launch-App
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function Check-Accelerate {
|
||||||
|
Write-Output 'Checking for accelerate'
|
||||||
|
$ACCELERATE = "$VENV_DIR\Scripts\accelerate.exe"
|
||||||
|
if (Test-Path -Path $ACCELERATE) {
|
||||||
|
Accelerate-Launch
|
||||||
|
} else {
|
||||||
|
Launch-App
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function Launch-App {
|
||||||
|
Write-Output "Launching with python"
|
||||||
|
Invoke-Expression "$PYTHON $LAUNCH_SCRIPT"
|
||||||
|
#pause
|
||||||
|
exit
|
||||||
|
}
|
||||||
|
|
||||||
|
function Accelerate-Launch {
|
||||||
|
Write-Output 'Accelerating'
|
||||||
|
Invoke-Expression "$ACCELERATE launch --num_cpu_threads_per_process=6 $LAUNCH_SCRIPT"
|
||||||
|
#pause
|
||||||
|
exit
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
try {
|
||||||
|
if(Get-Command $PYTHON){
|
||||||
|
Start-Venv
|
||||||
|
}
|
||||||
|
} Catch {
|
||||||
|
Write-Output "Couldn't launch python."
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
**webui-user.ps1**
|
||||||
|
|
||||||
|
```
|
||||||
|
[Environment]::SetEnvironmentVariable("PYTHON", "")
|
||||||
|
[Environment]::SetEnvironmentVariable("GIT", "")
|
||||||
|
[Environment]::SetEnvironmentVariable("VENV_DIR","")
|
||||||
|
|
||||||
|
# Commandline arguments for webui.py, for example: [Environment]::SetEnvironmentVariable("COMMANDLINE_ARGS", "--medvram --opt-split-attention")
|
||||||
|
[Environment]::SetEnvironmentVariable("COMMANDLINE_ARGS", "")
|
||||||
|
|
||||||
|
# script to launch to start the app
|
||||||
|
# [Environment]::SetEnvironmentVariable("LAUNCH_SCRIPT", "launch.py")
|
||||||
|
|
||||||
|
# install command for torch
|
||||||
|
# [Environment]::SetEnvironmentVariable("TORCH_COMMAND", "pip install torch==1.12.1+cu113 torchvision==0.13.1+cu113 --extra-index-url https://download.pytorch.org/whl/cu113")
|
||||||
|
|
||||||
|
# Requirements file to use for stable-diffusion-webui
|
||||||
|
# [Environment]::SetEnvironmentVariable("REQS_FILE", "requirements_versions.txt")
|
||||||
|
|
||||||
|
# [Environment]::SetEnvironmentVariable("GFPGAN_PACKAGE", "")
|
||||||
|
# [Environment]::SetEnvironmentVariable("CLIP_PACKAGE", "")
|
||||||
|
# [Environment]::SetEnvironmentVariable("OPENCLIP_PACKAGE", "")
|
||||||
|
|
||||||
|
# URL to a WHL if you wish to override default xformers windows
|
||||||
|
# [Environment]::SetEnvironmentVariable("XFORMERS_WINDOWS_PACKAGE", "")
|
||||||
|
|
||||||
|
# Uncomment and set to enable an alternate repository URL
|
||||||
|
# [Environment]::SetEnvironmentVariable("STABLE_DIFFUSION_REPO", "")
|
||||||
|
# [Environment]::SetEnvironmentVariable("TAMING_TRANSFORMERS_REPO", "")
|
||||||
|
# [Environment]::SetEnvironmentVariable("K_DIFFUSION_REPO", "")
|
||||||
|
# [Environment]::SetEnvironmentVariable("CODEFORMER_REPO", "")
|
||||||
|
# [Environment]::SetEnvironmentVariable("BLIP_REPO", "")
|
||||||
|
|
||||||
|
# Uncomment and set to enable a specific revision of a repository
|
||||||
|
# [Environment]::SetEnvironmentVariable("STABLE_DIFFUSION_COMMIT_HASH", "")
|
||||||
|
# [Environment]::SetEnvironmentVariable("TAMING_TRANSFORMERS_COMMIT_HASH", "")
|
||||||
|
# [Environment]::SetEnvironmentVariable("K_DIFFUSION_COMMIT_HASH", "")
|
||||||
|
# [Environment]::SetEnvironmentVariable("CODEFORMER_COMMIT_HASH", "")
|
||||||
|
# [Environment]::SetEnvironmentVariable("BLIP_COMMIT_HASH", "")
|
||||||
|
|
||||||
|
|
||||||
|
# Uncomment to enable accelerated launch
|
||||||
|
# [Environment]::SetEnvironmentVariable("ACCELERATE", "True")
|
||||||
|
|
||||||
|
$SCRIPT = "$PSScriptRoot\webui.ps1"
|
||||||
|
Invoke-Expression "$SCRIPT"
|
||||||
|
```
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user