Home Artists Posts Import Register

Content

INDEX:
SD Character LoRA Training Tutorial (Part 01 - Installation)
SD Character LoRA Training Tutorial (Part 03 - Image Gathering and Tagging)
SD Character LoRA Training Tutorial (Part 04 - Testing)

Good reference guide: LINK by The Other LoRA Rentry Guy. (He trains different than me nowadays).
Another good tutorial: The Ultimate Stable Diffusion LoRA Guide (Downloading, Usage, Training)

This part of the tutorial is to help you with the program. It's not yet about the training.

If you followed the first part, you should be able to open kohya_ss and with that running we start this.

There are only TWO tabs that you have to worry for this whole tutorial.

LoRA and Utilities. I will cover Utilities later in Part 03.

NOTE: Pay attention everytime you run kohya it will open Dreambooth tab. Becareful not to train something on that tab using LoRA configuration. Dreambooth is for another kind of model.

In the image above you can see the Training tab that is contained in LoRA tab, right?

This is the most important tab for training. The Tools and Guides are not covered in this tutorial.

So now we have the Source Model tab.

We should use a big model as a base model for our training. Because we will extract just a small part of it. So we can use that small part with other models. (That's how we use a LoRA).

The big model is a checkpoint. I will work with the one I'm most used which is NovelAI. I don't encourage downloading this, but there is a guide for it here. You can use a different one and the settings will be slightly different.

AnyLoRA is a good example, but I think the training will burn up faster. It's better for style. But if you train a character with that you should dampen the learning rate a bit. I'll teach that later. I encourage you to use other stuff instead of NAI. However, the results for characters are usually better with it, sadly.

You don't worry about that for now, but I suggest you already download these models while reading this. (Yes, even NAI if you want to follow my exact values).

Now, there is 3 tabs: Folders, Parameters and Dataset Preparation. I will not cover Dataset Preparation, but if you get used to training I suggest you use that to make it more intuitive.

Now, before that I prepared 2 configuration files that will save you a lot of time.

If you have 8+- GB VRAM Use this: Medium VRAM configuration file
If you have 12+GB VRAM Use this: High VRAM configuration file

Save it in a good folder. Then you can open it by clicking on configuration file button:

Click on Open and select it.

If you run out of memory using the Medium VRAM settings I suggest you study more about the Parameters that could help you like Gradient Checkpoint and maybe reducing the size of your images that you are going to use for training.

Now your screen will be like this:

Click on the marked icon and select the model you are going to use as base for training. You don't have to use the 2 I mentioned before. You can try to search for good base models on your own. After selecting the model on the right folder you can hit the SAVE icon or SAVE AS if you want to save as another file. That is to save you time, because you will not need to do folder and model configuration again next time.

Now go to the folders tab:

You can go to your windows explorer and create a folder in anywhere you want and name it with something like LoRA training or whatever you prefer. Then create folders like this:

You don't have to name it like I did.

Select these folder in this tab of kohya_ss

Save again.

Now the parameters tab is important, but I will only cover a few things for the sake of your mind. I will leave a link at the top of this page with a much more in-depth guide about each thing.

Now I'll explain briefly what are these colored parts and how you can change them:

Train Batch size: You can increase it to speed the training, basically it will make more than 1 run of training at the same time. It will basically double, triple, quadruple the speed. I usually run with 4-6 using the High settings. You should worry too much about it if you can run it above 4 leave it like that and forget about it.

Epoch: It's how many times the training will go through every image you have saved. I will explain how you can calculate the desired epochs when giving you the example with the images. Usually the more = the more precise your choice will be, but don't change this yet.

Learning rate: This is how fast the model will absorb info. If it's too high it will be a burning mess, if it's too low it will not learn your character. If you are using "AnyLoRA" you could try reducing this from 0.0001 to something like 0.00006-0.00008.

Max resolution: This will increase a bit the detail that is saved from your training images, but at the cost of a LOT of VRAM and sometimes it will create problematic results. I suggest you leave it at 576 or 512, you can increase to 768 if you want.

Text Encoder Learning rate and Unet learning rate: I usually leave text encoder learning rate at half the value of Learning Rate, you can leave everything the same value too, but don't leave it higher than the Learning Rate. Unet learning rate I use the same as learning rate.

NOTE: You can increase Number of CPU threads per Core based on your CPU, I usually increase to half the quantity of my CPU threads. Just search how many threads per core your CPU have and do this to increase the training speed a bit.

Now last but not least fro these parameters:

Network Rank (Dimension): This will determine the size of your model and how much info it will be absorbed. The higher, the more details it will have, but it will usually get less flexible faster the more you train it.
For character training I usually train with something from 32-64-128. You don't need 128 if you don't have tons of images. As a rule of thumb if I have something near 30 images, I train with 32, if I have 50+ I train with 64, if I have 100+ I train with 128.
The model size will be +- 1.125x this value. So if it's 32, it will be 36mb+-.
You may want to reduce this if you want to push the flexibility of the model a bit in exchange to some smaller details.

Network Alpha: This will act like a learning rate dampening. It can't have a value higher than Network Rank. I usually leave it at half the Network Rank value, but you can reduce it or increase it. I suggest using the binary number like 8-16-32-64-128 instead of breaking it.

When training we usually want our model to have as much steps as it can without burning it.
What are steps? It's basically a check that the model will make on your training image trying to learn it and have a reward/punish system that will tell on its own if it was a good memory.
With higher learning rates it will try to force the model to copy the image with more similarity, but it can also increase the errors. So slow pace is good for less errors. However, if it's too slow, it will not learn. So you may want to tweak these values I mentioned above when training.

SAVE AGAIN if you made changes that you need saving. Now we are ready for the 'pratical' part.

Next part: HERE

Comments

No comments found for this post.