0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Kohya ssでLoRAを自作した!!

0
Posted at

前回はLoRA学習ツールの設定項目について触れたね。

今回は実際にLoRA学習に挑戦してみよう。

画像素材を集める

LoRA学習に用意する画像は量より質らしい。
また、寸法、拡張子、絵柄を揃えた方がいいみたい。

つまり正面ばかり向いてる画像が沢山あってもしょうがないし、
それぞれ違う寸法だと安定して学習できないみたい。

それに絵柄が違うと不安定になるよね。

今回はVRoidを使わせていただきます。

▼フムフム VRoid Hub
https://hub.vroid.com/characters/4869555797016986872/models/7914376685457949940

3teneのフリー版を使って多方向からキャプチャしてみたよ。

▼3tene(無料版)
https://3tene.com/free/

キャプチャ結果はこんな感じ。

image.png

タグ設定

タグは画像と同じ名前のテキストファイルに用意するよ。
画像がxxx.pngなら、xxx.txtを用意するんだ。

さっきのキャプチャ画像は
3tene_yyyymmddhhmmss.pngだから
3tene_yyyymmddhhmmss.txtを用意する事になるね。

例えばこの画像。
3tene_20260902180921.png
この画像につけるならこんなタグかな。

fum2asahi,4 ears,anthro,black eyes,no sclera ,blue skin,blue theme,chibi,closed mouth,drooping ears,full body,looking at viewer,straight-on
  • fum2asahi 固有名詞
  • 4 ears 4つの耳
  • anthro 二足歩行動物
  • black eyes 黒い目
  • no sclera 白目なし
  • blue skin 青い肌
  • blue theme 青い雰囲気
  • blush 頬が赤い
  • chibi ちびキャラ
  • closed mouth 口を閉じている
  • drooping ears たれ耳
  • full body 全身
  • spiky hair トゲトゲな髪
  • looking at viewer こちらを見てる
  • no humans 人間を描かない
  • simple background シンプルな背景
  • smile 笑顔
  • solo 1体
  • standing 立っている
  • straight-on 正面

これらを全画像に適宜付与する訳。

いちいち記憶してテキストエディタに書き込むのは大変なので、タグ付けは表計算ソフトで管理。
image.png

学習ツールの設定

チェックポイントと画像格納元、出力されるLoRA名を設定。
image.png

出力先フォルダを設定。
image.png

学習回数Epochと、寸法をMax resolutionに設定。
image.png

学習開始

2026-09-14 06:13:11 INFO     use 8-bit AdamW optimizer | {}    optimizer.py:106
enable text encoder training
train unet: True, text_encoder1: True, text_encoder2: True
number of models: 3
number of trainable parameters: 3385184004
prepare optimizer, data loader etc.
running training / �w�K�J�n
  num examples / �T���v����: 330
  num batches per epoch / 1epoch�̃o�b�`��: 330
  num epochs / epoch��: 5
  batch size per device / �o�b�`�T�C�Y: 1
  gradient accumulation steps / ���z�����v����X�e�b�v�� = 1
  total optimization steps / �w�K�X�e�b�v��: 1600

steps:   0%|          | 0/1600 [00:00<?, ?it/s]2026-09-14 06:13:14 INFO     epoch is incremented.               dataset.py:464
                             current_epoch: 0, epoch: 1

steps:   0%|          | 1/1600 [00:38<17:07:17, 38.55s/it]
steps:   0%|          | 1/1600 [00:38<17:07:17, 38.55s/it, avr_loss=0.0273]
steps:   0%|          | 2/1600 [01:16<16:54:54, 38.11s/it, avr_loss=0.0273]
steps:   0%|          | 2/1600 [01:16<16:54:54, 38.11s/it, avr_loss=0.0245]

略

steps: 100%|#########9| 1599/1600 [17:03:54<00:38, 38.42s/it, avr_loss=0.0136]
steps: 100%|#########9| 1599/1600 [17:03:54<00:38, 38.42s/it, avr_loss=0.0137]
steps: 100%|##########| 1600/1600 [17:04:32<00:00, 38.42s/it, avr_loss=0.0137]
steps: 100%|##########| 1600/1600 [17:04:32<00:00, 38.42s/it, avr_loss=0.0136]2026-09-14 23:17:47 INFO                                   checkpoint_io.py:278


steps: 100%|##########| 1600/1600 [17:05:05<00:00, 38.44s/it, avr_loss=0.0136]

epoch 1/5

epoch 2/5

epoch 3/5

epoch 4/5

epoch 5/5
23:18:28-107121 INFO     Training has ended successfully (exit code 0).

出力結果

出力先フォルダに指定しておいたoutputファイルに成果物が格納されてるね。
image.png

じゃあ、このLoRAを使ってStable Diffusion WebUI Forge Neoで画像生成してみよう。
生成設定はこんな感じ。

prompt: <lora:Illustrious_fum2asahi260914:1>4 ears,anthro,black eyes,blue skin,blue theme,blush,chibi,closed mouth,drooping ears,spiky hair,no humans,smile,solo,tail,white tail tip,white ear tips,
Negative prompt: 3 or more legs, animal paw, artist, bad anatomy, bad fingers, bad hands, black and white, disconnected_limbs, error, extra digit, extra_fingers, fewer digits, fuman finger, fuman hands, greyscale, heart tattoo on cheek, heart-shaped blush, inaccurate limb, jpeg artifacts, liquid fingers, logo, low quality, lowres, malformed_hands, missing fingers, missing limb, monochrome, name, out of focus, pads, paw pads, poorly drawn fingers, signature, sketchesboys, teeth, text, ugly, worst quality, 
Steps: 20, Sampler: Euler a, Schedule type: Automatic, CFG scale: 6, Seed: 3073961743, Size: 1334x750, Model: waiIllustriousSDXL_v170, Model hash: f116b0c78f, Module 1: sdxl_vae, RNG: CPU, Lora hashes: "Illustrious_fum2asahi260915: 2ca1452f3980", Emphasis: Original, 

結果はこう。

image.png
……思ってたのと違うなあ。

まとめ

LoRAは確かに自作できた。
そのLoRAで生成した画像が思ったのと違った。
LoRAの出来が悪かったのはKohya ssの設定か、素材画像か、タグ付けのいずれかが原因なんだろうな。
どうしたら思ったようにできるんだろう?

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?