Skip to content

Commit

Permalink
Merge pull request #2119 from bmaltais/dev
Browse files Browse the repository at this point in the history
v23.0.12
  • Loading branch information
bmaltais committed Mar 18, 2024
2 parents 6162193 + 6c52d88 commit 726f5b3
Show file tree
Hide file tree
Showing 52 changed files with 2,775 additions and 1,699 deletions.
11 changes: 7 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,13 @@ test/ft
# Temporary requirements
requirements_tmp_for_setup.txt

# Version specific
0.13.3

*.npz
presets/*/user_presets/*
inputs
outputs
outputs
dataset/**
!dataset/**/
!dataset/**/.gitkeep
models
data
config.toml
2 changes: 1 addition & 1 deletion .release
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v23.0.11
v23.0.12
49 changes: 25 additions & 24 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -54,21 +54,8 @@ RUN if [ "$TARGETPLATFORM" = "linux/amd64" ]; then \

FROM python:3.10-slim as final

ARG UID
ARG VERSION
ARG RELEASE

LABEL name="bmaltais/kohya_ss" \
vendor="bmaltais" \
maintainer="bmaltais" \
# Dockerfile source repository
url="https://github.com/bmaltais/kohya_ss" \
version=${VERSION} \
# This should be a number, incremented with each change
release=${RELEASE} \
io.k8s.display-name="kohya_ss" \
summary="Kohya's GUI: This repository provides a Gradio GUI for Kohya's Stable Diffusion trainers(https://github.com/kohya-ss/sd-scripts)." \
description="The GUI allows you to set the training parameters and generate and run the required CLI commands to train the model. This is the docker image for Kohya's GUI. For more information about this tool, please visit the following website: https://github.com/bmaltais/kohya_ss."
ENV NVIDIA_VISIBLE_DEVICES all
ENV NVIDIA_DRIVER_CAPABILITIES compute,utility

# Install runtime dependencies
RUN apt-get update && \
Expand All @@ -81,6 +68,7 @@ RUN ln -s /usr/lib/x86_64-linux-gnu/libnvinfer.so /usr/lib/x86_64-linux-gnu/libn
ln -s /usr/lib/x86_64-linux-gnu/libnvinfer_plugin.so /usr/lib/x86_64-linux-gnu/libnvinfer_plugin.so.7

# Create user
ARG UID
RUN groupadd -g $UID $UID && \
useradd -l -u $UID -g $UID -m -s /bin/sh -N $UID

Expand All @@ -89,21 +77,20 @@ RUN install -d -m 775 -o $UID -g 0 /dataset && \
install -d -m 775 -o $UID -g 0 /licenses && \
install -d -m 775 -o $UID -g 0 /app

# Copy dist and support arbitrary user ids (OpenShift best practice)
COPY --chown=$UID:0 --chmod=775 \
--from=build /root/.local /home/$UID/.local

WORKDIR /app
COPY --chown=$UID:0 --chmod=775 . .

# Copy licenses (OpenShift Policy)
COPY --chmod=775 LICENSE.md /licenses/LICENSE.md
COPY --link --chmod=775 LICENSE.md /licenses/LICENSE.md

# Copy dependencies and code (and support arbitrary uid for OpenShift best practice)
COPY --link --chown=$UID:0 --chmod=775 --from=build /root/.local /home/$UID/.local
COPY --link --chown=$UID:0 --chmod=775 . /app

ENV PATH="/home/$UID/.local/bin:$PATH"
ENV PYTHONPATH="${PYTHONPATH}:/home/$UID/.local/lib/python3.10/site-packages"
ENV LD_PRELOAD=libtcmalloc.so
ENV PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python

WORKDIR /app

VOLUME [ "/dataset" ]

# 7860: Kohya GUI
Expand All @@ -116,4 +103,18 @@ STOPSIGNAL SIGINT

# Use dumb-init as PID 1 to handle signals properly
ENTRYPOINT ["dumb-init", "--"]
CMD ["python3", "kohya_gui.py", "--listen", "0.0.0.0", "--server_port", "7860"]
CMD ["python3", "kohya_gui.py", "--listen", "0.0.0.0", "--server_port", "7860"]

ARG VERSION
ARG RELEASE
LABEL name="bmaltais/kohya_ss" \
vendor="bmaltais" \
maintainer="bmaltais" \
# Dockerfile source repository
url="https://github.com/bmaltais/kohya_ss" \
version=${VERSION} \
# This should be a number, incremented with each change
release=${RELEASE} \
io.k8s.display-name="kohya_ss" \
summary="Kohya's GUI: This repository provides a Gradio GUI for Kohya's Stable Diffusion trainers(https://github.com/kohya-ss/sd-scripts)." \
description="The GUI allows you to set the training parameters and generate and run the required CLI commands to train the model. This is the docker image for Kohya's GUI. For more information about this tool, please visit the following website: https://github.com/bmaltais/kohya_ss."
115 changes: 77 additions & 38 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Kohya's GUI

This repository mostly provides a Gradio GUI for [Kohya's Stable Diffusion trainers](https://github.com/kohya-ss/sd-scripts)... but support for Linux OS is also provided through community contributions. Macos is not great at the moment... but might work if the wind blow in the right direction...
This repository primarily provides a Gradio GUI for [Kohya's Stable Diffusion trainers](https://github.com/kohya-ss/sd-scripts). However, support for Linux OS is also offered through community contributions. macOS support is not optimal at the moment but might work if the conditions are favorable.

The GUI allows you to set the training parameters and generate and run the required CLI commands to train the model.

Expand Down Expand Up @@ -30,13 +30,18 @@ The GUI allows you to set the training parameters and generate and run the requi
- [Starting GUI Service](#starting-gui-service)
- [Launching the GUI on Windows](#launching-the-gui-on-windows)
- [Launching the GUI on Linux and macOS](#launching-the-gui-on-linux-and-macos)
- [Custom Path Defaults](#custom-path-defaults)
- [LoRA](#lora)
- [Sample image generation during training](#sample-image-generation-during-training)
- [Troubleshooting](#troubleshooting)
- [Page File Limit](#page-file-limit)
- [No module called tkinter](#no-module-called-tkinter)
- [SDXL training](#sdxl-training)
- [Change History](#change-history)
- [2024/03/16 (v23.0.12)](#20240316-v23012)
- [New Features \& Improvements](#new-features--improvements)
- [Software Updates](#software-updates)
- [Recommendations for Users](#recommendations-for-users)
- [2024/03/13 (v23.0.11)](#20240313-v23011)
- [2024/03/13 (v23.0.9)](#20240313-v2309)
- [2024/03/12 (v23.0.8)](#20240312-v2308)
Expand Down Expand Up @@ -70,11 +75,11 @@ To install the necessary dependencies on a Windows system, follow these steps:
1. Install [Python 3.10.11](https://www.python.org/ftp/python/3.10.11/python-3.10.11-amd64.exe).
- During the installation process, ensure that you select the option to add Python to the 'PATH' environment variable.

2. Install [CUDA 11.8 toolkit](https://developer.nvidia.com/cuda-11-8-0-download-archive?target_os=Windows&target_arch=x86_64)
2. Install [CUDA 11.8 toolkit](https://developer.nvidia.com/cuda-11-8-0-download-archive?target_os=Windows&target_arch=x86_64).

2. Install [Git](https://git-scm.com/download/win).
3. Install [Git](https://git-scm.com/download/win).

3. Install the [Visual Studio 2015, 2017, 2019, and 2022 redistributable](https://aka.ms/vs/17/release/vc_redist.x64.exe).
4. Install the [Visual Studio 2015, 2017, 2019, and 2022 redistributable](https://aka.ms/vs/17/release/vc_redist.x64.exe).

#### Setup Windows

Expand All @@ -100,13 +105,13 @@ To set up the project, follow these steps:
.\setup.bat
```

During the accelerate config step use the default values as proposed during the configuration unless you know your hardware demand otherwise. The amount of VRAM on your GPU does not have an impact on the values used.
During the accelerate config step, use the default values as proposed during the configuration unless you know your hardware demands otherwise. The amount of VRAM on your GPU does not impact the values used.

#### Optional: CUDNN 8.9.6.50

The following steps are optional but will improve the learning speed for owners of NVIDIA 30X0/40X0 GPUs. These steps enable larger training batch sizes and faster training speeds.

1. Run .\setup.bat and select `2. (Optional) Install cudnn files (if you want to use latest supported cudnn version)`
1. Run `.\setup.bat` and select `2. (Optional) Install cudnn files (if you want to use the latest supported cudnn version)`.
### Linux and macOS
Expand All @@ -120,7 +125,7 @@ To install the necessary dependencies on a Linux system, ensure that you fulfill
apt install python3.10-venv
```
- Install the CUDA 11.8 Tolkit by following the instructions provided in [this link](https://developer.nvidia.com/cuda-11-8-0-download-archive?target_os=Linux&target_arch=x86_64).
- Install the CUDA 11.8 Toolkit by following the instructions provided in [this link](https://developer.nvidia.com/cuda-11-8-0-download-archive?target_os=Linux&target_arch=x86_64).
- Make sure you have Python version 3.10.9 or higher (but lower than 3.11.0) installed on your system.
Expand Down Expand Up @@ -188,13 +193,13 @@ To install the necessary components for Runpod and run kohya_ss, follow these st
./setup-runpod.sh
```
5. Run the gui with:
5. Run the GUI with:
```shell
./gui.sh --share --headless
```
or with this if you expose 7860 directly via the runpod configuration
or with this if you expose 7860 directly via the runpod configuration:
```shell
./gui.sh --listen=0.0.0.0 --headless
Expand All @@ -204,13 +209,13 @@ To install the necessary components for Runpod and run kohya_ss, follow these st
#### Pre-built Runpod template
To run from a pre-built Runpod template you can:
To run from a pre-built Runpod template, you can:
1. Open the Runpod template by clicking on <https://runpod.io/gsc?template=ya6013lj5a&ref=w18gds2n>
1. Open the Runpod template by clicking on <https://runpod.io/gsc?template=ya6013lj5a&ref=w18gds2n>.
2. Deploy the template on the desired host
2. Deploy the template on the desired host.
3. Once deployed connect to the Runpod on HTTP 3010 to connect to kohya_ss GUI. You can also connect to auto1111 on HTTP 3000.
3. Once deployed, connect to the Runpod on HTTP 3010 to access the kohya_ss GUI. You can also connect to auto1111 on HTTP 3000.
### Docker
Expand All @@ -235,13 +240,13 @@ If you prefer to use Docker, follow the instructions below:
- All training data must be placed in the `dataset` subdirectory, as the Docker container cannot access files from other directories.
- The file picker feature is not functional. You need to manually set the folder path and config file path.
- Dialogs may not work as expected, and it is recommended to use unique file names to avoid conflicts.
- This dockerfile has been designed to be easily disposable. You can discard the container at any time and docker build it with a new version of the code. To update the system, run update scripts outside of Docker and rebuild using `docker compose down && docker compose up -d --build`.
- This Dockerfile has been designed to be easily disposable. You can discard the container at any time and docker build it with a new version of the code. To update the system, run update scripts outside of Docker and rebuild using `docker compose down && docker compose up -d --build`.
If you are running Linux, an alternative Docker container port with fewer limitations is available [here](https://github.com/P2Enjoy/kohya_ss-docker).
#### ashleykleynhans runpod docker builds
You may want to use the following Dockerfile repos to build the images:
You may want to use the following Dockerfile repositories to build the images:
- Standalone Kohya_ss template: <https://github.com/ashleykleynhans/kohya-docker>
- Auto1111 + Kohya_ss GUI template: <https://github.com/ashleykleynhans/stable-diffusion-docker>
Expand Down Expand Up @@ -270,9 +275,7 @@ If a new release becomes available, you can upgrade your repository by running t
To upgrade your installation on Linux or macOS, follow these steps:
1. Open a terminal and navigate to the root
directory of the project.
1. Open a terminal and navigate to the root directory of the project.
2. Pull the latest changes from the repository:
Expand Down Expand Up @@ -322,6 +325,13 @@ To launch the GUI on Linux or macOS, run the `gui.sh` script located in the root
gui.sh --listen 127.0.0.1 --server_port 7860 --inbrowser --share
```
## Custom Path Defaults
You can now specify custom paths more easily:
- Simply copy the `config example.toml` file located in the root directory of the repository to `config.toml`.
- Edit the `config.toml` file to adjust paths and settings according to your preferences.
## LoRA
To train a LoRA, you can currently use the `train_network.py` code. You can create a LoRA network by using the all-in-one GUI.
Expand Down Expand Up @@ -349,7 +359,7 @@ Lines beginning with `#` are comments. You can specify options for the generated
- `--l`: Specifies the CFG scale of the generated image.
- `--s`: Specifies the number of steps in the generation.
The prompt weighting such as `( )` and `[ ]` are working.
The prompt weighting such as `( )` and `[ ]` is working.
## Troubleshooting
Expand All @@ -369,54 +379,83 @@ The documentation in this section will be moved to a separate document later.
## Change History
### 2024/03/16 (v23.0.12)
#### New Features & Improvements
- **Enhanced Logging and Tracking Capabilities**
- Added support for configuring advanced logging and tracking:
- `wandb_run_name`: Set a custom name for your Weights & Biases runs to easily identify and organize your experiments.
- `log_tracker_name` and `log_tracker_config`: Integrate custom logging trackers with your projects. Specify the tracker name and provide its configuration to enable detailed monitoring and logging of your runs.
- **Custom Path Defaults**
- You can now specify custom paths more easily:
- Simply copy the `config example.toml` file located in the root directory of the repository to `config.toml`.
- Edit the `config.toml` file to adjust paths and settings according to your preferences.
#### Software Updates
- **sd-scripts updated to v0.8.5**
- **Bug Fixes:**
- Corrected an issue where the value of timestep embedding was incorrect during SDXL training. This fix ensures accurate training progress and results.
- Addressed a related inference issue with the generation script, improving the reliability of SDXL model outputs.
- **Note:** The exact impact of this bug is currently unknown, but it's recommended to update to v0.8.5 for anyone engaged in SDXL training to ensure optimal performance and results.
- **Upgrade of `lycoris_lora` Python Module**
- Updated the `lycoris_lora` module to version 2.2.0.post3. This update may include bug fixes, performance improvements, and new features.
#### Recommendations for Users
- To benefit from the latest features and improvements, users are encouraged to update their installations and configurations accordingly.
### 2024/03/13 (v23.0.11)
- Increase icon size
- More setup fixes
- Increase icon size.
- More setup fixes.
### 2024/03/13 (v23.0.9)
- Reworked how setup can be run to improve Stability Matrix support
- Add support for huggingface based vea path
- Reworked how setup can be run to improve Stability Matrix support.
- Added support for huggingface-based vea path.
### 2024/03/12 (v23.0.8)
- Add the ability to create outout and logs folder if it does not exist
- Add the ability to create output and logs folder if it does not exist
### 2024/03/12 (v23.0.7)
- Fix minor issues related to functions and file path
- Fixed minor issues related to functions and file paths.
### 2024/03/11 (v23.0.6)
- Fix issue with PYTHON path that have "spaces" in them
- Fixed an issue with PYTHON paths that have "spaces" in them.
### 2024/03/11 (v23.0.5)
- Update python module verification
- Remove cudnn module installation in windows
- Updated python module verification.
- Removed cudnn module installation in Windows.
### 2024/03/10 (v23.0.4)
- Update bitsandbytes to 0.43.0
- Add packaging to runpod setup
- Updated bitsandbytes to 0.43.0.
- Added packaging to runpod setup.
### 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.
- Fixed a bug with setup.
- Enforced 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
- Improved validation of the path provided by users before running training.
### 2024/03/09 (v23.0.1)
- Update bitsandbytes module to 0.43.0 as it provide native windows support
- Minor fixes to code
- Updated bitsandbytes module to 0.43.0 as it provides native Windows support.
- Minor fixes to the code.
### 2024/03/02 (v23.0.0)
- Use sd-scripts release [0.8.4](https://github.com/kohya-ss/sd-scripts/releases/tag/v0.8.4) post commit [fccbee27277d65a8dcbdeeb81787ed4116b92e0b](https://github.com/kohya-ss/sd-scripts/commit/fccbee27277d65a8dcbdeeb81787ed4116b92e0b)
- Major code refactoring thanks to @wkpark , This will make updating sd-script cleaner by keeping sd-scripts files separate from the GUI files. This will also make configuration more streamlined with fewer tabs and more accordion elements. Hope you like the new style.
- This new release is implementing a significant structure change, moving all of the sd-scripts written by kohya under a folder called sd-scripts in the root of this project. This folder is a submodule that will be populated during setup or gui execution.
- Used sd-scripts release [0.8.4](https://github.com/kohya-ss/sd-scripts/releases/tag/v0.8.4) post commit [fccbee27277d65a8dcbdeeb81787ed4116b92e0b](https://github.com/kohya-ss/sd-scripts/commit/fccbee27277d65a8dcbdeeb81787ed4116b92e0b).
- Major code refactoring thanks to @wkpark. This will make updating sd-scripts cleaner by keeping sd-scripts files separate from the GUI files. This will also make configuration more streamlined with fewer tabs and more accordion elements. Hope you like the new style.
- This new release is implementing a significant structure change, moving all of the sd-scripts written by kohya under a folder called sd-scripts in the root of this project. This folder is a submodule that will be populated during setup or GUI execution.
16 changes: 16 additions & 0 deletions config example.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copy this file and name it config.toml
# Edit the values to suit your needs

# Default folders location
models_dir = "./models" # Pretrained model name or path
train_data_dir = "./data" # Image folder (containing training images subfolders) / Image folder (containing training images)
output_dir = "./outputs" # Output directory for trained model
reg_data_dir = "./data/reg" # Regularisation directory
logging_dir = "./logs" # Logging directory
config_dir = "./presets" # Load/Save Config file
log_tracker_config_dir = "./logs" # Log tracker configs directory
state_dir = "./outputs" # Resume from saved training state
vae_dir = "./models/vae" # VAEs folder path

# Example custom folder location
# models_dir = "e:/models" # Pretrained model name or path
File renamed without changes.
Empty file added dataset/logs/.gitkeep
Empty file.
Empty file added dataset/outputs/.gitkeep
Empty file.
Empty file added dataset/regularization/.gitkeep
Empty file.
Loading

0 comments on commit 726f5b3

Please sign in to comment.