diff --git a/.gitignore b/.gitignore index af16d51fd..d2be885e4 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,4 @@ wandb setup.log logs SmilingWolf +uninstall.txt diff --git a/README.md b/README.md index 340b81702..79efbad77 100644 --- a/README.md +++ b/README.md @@ -345,6 +345,8 @@ This will store a backup file with your current locally installed pip packages a ## Change History +* 2023/06/02 (v21.6.1) +- Add detection of files outside the venv to scripts * 2023/06/02 (v21.6.0) - Merge kohya_ss repo changes - Improge logging of kohya_ss GUI diff --git a/gui.bat b/gui.bat index e0e691e42..9b14c5dfe 100644 --- a/gui.bat +++ b/gui.bat @@ -1,4 +1,33 @@ @echo off +setlocal + +REM Define color variables +set "yellow_text=" +set "blue_text=" +set "reset_text=" + +REM Run pip freeze and capture the output +for /f "delims=" %%I in ('pip freeze') do ( + set "pip_output=%%I" + goto :CheckModules +) + +:CheckModules +REM Check if modules are found in the output +if defined pip_output ( + echo %yellow_text%============================================================= + echo Modules installed outside the virtual environment were found. + echo This can cause issues. Please review the installed modules. + echo. + echo You can uninstall all local modules with: + echo. + echo %blue_text%deactivate + echo pip freeze ^> uninstall.txt + echo pip uninstall -y -r uninstall.txt + echo %yellow_text%=============================================================%reset_text% +) + +endlocal :: Activate the virtual environment call .\venv\Scripts\activate.bat diff --git a/gui.ps1 b/gui.ps1 index dcb00a098..8044e9304 100644 --- a/gui.ps1 +++ b/gui.ps1 @@ -1,4 +1,30 @@ +# Check if a virtual environment is active and deactivate it if necessary +if ($env:VIRTUAL_ENV) { + # Write-Host "Deactivating the virtual environment to test for modules installed locally..." + & deactivate +} + +# Run pip freeze and capture the output +$pipOutput = & pip freeze + +# Check if modules are found in the output +if ($pipOutput) { + Write-Host " " + Write-Host -ForegroundColor Yellow -Object "=============================================================" + Write-Host -ForegroundColor Yellow -Object "Modules installed outside the virtual environment were found." + Write-Host -ForegroundColor Yellow -Object "This can cause issues. Please review the installed modules." + Write-Host " " + Write-Host -ForegroundColor Yellow -Object "You can deinstall all the local modules with:" + Write-Host " " + Write-Host -ForegroundColor Blue -Object "deactivate" + Write-Host -ForegroundColor Blue -Object "pip freeze > uninstall.txt" + Write-Host -ForegroundColor Blue -Object "pip uninstall -y -r uninstall.txt" + Write-Host -ForegroundColor Yellow -Object "=============================================================" + Write-Host " " +} + # Activate the virtual environment +# Write-Host "Activating the virtual environment..." & .\venv\Scripts\activate $env:PATH += ";$($MyInvocation.MyCommand.Path)\venv\Lib\site-packages\torch\lib" diff --git a/lora_gui.py b/lora_gui.py index 724d0b1e5..5cb37c61e 100644 --- a/lora_gui.py +++ b/lora_gui.py @@ -827,10 +827,10 @@ def train_model( # run_cmd += f' --conv_alphas="{conv_alphas}"' if print_only_bool: - log.info( - '\033[93m\nHere is the trainer command as a reference. It will not be executed:\033[0m\n' + log.warning( + 'Here is the trainer command as a reference. It will not be executed:\n' ) - log.info('\033[96m' + run_cmd + '\033[0m\n') + log.info(run_cmd) else: log.info(run_cmd) # Run the command diff --git a/setup.bat b/setup.bat index cffcb70d7..93da69fce 100644 --- a/setup.bat +++ b/setup.bat @@ -1,4 +1,53 @@ @echo off +setlocal + +REM Define color variables +set "yellow_text=" +set "blue_text=" +set "reset_text=" + +REM Run pip freeze and capture the output +for /f "delims=" %%I in ('pip freeze') do ( + set "pip_output=%%I" + goto :CheckModules +) + +:CheckModules +REM Check if modules are found in the output +if defined pip_output ( + echo %yellow_text%============================================================= + echo Modules installed outside the virtual environment were found. + echo This can cause issues. Please review the installed modules. + echo. + echo You can uninstall all local modules with: + echo. + echo %blue_text%deactivate + echo pip freeze ^> uninstall.txt + echo pip uninstall -y -r uninstall.txt + echo %yellow_text%=============================================================%reset_text% +) + +:PromptUser +REM Ask the user if they want to quit or continue +echo. +echo Do you want to: +echo [1] - Quit +echo [2] - Continue with the setup +set /p "choice=Enter your choice (1 or 2): " +if /i "%choice%"=="1" ( + echo You chose to quit. + echo. + goto :Quit +) else if /i "%choice%"=="2" ( + echo You chose to continue. + echo. +) else ( + echo Invalid choice. Please try again. + echo. + goto :PromptUser +) + +endlocal set PYTHON_VER=3.10.9 @@ -56,3 +105,5 @@ python.exe .\tools\update_bitsandbytes.py @REM copy /y .\bitsandbytes_windows\main.py .\venv\Lib\site-packages\bitsandbytes\cuda_setup\main.py accelerate config + +:Quit \ No newline at end of file diff --git a/uninstall.txt b/uninstall.txt new file mode 100644 index 000000000..fb70a287e --- /dev/null +++ b/uninstall.txt @@ -0,0 +1,2 @@ +pip freeze \ +pip freeze