Skip to content

Commit

Permalink
Merge pull request #2057 from bmaltais/dev
Browse files Browse the repository at this point in the history
v23.0.3
  • Loading branch information
bmaltais committed Mar 10, 2024
2 parents 7895de6 + 5fa3876 commit f2ea21d
Show file tree
Hide file tree
Showing 10 changed files with 46 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .release
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v23.0.2
v23.0.3
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ The GUI allows you to set the training parameters and generate and run the requi
- [No module called tkinter](#no-module-called-tkinter)
- [SDXL training](#sdxl-training)
- [Change History](#change-history)
- [2024/03/10 (v23.0.3)](#20240310-v2303)
- [2024/03/10 (v23.0.2)](#20240310-v2302)
- [2024/03/09 (v23.0.1)](#20240309-v2301)
- [2024/03/02 (v23.0.0)](#20240302-v2300)
Expand Down Expand Up @@ -365,6 +366,11 @@ The documentation in this section will be moved to a separate document later.
## Change History
### 2024/03/10 (v23.0.3)
- Fix bug with setup
- Enforce proper python version before running the GUI to prevent issues with execution of the GUI.
### 2024/03/10 (v23.0.2)
- Improve validation of path provided by users before running training
Expand Down
1 change: 1 addition & 0 deletions gui.bat
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ set PATH=%PATH%;%~dp0venv\Lib\site-packages\torch\lib

:: Validate requirements
python.exe .\setup\validate_requirements.py
if %errorlevel% neq 0 exit /b %errorlevel%

:: If the exit code is 0, run the kohya_gui.py script with the command-line arguments
if %errorlevel% equ 0 (
Expand Down
6 changes: 6 additions & 0 deletions gui.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ $env:PATH += ";$($MyInvocation.MyCommand.Path)\venv\Lib\site-packages\torch\lib"
# Validate the requirements and store the exit code
python.exe .\setup\validate_requirements.py

# Check the exit code and stop execution if it is not 0
if ($LASTEXITCODE -ne 0) {
Write-Host "Failed to validate requirements. Exiting script..."
exit $LASTEXITCODE
}

# If the exit code is 0, read arguments from gui_parameters.txt (if it exists)
# and run the kohya_gui.py script with the command-line arguments
if ($LASTEXITCODE -eq 0) {
Expand Down
3 changes: 3 additions & 0 deletions gui.sh
Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,7 @@ fi
# Validate the requirements and run the script if successful
if python "$SCRIPT_DIR/setup/validate_requirements.py" -r "$REQUIREMENTS_FILE"; then
"${STARTUP_CMD}" $STARTUP_CMD_ARGS "$SCRIPT_DIR/kohya_gui.py" "$@"
else
echo "Validation failed. Exiting..."
exit 1
fi
3 changes: 3 additions & 0 deletions setup.bat
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ call .\venv\Scripts\deactivate.bat

call .\venv\Scripts\activate.bat

echo "Installing packaging python module..."
pip install packaging

REM Check if the batch was started via double-click
IF /i "%comspec% /c %~0 " equ "%cmdcmdline:"=%" (
REM echo This script was started by double clicking.
Expand Down
5 changes: 4 additions & 1 deletion setup.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,13 @@ $null = New-Item -ItemType Directory -Force -Path ".\logs\setup"
& .\venv\Scripts\deactivate.bat

# Calling external python program to check for local modules
& .\venv\Scripts\python.exe .\setup\check_local_modules.py
# & .\venv\Scripts\python.exe .\setup\check_local_modules.py

& .\venv\Scripts\activate.bat

Write-Host "Installing python packaging module..."
& pip install packaging

& .\venv\Scripts\python.exe .\setup\setup_windows.py

# Deactivate the virtual environment
Expand Down
6 changes: 5 additions & 1 deletion setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,10 @@ install_python_dependencies() {
source "$DIR/venv/bin/activate"
fi

# Install packaging
echo "Installing the python packaging module..."
pip install packaging

case "$OSTYPE" in
"lin"*)
if [ "$RUNPOD" = true ]; then
Expand Down Expand Up @@ -625,5 +629,5 @@ elif [[ "$OSTYPE" == "cygwin" ]]; then
elif [[ "$OSTYPE" == "msys" ]]; then
# MinGW has the msys environment which is a standalone suite of Linux utilities on Windows
# "git bash" on Windows may also be detected as msys.
echo "This hasn't been validated in msys (mingw) on Windows yet."
echo "This hasn't been validated in msys 'mingw' on Windows yet."
fi
22 changes: 13 additions & 9 deletions setup/setup_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,25 @@
def check_python_version():
"""
Check if the current Python version is >= 3.10.9 and < 3.11.0
Returns:
bool: True if the current Python version is valid, False otherwise.
"""
min_version = (3, 10, 9)
max_version = (3, 11, 0)
current_version = sys.version_info

log.info(f"Python version is {sys.version}")

if not (min_version <= current_version < max_version):
log.error(f"The current version of python is not appropriate to run Kohya_ss GUI")
log.error("The python version need to be greater or equal to 3.10.9 and less than 3.11.0")

return (min_version <= current_version < max_version)
try:
current_version = sys.version_info
log.info(f"Python version is {sys.version}")

if not (min_version <= current_version < max_version):
log.error("The current version of python is not appropriate to run Kohya_ss GUI")
log.error("The python version needs to be greater or equal to 3.10.9 and less than 3.11.0")
return False
return True
except Exception as e:
log.error(f"Failed to verify Python version. Error: {e}")
return False

def update_submodule():
"""
Expand Down
7 changes: 4 additions & 3 deletions setup/validate_requirements.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,13 @@ def main():
)
parser.add_argument('--debug', action='store_true', help='Debug on')
args = parser.parse_args()

setup_common.update_submodule()

torch_ver = check_torch()

python_ver = setup_common.check_python_version()

setup_common.update_submodule()
if not setup_common.check_python_version():
exit(1)

if args.requirements:
setup_common.install_requirements(args.requirements, check_no_verify_flag=True)
Expand Down

0 comments on commit f2ea21d

Please sign in to comment.