-
Notifications
You must be signed in to change notification settings - Fork 11
/
webui.bat
130 lines (105 loc) · 4.55 KB
/
webui.bat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
@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%
setlocal enabledelayedexpansion
if not exist "models\Codeformer" ( mkdir "models\Codeformer" )
if not exist "models\Lora" ( mkdir "models\Lora" )
if not exist "models\GFPGAN" ( mkdir "models\GFPGAN" )
if not exist "models\Stable-diffusion" ( mkdir "models\Stable-diffusion" )
if not exist "models\VAE" ( mkdir "models\VAE" )
if not exist "models\BLIP" ( mkdir "models\BLIP" )
REM Download dependencies
set "file_names[0]=./extensions/sd-webui-controlnet/models/control_openpose-fp16.yaml"
set "urls[0]=https://huggingface.co/KorewaDes/basicmodel/raw/main/control_openpose-fp16.yaml"
set "file_names[1]=./extensions/sd-webui-controlnet/models/control_openpose-fp16.safetensors"
set "urls[1]=https://huggingface.co/KorewaDes/basicmodel/resolve/main/control_openpose-fp16.safetensors"
set "file_names[2]=./models/Codeformer/codeformer-v0.1.0.pth"
set "urls[2]=https://huggingface.co/KorewaDes/basicmodel/resolve/main/codeformer-v0.1.0.pth"
set "file_names[3]=./models/GFPGAN/detection_Resnet50_Final.pth"
set "urls[3]=https://huggingface.co/KorewaDes/basicmodel/resolve/main/detection_Resnet50_Final.pth"
set "file_names[4]=./models/GFPGAN/GFPGANv1.4.pth"
set "urls[4]=https://huggingface.co/KorewaDes/basicmodel/resolve/main/GFPGANv1.4.pth"
set "file_names[5]=./models/Stable-diffusion/basemodel.safetensors"
set "urls[5]=https://huggingface.co/KorewaDes/basicmodel/resolve/main/basemodel.safetensors"
set "file_names[6]=./repositories/CodeFormer/weights/facelib/detection_Resnet50_Final.pth"
set "urls[6]=https://huggingface.co/KorewaDes/basicmodel/resolve/main/detection_Resnet50_Final.pth"
set "file_names[7]=./models/VAE/vae-ft-mse-840000-ema-pruned.safetensors"
set "urls[7]=https://huggingface.co/stabilityai/sd-vae-ft-mse-original/resolve/main/vae-ft-mse-840000-ema-pruned.safetensors"
set "file_names[8]=.\models\BLIP\model_base_caption_capfilt_large.pth"
set "urls[8]=https://storage.googleapis.com/sfr-vision-language-research/BLIP/models/model_base_caption_capfilt_large.pth"
set i=0
:check_deps
if defined file_names[%i%] (
if not exist "!file_names[%i%]!" (
echo File !file_names[%i%]! does not exist, downloading...
@REM powershell -command "& { (New-Object Net.WebClient).DownloadFile('!urls[%i%]!', '!file_names[%i%]!') }"
powershell -command "Invoke-WebRequest -Uri !urls[%i%]! -OutFile !file_names[%i%]!"
)
@REM else (
@REM echo File !file_names[%i%]! already exists, skipping download.
@REM )
set /a i+=1
goto :check_deps
)
: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