2022-09-07 01:50:14 +03:00
|
|
|
@echo off
|
|
|
|
|
2022-09-12 11:41:47 +03:00
|
|
|
:: Run all commands using this script's directory as the working directory
|
|
|
|
cd %~dp0
|
|
|
|
|
2022-09-13 12:13:23 +03:00
|
|
|
:: copy over the first line from environment.yaml, e.g. name: ldm, and take the second word after splitting by ":" delimiter
|
|
|
|
for /F "tokens=2 delims=: " %%i in (environment.yaml) DO (
|
|
|
|
set v_conda_env_name=%%i
|
|
|
|
goto EOL
|
|
|
|
)
|
|
|
|
:EOL
|
2022-09-07 01:50:14 +03:00
|
|
|
|
2022-09-13 12:13:23 +03:00
|
|
|
echo Environment name is set as %v_conda_env_name% as per environment.yaml
|
2022-09-07 01:50:14 +03:00
|
|
|
|
2022-09-13 12:13:23 +03:00
|
|
|
:: Put the path to conda directory in a file called "custom-conda-path.txt" if it's installed at non-standard path
|
|
|
|
IF EXIST custom-conda-path.txt (
|
|
|
|
FOR /F %%i IN (custom-conda-path.txt) DO set v_custom_path=%%i
|
2022-09-07 01:50:14 +03:00
|
|
|
)
|
|
|
|
|
2022-09-13 12:13:23 +03:00
|
|
|
set v_paths=%ProgramData%\miniconda3
|
|
|
|
set v_paths=%v_paths%;%USERPROFILE%\miniconda3
|
|
|
|
set v_paths=%v_paths%;%ProgramData%\anaconda3
|
|
|
|
set v_paths=%v_paths%;%USERPROFILE%\anaconda3
|
2022-09-07 01:50:14 +03:00
|
|
|
|
2022-09-13 12:13:23 +03:00
|
|
|
for %%a in (%v_paths%) do (
|
2022-09-14 19:43:32 +03:00
|
|
|
IF NOT "%v_custom_path%"=="" (
|
|
|
|
set v_paths=%v_custom_path%;%v_paths%
|
|
|
|
)
|
2022-09-07 01:50:14 +03:00
|
|
|
)
|
|
|
|
|
2022-09-13 12:13:23 +03:00
|
|
|
for %%a in (%v_paths%) do (
|
2022-09-14 19:43:32 +03:00
|
|
|
if EXIST "%%a\Scripts\activate.bat" (
|
2022-09-13 12:13:23 +03:00
|
|
|
SET v_conda_path=%%a
|
2022-09-07 01:50:14 +03:00
|
|
|
echo anaconda3/miniconda3 detected in %%a
|
2022-09-13 12:13:23 +03:00
|
|
|
goto :CONDA_FOUND
|
2022-09-14 19:43:32 +03:00
|
|
|
)
|
2022-09-07 01:50:14 +03:00
|
|
|
)
|
|
|
|
|
2022-09-13 12:13:23 +03:00
|
|
|
IF "%v_conda_path%"=="" (
|
2022-09-07 01:50:14 +03:00
|
|
|
echo anaconda3/miniconda3 not found. Install from here https://docs.conda.io/en/latest/miniconda.html
|
2022-09-15 00:34:15 +03:00
|
|
|
pause
|
2022-09-07 01:50:14 +03:00
|
|
|
exit /b 1
|
|
|
|
)
|
|
|
|
|
2022-09-13 12:13:23 +03:00
|
|
|
:CONDA_FOUND
|
|
|
|
|
2022-09-14 19:43:32 +03:00
|
|
|
if not exist "z_version_env.tmp" (
|
|
|
|
:: first time running, we need to update
|
2022-09-15 00:34:15 +03:00
|
|
|
set AUTO=1
|
2022-09-14 19:43:32 +03:00
|
|
|
call "update_to_latest.cmd"
|
2022-09-13 12:13:23 +03:00
|
|
|
)
|
2022-09-08 05:21:34 +03:00
|
|
|
|
2022-09-13 12:13:23 +03:00
|
|
|
call "%v_conda_path%\Scripts\activate.bat" "%v_conda_env_name%"
|
2022-09-07 01:50:14 +03:00
|
|
|
|
2022-09-16 10:35:53 +03:00
|
|
|
set v_last_hash=0
|
|
|
|
set /p "v_last_hash="<"z_version_env.tmp"
|
|
|
|
for /f "delims=" %%a in ('git log -1 --format^="%%H" -- environment.yaml') DO set v_cur_hash=%%a
|
|
|
|
|
|
|
|
if not "%v_last_hash%" == "%v_cur_hash%" (
|
|
|
|
set /P updateenv="Do you want to update with the latest environment.yaml? (Y/N): "
|
|
|
|
if /I "%updateenv%" == "N" (
|
|
|
|
echo Starting without updating dependencies.
|
|
|
|
) else if /I "%updateenv%" == "Y" (
|
|
|
|
echo Updating dependencies...
|
|
|
|
call conda env create --name "%v_conda_env_name%" -f environment.yaml
|
|
|
|
call conda env update --name "%v_conda_env_name%" -f environment.yaml
|
|
|
|
echo %v_cur_hash%>z_version_env.tmp
|
|
|
|
)
|
|
|
|
) else (
|
|
|
|
echo No environment.yaml update required.
|
|
|
|
)
|
|
|
|
|
2022-09-07 01:50:14 +03:00
|
|
|
:PROMPT
|
|
|
|
set SETUPTOOLS_USE_DISTUTILS=stdlib
|
|
|
|
IF EXIST "models\ldm\stable-diffusion-v1\model.ckpt" (
|
2022-09-13 12:13:23 +03:00
|
|
|
set PYTHONPATH=%~dp0
|
|
|
|
python scripts\relauncher.py
|
2022-09-07 01:50:14 +03:00
|
|
|
) ELSE (
|
2022-09-13 12:13:23 +03:00
|
|
|
echo Your model file does not exist! Place it in 'models\ldm\stable-diffusion-v1' with the name 'model.ckpt'.
|
|
|
|
pause
|
2022-09-12 11:41:47 +03:00
|
|
|
)
|