Basic LoRa Training with Kohya

Basic LoRa Training with Kohya

Introduction

Creating unique AI art often requires custom models and datasets. This updated tutorial on training a LoRa with Kohya offers a streamlined process, surpassing the older version's usability. For those who prefer, the previous tutorial is still available. Follow this step-by-step guide to enhance your training efficiency with the current builds as of 5/18/2024.

Step 1: Launching Kohya

Launch: Start Kohya on a Medium or Large server. I recommend Large.

Navigate: Go to the Lora tab.

Step 2: Data Preparation


This tutorial assumes you already have a dataset of images and text files prepared.

Instance Prompt: What would trigger your image if someone typed it in as a Token in a prompt.
Class Prompt: Person, style, etc
Training Images: /mnt/private/train/(you folder name with your images and captions)/
Repeats: 20-40
Regularization Images: If you are training a person you may wish to setup regularization images but not necessary for this tutorial right now.
Destination Training Direction: /mnt/private/train/  ← That / is important don’t forget those and avoid extra spaces after them it can throw an error.Then click Prepare Training Data This will create a series of folders that we can then use to train our Lora.  Now you can minimize this section by clicking on Data Preparation again.

Step 3: Metadata (Optional can skip)

Metadata title: Optional title for model metadata
Data Metadata Author: Your name
Metadata License: If you want to include a license for your model.
Metadata tags: Any tags you wish to add separate them by commas.

Step 4: Model

Pretrained Model: stabilityai/stable-diffusion-xl-base-1.0
Trained Model output name: Write the name of your model.
Image Folder: /mnt/private/trained/img/
Training Comment: Personal preference if you want to add any notes here like what words to use to trigger the model. 

Step 5: Model Folders

Output Directory for trained model: /mnt/private/train/model/ Logging Directory: /mnt/private/train/log/

Step 6: Parameters

There are many ways to train a Lora. Here is a simple one to get you started. Will we use a preset which will fill out most of it for us.

Presets: SDXL - Lora AI_Now prodigy v1.0 
Epochs: You may edit this standard I between 5-10
Network Rank: 64
Network Alpha: 32

6.1 Advanced
Save every N Steps
: If you have the storage I like to do every 100-200 steps and test them all until I’m happy.

6.2 Samples
Samples every N Steps:
100
Sample Sampler: This is up to you and is a matter of preference.
Sample Prompt: a mouse, 8k resolution, photograph, good quality --n bad quality,poor quality, blurry, bad composition --w 1024 --h 1024 --d 3456, --l 6.5,  --s 28

Finally! Now Click Start Training at the bottom.

On the left click the below symbol to open up the logs.You can then watch as it trains!

If you want to check on the training you can go to /mnt/private/sample  and it will save there images depending on how often you told it to save samples. Good luck!

About the author
Adam Stewart

Great! You’ve successfully signed up.

Welcome back! You've successfully signed in.

You've successfully subscribed to .

Success! Check your email for magic link to sign-in.

Success! Your billing info has been updated.

Your billing was not updated.