The script will now detect and utilize Python 3.11 alongside Python 3.10.
Here are the key changes:
- I added a function to detect the available Python command, prioritizing python3.11, then python3.10, then python3.
- I modified virtual environment creation to use the detected Python version.
- I updated macOS Homebrew installation logic to check for python@3.11 and python-tk@3.11 first.
- I made Python-version-specific paths (e.g., for site-packages and symlinks, especially in Runpod environments) dynamic to adapt to the selected Python version.
Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
* Refactor and Improve Core Components
This commit includes several improvements to the core components of the Kohya_ss GUI:
1. **Refactored `check_torch()` in `setup/setup_common.py`**:
* Broke down the function into smaller, more focused functions for better readability and maintainability.
* Simplified the logic for detecting different hardware backends (CUDA, ROCm, Intel OneAPI).
2. **Improved Error Handling in `setup/setup_common.py`**:
* Made error messages more user-friendly and informative by providing context and suggestions.
* Ensured consistent logging of errors.
* Enhanced error reporting for external processes like Git and pip/uv.
3. **Enhanced Documentation for `config.toml`**:
* Updated the "Custom Path Defaults" section in `README.md` with more details on customizing `config.toml`.
* Provided clearer examples of common configurations.
4. **Reviewed and Updated Dependencies**:
* Removed several unused dependencies from `pyproject.toml` (`altair`, `fairscale`, `imagesize`, `invisible-watermark`, `pytorch-lightning`, `voluptuous`).
* Updated various dependencies to their latest stable and compatible versions.
---------
Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
I've modified both scripts to check for `nvidia-smi` first. If `nvidia-smi` is found, the scripts will now use the NVIDIA-specific (CUDA) requirements files, regardless of the presence of `rocminfo`. The ROCm check is now a fallback if `nvidia-smi` is not detected.
This should ensure that you get the correct PyTorch build and dependencies if you have an NVIDIA GPU, resolving the issue where ROCm packages were being erroneously selected.
Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
* feat: Remember last used folder for file dialogs
This commit introduces a feature to remember the last used folder for various file and folder dialogs within the GUI.
Key changes:
- Modified `KohyaSSGUIConfig` (`kohya_gui/class_gui_config.py`) to store and retrieve a `last_used_folder` value in the `config.toml` file.
- Updated file/folder dialog utility functions in `kohya_gui/common_gui.py` (e.g., `get_folder_path`, `get_file_path`, `get_saveasfilename_path`) to:
- Accept the `KohyaSSGUIConfig` instance.
- Use the stored `last_used_folder` as the initial directory for dialogs.
- Update `last_used_folder` after a successful selection.
- Updated various GUI modules (`class_folders.py`, `wd14_caption_gui.py`, and other captioning utilities) to pass the `KohyaSSGUIConfig` instance to these dialog functions.
This enhancement improves your experience by defaulting file dialogs to the most recently accessed relevant directory, streamlining the workflow for you when you frequently work with specific folders.
* Fix typo
* Fix typos
---------
Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
* Docs: Explain .python-version file for uv installs
I've updated the Linux and Windows uv installation guides to explain that you can specify the Python version for the uv environment by editing the .python-version file at the root of the repository.
* Update linux documentation
---------
Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
This commit updates the README.md file to include Windows-specific
instructions for setting up the project using a Conda environment.
The "Using `conda`" subsection under "Installation Methods" now clarifies:
- `chmod +x` commands are not needed for Windows.
- Windows users should use `setup.bat` and `gui.bat` (or `gui.ps1`)
instead of the `.sh` scripts.
The Table of Contents was previously updated to include the "Using `conda`"
section.
This commit adds a new section to the README.md file detailing how to set up the project using a Conda environment.
The new "Using `conda`" subsection under "Installation Methods" includes:
- Commands to create and activate a Conda environment with Python 3.11.
- Instructions on how to make the setup and GUI scripts executable and how to run them.
The Table of Contents has also been updated to reflect this new section.
- Fixes a typo in the variable name and log message from "reccomended" to the correct "recommended" when logging Apple MPS memory information.
Signed-off-by: CHEN, CHUN <jim60105@gmail.com>
Modified the get_file_path function in kohya_gui/common_gui.py
to ensure that when you are opening a configuration file, the
file dialog defaults to the kohya_ss repository root if no
initial path or only a filename is provided.
If a full or relative path is already present in the input field,
the dialog will open in the specified directory as before.
This change improves your experience by starting the file search
in a more relevant location.
This commit introduces a helper function, `get_effective_lr_messages`, into `kohya_gui/lora_gui.py` and integrates it into the `train_model` function.
The purpose is to provide you with clearer information about how the learning rates set in the GUI (Main LR, Text Encoder LR, U-Net LR, T5XXL LR) will be interpreted and effectively applied by the underlying `sd-scripts` training engine.
Before training commences, the GUI will now log:
- The Main LR.
- The effective LR for the primary Text Encoder (CLIP), indicating if it's a specific value or a fallback to the Main LR.
- The effective LR for the T5XXL Text Encoder (if applicable), indicating its source (specific, inherited from primary TE, or fallback to Main LR).
- The effective LR for the U-Net, indicating if it's a specific value or a fallback to the Main LR.
This enhances transparency by helping you understand how your LR settings interact, without modifying the `sd-scripts` submodule.
This commit refactors the learning rate (LR) handling in `kohya_gui/lora_gui.py` for LoRA training.
The previous fix for LR misinterpretation involved commenting out a line. This commit completes the cleanup by:
- Removing the `do_not_set_learning_rate` variable and its associated conditional logic, which became redundant.
- Renaming the float-converted `learning_rate` to `learning_rate_float` for clarity.
- Ensuring that `learning_rate_float` and the float-converted `unet_lr_float` are consistently used when preparing the `config_toml_data` for the training script.
This makes the code cleaner and the intent of always passing the main learning rate (along with specific TE/UNet LRs) more direct. The functional behavior of the LR fix remains the same.
The GUI logic was preventing the main learning rate from being passed to the training script if text_encoder_lr or unet_lr was set. This caused issues with optimizers like Prodigy, which might default to a very small LR if the main LR isn't provided.
This commit modifies kohya_gui/lora_gui.py to ensure the main learning_rate is always included in the parameters passed to the training script, allowing optimizers to use your specified main LR, TE LR, and UNet LR correctly.