LoRAと遊ぶ
LoRAを試す
方針
✅まずAUTOのLoraを触る
(不実行)学習が必要ならAUTOのDreamBoothで実行するsd-scriptsのDreamBoothで学習する
LoRAと遊ぶ#63efbfe6774b170000004840
✅kohya-ssのキャプションベースの手法を実行して確認する
気づき
trigger word
weights are different
やり方調べる
2023/1/21にAUTOMATIC1111版Stable Diffusion web UIでできるようになったらしい? https://github.com/Danamir/stable-diffusion-webui/commit/855b9e3d1c5a1bd8c2d815d38a38bc7c410be5a8
https://gyazo.com/12beedae2a86731de3958f3c22cda6cbhttps://gyazo.com/660dbfa4aea77e9b6149999e8880b324
https://github.com/AUTOMATIC1111/stable-diffusion-webui/wiki/Features#extra-networks
added details in wiki 1/26
https://github.com/AUTOMATIC1111/stable-diffusion-webui/wiki/Features/_history
Loras (same as Hypernetworks but more pretty)
しかしAUTOのLoRAサポート(Not dreamboothサポート)ではtrainingにはkohya-ssのscriptsが推奨されている
A good way to train Lora is to use kohya-ss.
https://github.com/kohya-ss/sd-scripts/blob/main/train_network_README-ja.md
WebUI等で画像生成する場合には、学習したLoRAのモデルを学習元のStable Diffusionのモデルにこのリポジトリ内のスクリプトであらかじめマージしておくか、こちらのWebUI用extensionを使ってください。
画像生成AIでオリキャラを出す#63efac3a774b17000049c031では多分DreamBoothを使っている
https://dskjal.com/deeplearning/dreambooth.html
how to use
https://youtu.be/omOlqAsBKfE?t=342
2022年12月9日には DreamBoothのextensionで実装されている
Feature Request : PLEASE AUTOMATIC1111 add Lora · Issue #5524 · AUTOMATIC1111/stable-diffusion-webui · GitHub
2022年12月19日 AUTOMATIC1111版Stable Diffusion web UI上でLoRAを利用する手順(Windows、VRAM 8GB以上、CUDA 11.6以上)|まゆひら|noteこの記事はこれを使っている
拡張機能としても存在してる(違いは何?)
GitHub - kohya-ss/sd-webui-additional-networks
This extension is for AUTOMATIC1111's Stable Diffusion web UI, allows the Web UI to add some networks (e.g. LoRA) to the original Stable Diffusion model to generate images.
現在は LoRA のみ対応しています。
この拡張で使えるのはsd-scriptsリポジトリで学習した LoRA のモデル(*.ckpt または *.safetensors)です。他の LoRA リポジトリで学習したモデルは対応していません。https://github.com/kohya-ss/sd-scripts/blob/main/README-ja.md
つまりこの人のscriptを使ってLoRAを学習させて、それを利用することができる拡張ということ基素.icon
ではLoRAをどう学習させるのか?
sd-scriptsでは学習方法は2種類提供されている
どっちがいいの?基素.icon
DreamBoothの手法
identifier(sksなど)とclass、オプションで正則化画像を用いる
https://github.com/kohya-ss/sd-scripts/blob/main/train_db_README-ja.md
これとLoRAと遊ぶ#63efb606774b17000088f83eは同等なの?基素.icon
NAIの提案ベースの手法
https://github.com/kohya-ss/sd-scripts/blob/main/fine_tune_README_ja.md
キャプションを用いる
NovelAIの提案した学習手法
自動キャプションニング
タグ付け
DeepDanbooru or WD14Tagger
Diffusersを用いてStable DiffusionのU-Netのfine tuningを行います。NovelAIの記事にある以下の改善に対応しています(Aspect Ratio BucketingについてはNovelAIのコードを参考にしましたが、最終的なコードはすべてオリジナルです)。
デフォルトではAuto Encoderの学習は行いません。モデル全体のfine tuningではU-Netだけを学習するのが一般的なようです(NovelAIもそのようです)。オプション指定でText Encoderも学習対象とできます。
example
LoRAを使ってみよう|感想日記
https://gyazo.com/cc24c6bf9be57b3f638c8242be8e39b7
https://github.com/AUTOMATIC1111/stable-diffusion-webui/wiki/Features#lora
A method to fine tune weights for CLIP and Unet, the language model and the actual image de-noiser used by Stable Diffusion, published in 2021. Paper. A good way to train Lora is to use kohya-ss.
Support for Lora is built-in into the Web UI, but there is an extension with original implementation by kohyaa-ss.
Currently, Lora networks for Stable Diffusion 2.0+ models are not supported by Web UI.
Lora is added to the prompt by putting the following text into any location: <lora:filename:multiplier>, where filename is the name of file with Lora on disk, excluding extension, and multiplier is a number, generally from 0 to 1, that lets you choose how strongly Lora will affect the output. Lora cannot be added to the negative prompt.
The text for adding Lora to the prompt, <lora:filename:multiplier>, is only used to enable Lora, and is erased from prompt afterwards, so you can't do tricks with prompt editing like [<lora:one:1.0>|<lora:two:1.0>]. A batch with multiple different prompts will only use the Lora from the first prompt.