初めに
OneTrainerは、Stable Diffusionで使用するためのLoRAモデルを学習できるGUIプログラムです。これにより、新しいキャラの追加やスタイルの変更などが可能になります。
注: 記載されていないメニュー/項目はスキップしても問題ありません。または、説明が不要な場合もあります(例: 「サブフォルダーを含める」)。
Note: The English version of this article follows at the end.
インストール
こちらから取得できます。
https://github.com/Nerogar/OneTrainer
説明書はOneTrainerプロジェクトのREADMEに含まれています。
注: AMDに関する情報はREADMEに入っていると思いますが、もしAMD GPUをお使いに問題がある場合は、CUDA用のtorchをpipでアンインストールして、https://pytorch.org/ から以下のコマンドでAMD ROCmをインストールする必要があるかもしれません。
pip3 install torch torchvision --index-url https://download.pytorch.org/whl/rocm6.4
注: もしOneTrainerを実行できないですと、Pythonバージョンに関係ある可能性があります。3.12はAIライブラリーに対象外との噂がありそうですので、その場合に3.11を試してみて。
メニュ概要
general: プログラム固有の情報。
model: 学習に使用するモデル。
data: いくつかの設定。
concepts: 学習データ。
training: 学習設定。
sampling: 学習中のテスト(おそらく古いので、使用しないでください)。
backup: 学習中にモデルのバックアップを作成します。
tools: サブタスクを自動化するためのサブプログラム。
additional embeddings: ほとんどの学習タスクでは必要ありません。
cloud: ローカルPCの代わりにクラウドを使用できます。
LoRA: 出力されるモデルについて。
一般操作
右上隅で、SDXL と LoRA を選択します。
general

Workspace Directory: プログラムが動作する場所です。特にハードドライブ上に配置されている場合は、このディレクトリのサイズが非常に大きくなる可能性があるため、注意してください。
Cache Directory: 上記を参照してください。
Always-On Tensorboard: これを有効にすると、ローカルマシンでホストされている Web インターフェースで学習の進行状況を確認できます。
Tensorboard Port: Web インターフェースのポート番号です。6006 に設定されている場合、 https://localhost:6006 でアクセスできます。
model

Base Model: 技術的にはどのチェックポイントでも学習できますが、実際には実際のベースモデルのみを使用して学習し、ファインチューンは使用しないでください。
Model Output Destination: 学習済みモデルを保存する場所。
concepts
注:例の画像は未公開
上のAdd Conceptを選択。
その下に新たな箱は表示されます。
その箱をクリックして、新たなウィンドウは表示されます。
Concept
general:
- Name: 学習用のデータセット名。
- Path: その画像の場所。
- From text file per sample: 各画像には、同じ名前のテキストファイルが必要です。
(例:5.png -> 5.txt) - From text file: 1つのテキストファイルに、各画像を説明するタグが含まれます。
- Prompt Source: From text fileの場合、そのtxtファイルの場所です。
image augmentation:

個人的には、Crop JitterとRandom Flipは無効にしています。
Resolution Overrideは実装上、少し分かりにくいですが、学習画像は同じ解像度のものを使用するようにしてください。
可能であれば、有効にして画像の解像度に設定してください。
そうでない場合は、無効のままにしてください。
training
調整が必要な主な項目は次のとおりです。
- Learning Rate Scheduler: 主に個人の好みによります。必要なエポック数/ステップ数が既にわかっている場合は、コサイン(Cosine)が一般的な選択肢です。
- Learning Rate: 学習アルゴリズムは、各ステップでこの値に基づいて調整を行います。値が低いほど「ジャンプ」は短くなりますが、結果として「行き詰まる」可能性があります。値が高いと目標値を超えてしまう可能性があります。0.001~0.0001 が適切と思われます。ただし、これは学習速度には影響しません。
- Learning Rate Warmup Steps: 0 から指定した学習率まで、この値で設定したステップ数だけ調整します。アルゴリズムが正しい方向に誘導されるように、通常は 100~1000 を使用することをお勧めします。学習率スケジューラがコサイン(ハード)リスタートの場合、その性質上、この設定は必要ありません。
- Learning Rate Cycles: コサイン(ハード)リスタートでのみ使用されます。これら2つのスケジューラは定期的に実行されるため、この値によってスケジューラの周期が決まります。私は通常、エポック数の5倍の値を使用します。
- Epochs: アルゴリズムがデータセット全体に対して学習する回数。これはステップ数とは異なり、学習期間を決定する上でステップ数の方が重要になる傾向があることに注意してください。この値は、学習画像の数によって異なります。多くの人は20枚の画像で100エポックを使用しますが、私は100~200枚の画像で5エポックを使用します。
- Local Batch Size: 一度に学習する画像の数。この機能は、あるAI学習ライブラリの実装が原因で、AI学習プログラム全般で動作しないという話を聞きましたので、1に設定しました。
sampling
このメニューについて特に言及しているのは、スキップする必要があるからです。このメニューは、学習に使用しているモデルではなく、元のSDモデルで機能するようです。
cloud
このプログラムは通常、自分のGPUを使用して実行されます。通常はこのセクションをスキップできますが、クラウドサービスプロバイダーを使用する必要がある場合は、このセクションを設定する必要があります。
LoRA
- Type: LoRA を選択します。
- LoRA base model: 選択したベースモデルに加えて、既存の LoRA モデルも学習する場合は、LoRA を選択します。通常は空欄のままで問題ありません。
- LoRA rank: 「解像度」です。スタイルには 8、キャラクターには 16、複雑な被写体には 32 が一般的に使用されます。いずれにしても、16 で十分です。ただし、値を大きくするとモデルファイルサイズが大きくなることに注意してください (例: ランク 128 -> 1.2GB)。
- LoRA alpha: 「ボリューム/パワー」です。この値を大きくすると、基本的に学習速度が速くなります。通常は LoRA ランクの半分か 1:1 の間で値を選択します。私は 18 まで上げても問題ありませんでした。
- Decompose Weights (DoRA):比較的新しい学習手法です。興味があれば試してみてください。
LoRA 学習及び使用
すべての設定が完了したら、右下にある緑色の「Start Training」をクリックしてください。学習時間はシステムや設定によって異なりますが、通常は20分から2時間程度かかります。
このドキュメントの範囲外になりますが、ここで簡単に使用方法について説明します。学習が完了したら、ノードリストを更新し、ワークフローにドラッグ&ドロップすることで、ComfyUIでLoRAを使用できます。動作がおかしい場合は、LoRAの重みを調整するか、エポック数を減らしたり増やしたりして再学習してみてください。
Introduction
OneTrainer is a GUI program that can help you train your own LoRA models for use with Stable Diffusion. This allows you to do things such as add new characters or change the art style.
Note: Menus/Items that aren't mentioned in this document are generally safe to skip, or are self-explanatory. (Ex: Include subfolders).
Installation
Instructions are included with the project.
Note: If you are using an AMD GPU, then you may need to uninstall the CUDA related torch packages with pip and then install AMD ROCm with the following command from https://pytorch.org/ :
pip3 install torch torchvision --index-url https://download.pytorch.org/whl/rocm6.4
Note: If you have problems running OneTrainer itself, the problem may be related to your Python version. You may need to install Python 3.11 instead due to an issue with AI library support.
Menu Summary
general: Program-specific stuff.
model: The model you will train against.
data: A few settings.
concepts: Your training data.
training: Training configuration.
sampling: Test while training (Probably outdated, don't use).
backup: Create backups of your model while training.
tools: Some subprograms to help automate common tasks.
additional embeddings: Not needed for most training tasks.
cloud: Use a cloud infrastructure instead of your local machine.
LoRA: Your custom model.
General Usage
In the top right corner, select SDXL and LoRA.
general
- Workspace Directory: This is where the program does its work. Keep an eye on this directory as it can grow tremendously in size, especially if it is located on your hard drive.
- Cache Directory: See above.
- Always-On Tensorboard: Enabling this lets you view training progress in a web interface hosted on your local machine.
- Tensorboard Port: The port number for the web interface. So if it is set to 6006, then you can access it at https://localhost:6006 .
model
- Base Model: Technically you can train with any checkpoint, but you should really only train with actual base models and not finetunes.
- Model Output Destination: Where you want to save your trained model.
concepts
Note: No example picture.
Select Add Concept above.
A new box will appear below.
Click the box to configure the dataset in a new popup window.
When finished, be sure to enable/disable the datasets by clicking the switches on the boxes.
Concept
general:
- Name: The dataset name.
- Path: The location of the dataset images.
- From text file per sample: Every image has its own txt file containing the tags for that specific image.
(例:5.png -> 5.txt) - From text file: All of the tags for every image are contained in a single txt file.
- Prompt Source: When selecting "From text file", this will be the location of that txt file.
image augmentation:

Personally, I disable Crop Jitter and Random Flip.
Resolution Override is a bit tricky to understand due to its implemenation, but try to use training images with the same resolutions.
If you can, then enable it and set it to the resolution of the images.
Otherwise, leave it disabled.
training

These are the main items that need to be adjusted.
- Learning Rate Scheduler: Mostly personal preference. Cosine is a popular choice if you already know how many epochs/steps you need.
- Learning Rate: The training algorithm will adjust itself by this amount through each step. A lower amount means shorter "jumps", but can end up getting "stuck" as a result. Higher amounts can overshoot the target. 0.001-0.0001 seems good. Note that this does NOT affect the speed of training.
- Learning Rate Warmup Steps: Goes from 0 to your specified Learning Rate for this many steps. Generally a good idea to use 100-1000 so that the algorithm can be guided in the right direction. This isn't needed when the Learning Rate Scheduler is Cosine with (hard) restarts due to its nature.
- Learning Rate Cycles: Only used with COSINE WITH (HARD) RESTARTS. Since these 2 schedulers repeat constantly, this value determines how often they cycle. I tend to use 5 times the Epochs value.
- Epochs: How many times the algorithm will train against the entire dataset. Note that this is not the same thing as steps, and steps tend to be more important for determining how long to train for. This value really depends on how many training images you have. Most people use 100 epochs with 20 images, but I use 5 epochs with 100-200 images.
- Local Batch Size: How many images to train together at a time. I heard this feature is broken in AI training programs in general due to the implementation in a certain AI training library, so I set this to 1.
sampling
I'm specifically mentioning this menu because it should be skipped. It appears to work with the original SD model and not the one you are training against.
backup
Useful for comparing models to figure out how many steps are needed. Skipping the first 500 steps and then saving every 500 steps is usually a good idea.
tools
Dataset Tools is useful for automatically tagging images if you're in a hurry.
cloud
This program normally runs by using your own GPU. Normally you can skip this section, but you'll need to configure this if you need to use a cloud service provider.
LoRA
- Type: Select LoRA.
- LoRA base model: Select a LoRA if you are training against a previous one in addition to your selected base model. Normally it's fine to leave this empty.
- LoRA rank: The "resolution". People typically use 8 for styles, 16 for characters, and 32 for complex ideas (Ex: Characters with multiple outfits). 16 is usually fine. Be aware that higher ranks lead to higher file sizes (128 -> 1.2GB).
- LoRA alpha: The "volume/power". Higher values basically let you train faster. 1 is fine, but some people use 1/2 the rank value or even the rank value itself. I've gone up to 18 without issues.
- Decompose Weights (DoRA): A relatively new method of training. Try it if you want.
LoRA Training and Usage
Once everything is set up, click Start Training in the bottom right corner. Training times will vary depending on your system and settings, but typically should take between 20 minutes to 2 hours.
While a bit out of scope for this document, I'll cover usage here briefly. When the training is finished, you can use the LoRA in ComfyUI by refreshing the node list and dragging/connecting it into your workflow. If the output image looks strange, try adjusting the LoRA weight within the node or retraining it with less/more epochs.

