SDXL用LECOの学習をしてみる
参考
https://note.com/tori29umai/n/n33bec5aba718LECOでSDXLモデルを学習する
https://zenn.dev/aics/articles/lora_for_erasing_concepts_from_diffusion_modelsStable Diffusion から特定の概念を忘れさせる学習を行ってみる
https://civitai.com/articles/1766【GoodBye,AllQualityWords】bdsqlsz LoRA training Advanced Tutorial(3):Best Finetune with DB
ソフトのダウンロードとインストール
https://civitai.com/models/129028/leco-lora-train8gb-sdxl-lora-train24gbLECO LoRA train(8GB) SDXL LORA train(24GB)
https://github.com/p1atdev/LECOp1atdev/LECOベースでSDXLを扱えるようにしてある
解凍する
PowerShellを管理者権限で開き、Set-ExecutionPolicy Unrestricted
Aを選択して閉じる
install.ps1を右クリックしてPowerShellで実行
勝手にインストールが始まる
設定ファイルの編集
$ path\to\lecoLoraTrain8GBSDXL_v20\examples
内のconfig.yamlとprompts.yamlをコピペしてそれぞれ適当にリネーム
中身を書き換える
詳しいことはは作者さんの記事で→Stable Diffusion から特定の概念を忘れさせる学習を行ってみる
nomadoor.iconが作りたいもの
人間が生成されないようにする
全然上手くいかない…
code:goodbye-human_config.yaml
prompts_file: "./examples/goodbye-human_prompts.yaml"
pretrained_model:
name_or_path: "F:/lecoLoraTrain8GBSDXL_v20/base_model/sd_xl_base_1.0_0.9vae.safetensors" # you can also use .ckpt or .safetensors models
v2: false # true if model is v2.x
v_pred: false # true if model uses v-prediction
network:
type: "lierla" # or "c3lier"
rank: 4
alpha: 1.0
training_method: "full" # selfattn, xattn, noxattn, or innoxattn
train:
precision: "bfloat16"
noise_scheduler: "ddim" # or "ddpm", "lms", "euler_a"
iterations: 500
lr: 1e-4
optimizer: "AdamW"
lr_scheduler: "constant"
max_denoising_steps: 50
save:
name: "goodbye-human"
path: "./output"
per_steps: 200
precision: "bfloat16"
logging:
use_wandb: false
verbose: false
other:
use_xformers: true
prompts_file: prompt.yamlへのパス
pretrained_model:
name_or_path: SDXLモデルへのパスへ変更
パスの中に絵文字が入っているとパスを認識しなくなる
v2:
SDXLならfalseに
v_pred:
SDXLならfalseに
network:
type: lierlaが通常のLoRAでc3lierがLoCon
train:
LoRAの学習設定
save:
name: 好きな名前に
code:goodbye-human_prompts.yaml
- target: "human" # what word for erasing the positive concept from
positive: "human" # concept to erase
unconditional: "" # word to take the difference from the positive concept
neutral: "" # starting point for conditioning the target
action: "erase" # erase or enhance
guidance_scale: 1.0
resolution: 1024
dynamic_resolution: true
batch_size: 2
- target: "man"
action: "erase"
guidance_scale: 1.0
resolution: 1024
dynamic_resolution: true
batch_size: 2
- target: "woman"
# …続く…
eraseの場合はtargetのみで良いらしい
action:
erase 概念を消す(LECOの標準動作)
enhance LECOの応用で複数のトークンをまとめる
cf. LECOがやっていることを解説する
guidance_scale:
多分1で良い
resolution:
SDXLは1024✕1024に最適なされているので1024に
dynamic_resolution:
?
batch_size:
vram8GBなら2~3
上記のようにtargetはいくらでも記述できる
実行
train_leco.ps1を編集
code:train_leco.ps1
# Train data config | 设置训练配置路径
$config_file = "./examples/goodbye-human_config.yaml" # config path | 配置路径
ここにさっき作ったconfig fileのパスを指定する
train_leco.ps1を右クリックしてPowerShellで実行