Merge 1604d6387a
into ea9bd9fc74
This commit is contained in:
commit
4afb7754aa
|
@ -1,8 +0,0 @@
|
|||
@echo off
|
||||
|
||||
set PYTHON=
|
||||
set GIT=
|
||||
set VENV_DIR=
|
||||
set COMMANDLINE_ARGS=
|
||||
|
||||
call webui.bat
|
43
webui-user.ps1
Normal file
43
webui-user.ps1
Normal file
|
@ -0,0 +1,43 @@
|
|||
[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"
|
85
webui.bat
85
webui.bat
|
@ -1,85 +0,0 @@
|
|||
@echo off
|
||||
|
||||
if not defined PYTHON (set PYTHON=python)
|
||||
if not defined VENV_DIR (set "VENV_DIR=%~dp0%venv")
|
||||
|
||||
|
||||
set ERROR_REPORTING=FALSE
|
||||
|
||||
mkdir tmp 2>NUL
|
||||
|
||||
%PYTHON% -c "" >tmp/stdout.txt 2>tmp/stderr.txt
|
||||
if %ERRORLEVEL% == 0 goto :check_pip
|
||||
echo Couldn't launch python
|
||||
goto :show_stdout_stderr
|
||||
|
||||
:check_pip
|
||||
%PYTHON% -mpip --help >tmp/stdout.txt 2>tmp/stderr.txt
|
||||
if %ERRORLEVEL% == 0 goto :start_venv
|
||||
if "%PIP_INSTALLER_LOCATION%" == "" goto :show_stdout_stderr
|
||||
%PYTHON% "%PIP_INSTALLER_LOCATION%" >tmp/stdout.txt 2>tmp/stderr.txt
|
||||
if %ERRORLEVEL% == 0 goto :start_venv
|
||||
echo Couldn't install pip
|
||||
goto :show_stdout_stderr
|
||||
|
||||
:start_venv
|
||||
if ["%VENV_DIR%"] == ["-"] goto :skip_venv
|
||||
if ["%SKIP_VENV%"] == ["1"] goto :skip_venv
|
||||
|
||||
dir "%VENV_DIR%\Scripts\Python.exe" >tmp/stdout.txt 2>tmp/stderr.txt
|
||||
if %ERRORLEVEL% == 0 goto :activate_venv
|
||||
|
||||
for /f "delims=" %%i in ('CALL %PYTHON% -c "import sys; print(sys.executable)"') do set PYTHON_FULLNAME="%%i"
|
||||
echo Creating venv in directory %VENV_DIR% using python %PYTHON_FULLNAME%
|
||||
%PYTHON_FULLNAME% -m venv "%VENV_DIR%" >tmp/stdout.txt 2>tmp/stderr.txt
|
||||
if %ERRORLEVEL% == 0 goto :activate_venv
|
||||
echo Unable to create venv in directory "%VENV_DIR%"
|
||||
goto :show_stdout_stderr
|
||||
|
||||
:activate_venv
|
||||
set PYTHON="%VENV_DIR%\Scripts\Python.exe"
|
||||
echo venv %PYTHON%
|
||||
|
||||
:skip_venv
|
||||
if [%ACCELERATE%] == ["True"] goto :accelerate
|
||||
goto :launch
|
||||
|
||||
:accelerate
|
||||
echo Checking for accelerate
|
||||
set ACCELERATE="%VENV_DIR%\Scripts\accelerate.exe"
|
||||
if EXIST %ACCELERATE% goto :accelerate_launch
|
||||
|
||||
:launch
|
||||
%PYTHON% launch.py %*
|
||||
pause
|
||||
exit /b
|
||||
|
||||
:accelerate_launch
|
||||
echo Accelerating
|
||||
%ACCELERATE% launch --num_cpu_threads_per_process=6 launch.py
|
||||
pause
|
||||
exit /b
|
||||
|
||||
:show_stdout_stderr
|
||||
|
||||
echo.
|
||||
echo exit code: %errorlevel%
|
||||
|
||||
for /f %%i in ("tmp\stdout.txt") do set size=%%~zi
|
||||
if %size% equ 0 goto :show_stderr
|
||||
echo.
|
||||
echo stdout:
|
||||
type tmp\stdout.txt
|
||||
|
||||
:show_stderr
|
||||
for /f %%i in ("tmp\stderr.txt") do set size=%%~zi
|
||||
if %size% equ 0 goto :show_stderr
|
||||
echo.
|
||||
echo stderr:
|
||||
type tmp\stderr.txt
|
||||
|
||||
:endofscript
|
||||
|
||||
echo.
|
||||
echo Launch unsuccessful. Exiting.
|
||||
pause
|
96
webui.ps1
Normal file
96
webui.ps1
Normal file
|
@ -0,0 +1,96 @@
|
|||
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 {
|
||||
$global:LASTEXITCODE = 0
|
||||
try {
|
||||
$PYTHON_FULLNAME = & $PYTHON -c "import sys; print(sys.executable)"
|
||||
Write-Output "Creating venv in directory $VENV_DIR using $PYTHON_FULLNAME"
|
||||
Invoke-Expression "& '$PYTHON_FULLNAME' -m venv $VENV_DIR"
|
||||
Activate-Venv
|
||||
} Catch {
|
||||
Write-Output "Unable to create venv in directory $VENV_DIR"
|
||||
Write-Output $_
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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."
|
||||
}
|
Loading…
Reference in New Issue
Block a user