DCAI
Loading Light/Dark Toggl

How to create an original character LoRA [Preparation] Kohya SS GUI Installation and basic operations

⏱️24min read
📅 Mar 09, 2025
🔄 Mar 09, 2025
Category:📂 Advanced
How to create an original character LoRA [Preparation] Kohya SS GUI Installation and basic operations featured Image
Supported by

Once you are familiar with AI illustration generation, wouldn’t you like to create your own original LoRA by generating original characters and costumes? I will explain how to create your own original LoRA character in several articles, starting with this one, and you will learn faster if you understand machine learning. I will not explain machine learning in detail, but let’s try to understand at least a shallow part of it through learning LoRA.

PR
Image of Intel® CoreTM i9-14900K New Gaming Desktop Processor 24 (8 P-cores + 16 E-cores) with Integrated Graphics - Unlocked
Intel® CoreTM i9-14900K New Gaming Desktop Processor 24 (8 P-cores + 16 E-cores) with Integrated Graphics - Unlocked
🔗Amazon-Usa Link
Image of WD_BLACK 2TB SN850X NVMe Internal Gaming SSD Solid State Drive - Gen4 PCIe, M.2 2280, Up to 7,300 MB/s - WDS200T2X0E
WD_BLACK 2TB SN850X NVMe Internal Gaming SSD Solid State Drive - Gen4 PCIe, M.2 2280, Up to 7,300 MB/s - WDS200T2X0E
🔗Amazon-Usa Link

What is LoRA?

The following is a brief explanation of LoRA as you build your own LoRA.

LoRA (Low-Rank Adaptation) is a technology for efficiently fine-tuning image generation AI such as Stable Diffusion and Flux.1, and large-scale language models (LLM) such as Llama and GPT series. By retaining the base model and training additional small layers, only the necessary parts can be learned without destroying the original model. This allows learning model-specific styles and features with very small data and resources compared to the base model.

It can also be trained with fewer resources, so depending on the configuration, it can be trained on an 8 GB VRAM machine.

To learn more, please refer to the following link.

About Kohya SS

First, as a [Preparation] section, we will start with the learning script “kohya-ss/sd-scripts”.

kohya-ss/sd-scripts, developed by kohya-ss, is a CLI-based learning script that can be used with LoRA, LyCORIS, and DreamBooth.

Since this script requires operation through the CLI (command line interface), it is often considered difficult for those who are not familiar with it, but once you get used to it, it is not that difficult.

In addition to sd-scripts, other training scripts include Huggingface’s 🔗diffusers and invoke-ai’s 🔗InvokeAI.

And this time, we will install “Kohya’s GUI”, which allows you to operate kohya-ss/sd-scripts with a GUI (Graphic User Interface).

Installing the Kohya SS GUI

If you have installed “A1111 WebUI” or “ComfyUI” in the past, you can easily install them as they are almost identical. Follow the steps in order to ensure a reliable installation.

Required Environment before installing Kohya SS GUI

The following environment is required to run Kohya SS GUI.

A1111 WebUI recommends Python 3.10.6, but the Python 3.10.11 introduced here also works fine because of the micro version difference.

Installation of Kohya SS GUI itself

As usual, clone from the GitHub repository.

Preparation of clones

Open a command prompt and use the following command to navigate to your home folder (e.g. C:\Users\Your user name). You may set it to any location of your choice.

cd %userprofile%

Repository Cloning

Next, clone the bmaltais/kohya_ss repository by executing the following command.

git clone --recursive https://github.com/bmaltais/kohya_ss.git

Move to kohya_ss directory

When the clone is complete, run the following command to the repository directory

cd kohya_ss

Running Setup

Once in the directory, run the following command to begin setup (requires Python 3.10.11)

.\setup.bat

If you have another version of Python installed besides Python 3.10, use the following command to specify the version and start setup.

.\setup-3.10.bat

Installing Kohya ss GUI

When the Kohya ss setup menu appears, enter 1 for “Select an option” to install the Kohya ss GUI. The installation will take a few minutes.

(Optional) Installation of CUDNN 8.9.6.50

If your GPU is NVIDIA 30X0/40X0 series, enter 2 in “Select an option” and install CUDNN 8.9.6.50. You will see a slight performance increase.

Finish Setup

Type 7 in “Select an option” to exit the setup. When finished, you may close the command prompt. This completes the installation of the Kohya SS GUI.

Supported by

How to launch Kohya SS GUI

To launch Kohya SS GUI, open the folder where Kohya SS GUI is installed in Explorer.

Run gui.bat in the folder.

After a while, you will see Running on local URL: http://127.0.0.1:7860 as shown in the image below. Clicking on it while holding down Ctrl on the keyboard will launch the Kohya SS GUI in your browser.

How to exit the Kohya SS GUI

To exit the Kohya SS GUI, do not simply close your browser. Open a running command prompt and type Ctrl + c to exit the server.

When you exit the server, the command prompt is in the virtual environment (venv). You can close the command prompt directly, but if you want to close it with care, type the command deactivate to exit the virtual environment, and then close the command prompt.

How to update the Kohya SS GUI

To update the Kohya SS GUI, simply pull command the repository.

Open the Kohya SS GUI directory

Open a command prompt and enter the following command to open the Kohya SS GUI directory. *If you have installed the software in a location of your choice, the following commands are not available.

cd %userprofile%\kohya_ss

Pull the Kohya SS GUI repository

Once you are in the directory, run the pull command with the following command.

git pull

Kohya SS GUI re-setup

After the pull command is complete, re-setup with the following command.

.\setup.bat

Reinstallation of Kohya SS GUI

When the setup menu appears, enter 1 in Select an option to reinstall Kohya ss GUI.

(Optional) Reinstallation of CUDNN 8.9.6.50

After the reinstallation is complete, CUDNN will revert to the old version, so enter 2 in Select an option to install CUDNN 8.9.6.50.

This completes the update of the Kohya SS GUI.

How to install any version of Kohya SS GUI

To install any version of the Kohya SS GUI, run the checkout command with the hash code of the desired version.

Open the repository’s release page

Go to the bmaltais/kohya_ss release page.

Find the version you want to return

Find the desired version in the list and click on the hash code (red box) on the right.

Copy the hash code after github.com/bmaltais/kohya_ss/commit/ at the address of the page opened in your browser.

Open the Kohya SS GUI directory

Open a command prompt and enter the following command to open the Kohya SS GUI directory. If you have installed the software at a location of your choice, the following command is not available.

cd %userprofile%\kohya_ss

Execute checkout command

Once in the directory, execute the checkout command using the hash code you just copied.

git checkout df0c81db560ac139cd7ebd0bf471ef58f72a962f

Kohya SS GUI re-setup

After the pull command is complete, re-setup with the following command.

.\setup.bat

Reinstallation of Kohya SS GUI

When the setup menu appears, enter 1 in Select an option to reinstall Kohya ss GUI.

(Optional) Reinstallation of CUDNN 8.9.6.50

After the reinstallation is complete, CUDNN will revert to the old version, so enter 2 in Select an option to install CUDNN 8.9.6.50.

To revert to the latest version

If you want to revert to the latest version, use the following command to revert to the master branch.

git checkout master

Run .\setup.bat to reinstall the Kohya SS GUI as you did for the update.

.\setup.bat

This completes the change of the Kohya SS GUI to the desired version.

How to Backup and Uninstall Kohya SS GUI

Backup the following folders for Kohya SS GUI.

  • models: It contains the learning base model. Back up this folder if you want to keep it.
  • presets: It contains the preset files. If you want to keep only the user presets, back up the user_presets in the finetune and lora folders.

To uninstall, simply delete the cloned folder kohya_ss.

Supported by

How to use the Kohya SS GUI

This time, only LoRA learning will be explained; the basics are the same for Dreambooth and Textual Inversion.

Description of interface

Screen of Kohya SS GUI
*Mode is set to LoRA.
Open Image
  • Mode Switching Tabs: Switches between modes such as Dreambooth, LoRA and Textual Inversion.
  • Page Switching Tabs: Switch between pages of tools, etc.
  • Configuration Parameters Area: Enter configurations and study parameters.
  • Start training button: Used to start training.
  • Print training command button: Export a configuration file (.toml) to the model folder, which can be used as a configuration file in sd-scripts.
  • Start tensorbord button: You can check the training logs. The log folder must be specified for confirmation.

Basic operation of LoRA Training

As a practical example, let’s try training with SD1.5, which is lightweight, and although you may not be satisfied with the quality of SD1.5 compared to SDXL, you can try and learn various settings with SD1.5, which allows you to train in a short period of time.

Download Dataset

To train, you will need a dataset with training images and image captions. Let’s download the 🔗ZunZun PJ Illustration/3D Data (Japanese) “Training Data for AI Image Models” to train. You can go to Google Drive by clicking “Download data for image training” at the bottom of the linked page.

The dataset will be “02_LoRA trained data_Mr. B provided version_background transparency > zunko”, but the caption did not include an instance (znk), so the modified dataset and sample LoRA for this study are placed on the DCAI drive.

Creating a Training Folder

Create it in an arbitrary location with a name that will be easy to recognize later, such as “zunko-sd15”.

Once created, unzip the Tohoku Zunko Zip file you just downloaded and put it in the “zunko-sd15” folder as the dataset source folder.

Then create empty folders in the folder with the names log and model.

Creating a Dataset Folder

Start the Kohya SS GUI and switch the mode to LoRA. (*Beware that you may forget to switch this and end up working with the “Dreambooth” tag.)

After switching, enter the following in the “Dataset Preparation” field in the configuration parameter area.

  • Instance prompt: Enter the instance. Enter a unique name for the instance that is not used elsewhere. In this case, I chose znk.
  • Class prompt: Enter the class. Enter a generic name for the class. In this case, I chose 1girl because it is a character.
  • Training images (directory containing…): Specify the dataset source folder. Press the 📂 button to select zunko in the training folder “zunko-sd15”.
  • Repeats: Enter the number of times the training image will be repeated. In this case, I set the number to 10.
  • Destination training directory (where formatted…): Specify the learning folder. Press the 📂 button to select the learning folder zunko-sd15.

After inputting the data, click the “Prepare training data” button to create the data set. A dataset folder named “img” will be created in the “zunko-sd15” folder, and a copy of the data set “10_znk 1girl” will be created in it.

Then, use the “Copy info to respective fields” button to reflect the parameters in the “Folders” and “Models” in the configuration parameter area.

Select a training base model and enter a LoRA model name

Next, enter the training base model and the name of the LoRA in the “Model” field. Since the training base model is not included in the installation, download the model from the link below and place it in \kohya_ss\models\.

Once the training base model is ready, enter the following

  • Pretrained model name or path: Select a training base model. Press the 📄 button to select the model you just downloaded.
  • Trained Model output name: Specify a file name for LoRA. The file name can be specified freely, but it should be DCAI_Zunko_V1.

Image folder (containing…) was automatically populated when the “Copy info to respective fields” button was pressed in the previous step.

Enter parameters (Basic)

After setting up the model information, let’s move on to entering parameters. Enter parameters for “Basic” under “Parameters” as shown below.

Upper part of parameter (Basic)
Upper part of parameter (Basic)
Open Image

There are many input fields, which may be confusing at first, but this time we will keep the defaults as much as possible to make it easier for beginners to understand, while setting only the parts that are important for LoRA learning.

  • Epoch: The epoch is the number of iterations for one round of the dataset (number of training images x number of iterations) divided by the number of batches (Train batch size). One epoch in this case is {(51 training images x 10 repetitions) / 1 batch}, which amounts to 510 steps. I want the total number of steps to be around 2500, so if I specify 5, (510 x 5), the total number of steps will be 2550. It is also more stable when the number of epochs is smaller than the number of repetitions of the training image. (❌ repetition = 5, epoch = 10 specified)
    Comparison data
    LOSS/AVERAGE comparison for this LoRA. Cyan: Repetition = 10, Epoch = 5 vs Orange: Repetition = 5, Epoch = 10
    Open Image
  • Max train steps: Specify the maximum number of training steps. In this case, the total number of steps is calculated in epochs, so set it to 0.
  • Save every N epochs: Save the LoRA for each specified number of epochs. This allows you to see the optimal number of training steps. In this case, since it is not necessary, set it to 0 and do not save the intermediate steps. If you would like to see the progress along the way, leave it at 1.
  • Seed: Enter a seed value for training. 0 means random. If you want to experiment with different settings, set it to other than random. If you want to use the same settings as the sample LoRA, set it to 123.
  • LR Scheduler: Specify the scheduler for the LR (learning rate). In this case, we will use the default, cosine. cosine provides stable learning as the LR converges gently.
    TenseBord graph of LR scheduler
    cosine LR scheduler graph. The beginning is rising slowly because LR warmup is specified.
    Open Image
  • Optimizer: Specify the optimizer. In this case, use AdamW; if you have less VRAM, use the default AdamW8bit.
Lower part of parameter (Basic)
Lower part of parameter (Basic)
Open Image
  • Learning rate: Specifies the basic learning rate; if Text Encoder learning rate and Unet learning rate are specified, they take precedence. However, even if the Unet learning rate is used, there will be subtle effects (as a result of learning at 0.0001 and 0.0003 with the same settings), so set the rate to 0.0003 or 3e-4 in the E notation, the same as the Unet LR.
  • LR warmup (% of total steps): Slowly raise LR to the specified value in the initial training step. In this case, I want to raise it a little faster than the default, so I set it to 5.
  • Text Encoder learning rate: Specifies the LR of the text encoder (TE). This value is very important for learning quality and controls how the AI interprets prompts during generation. Generally, 1/2 or 1/10 of the Unet learning rate is a good value. In this case, let’s go a little lower and set it to 0.00003 or 3e-5.
  • Unet learning rate: Specifies the LR of the Unet. This value is also very important for the quality of the training, learning the relationship between the elements of the training image and their position in the structure. In this case, we set it to 0.0003 or 3e-4.
  • Network Rank (Dimension): Specify the amount of information for Unet and TE. Generally speaking, the larger the better, but if it is too large, unnecessary information will be learned, so for AI illustrations, use around 8/16/32/64.
  • Network Alpha: It acts like a damper to prevent underfitting. Generally, a value equal to or half of the Network Rank (Dimension) is used; do not use a value higher than Rank. In this case, we use 16, half of the Rank. If this value is too low, it is likely to be underfitted, while if it is too high, the learned poses and facial expressions may be fixed when generating AI illustrations.
  • Scale weight norms: This value averages the weights so that the trained LoRA does not have too great an impact when used in conjunction with other LoRAs. In this case, it is set to the recommended value of 1. If the influence is strong, increase this value.

Enter parameters (Advanced)

Once you have finished entering parameters (Basic), let’s move on to entering parameters (Advanced). Enter parameters for “Advanced” under “Parameters” as shown below.

  • Additional parameters: You can add parameters that are not available in the Kohya ss GUI. Since the training image in this case is a PNG transparent data, we can use masked loss to avoid learning the transparent part of the image. Kohya ss GUI does not have a GUI to directly use the transparent data embedded in the image (there is a way to refer to the masked data), so enter --alpha_mask here to enable it.
  • Clip skip: Specify the Clip skip value. In this case, the skip value is set to 2 for illustrations.
  • Max Token Length: Specify the maximum number of tokens for caption data. This time the data is more than the default of 75, so set it to 150.
  • CrossAttention: Specify the cross-attention. The default xformers is fine, but if your GPU is an NVIDIA 30X0/40X0 series, sdpa will give you better performance.
  • Min SNR gamma: Smoothes the average loss (average difference from the training source image) to stabilize the training. In this case, we will use the paper’s recommended value of 5.

Training Results

Training Results
The image is post-processed for color.
Open Image

I used the trained LoRA to generate an AI illustration. The generated model is “anyorangemixAnything_mint”. The prompt parameters are as follows.

Positive prompts
znk, 1girl, solo, smile, open mouth, yellow_eyes, long_hair, ahoge, hairband, green_hairband, furisode, mini_kimono, sash, obi, tasuki,(muneate:1.1), zettai_ryouiki,
masterpiece, best quality, upper body, standing, sky, mountains, arms behind back<lora:DCAI_Zunko_V1:0.95>
Negative prompts
EasyNegativeV2,( low quality, worst quality, normal quality:1.1), bad anatomy
Parameters
Steps: 20
Schedule type: Automatic
CFG scale: 9.1
Seed: 415943952
Size: 768×512
Model: anyorangemixAnything_mint
Clip skip: 2
ADetailer: true
Hires upscaler: 4x-UltraSharp
Hires steps: 10
Hires upscale: 2
Denoising strength: 0.25

Introducing the LoRA Metadata Viewer

🔗LoRA Inspector 🧐”, a tool for viewing metadata of completed LoRAs and LoRAs published by others, is now available.

There are several tools available on the Internet to view LoRA metadata, but the information was not clear, so we created a tool. If you like, please use this tool to help you learn LoRA.

Conclusion

How about it? In this article, I explained the installation and basic operations of Kohya ss GUI. Since this is a “Preparation” article, the explanation of basic operations was just to try to create LoRA for now, but I would like to explain the parameters in detail in another article. In addition, when studying copyrighted images, please keep it within the scope of hobby or research to protect the rights of the artist.

PR
Image of GIGABYTE GeForce RTX 4080 Super WINDFORCE V2 16G Graphics Card, 3X WINDFORCE Fans, 16GB 256-bit GDDR6X, GV-N408SWF3V2-16GD Video Card
GIGABYTE GeForce RTX 4080 Super WINDFORCE V2 16G Graphics Card, 3X WINDFORCE Fans, 16GB 256-bit GDDR6X, GV-N408SWF3V2-16GD Video Card
🔗Amazon-Usa Link
Image of ASUS TUF Gaming NVIDIA GeForce RTX 4080 Super OC Edition Gaming Graphics Card (PCIe 4.0, 16GB GDDR6X, HDMI 2.1a, DisplayPort 1.4a)
ASUS TUF Gaming NVIDIA GeForce RTX 4080 Super OC Edition Gaming Graphics Card (PCIe 4.0, 16GB GDDR6X, HDMI 2.1a, DisplayPort 1.4a)
🔗Amazon-Usa Link
Supported by