Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

差分学習機能追加 #542

Merged
merged 1 commit into from
May 28, 2023

Conversation

u-haru
Copy link
Contributor

@u-haru u-haru commented May 26, 2023

学習開始前に学習済みのLoRAモデルを適用して、差分のみを学習するオプションを追加します。

  • --base_modules: 差分学習用のベースモデル
  • --base_modules_weight: 差分学習用のベースモデルの比重
    複数のモデルを適用できるようにはなっていますが、2つ以上適用した場合の効果は未検証です。

差分学習の効果についてはエマノンさんの記事(note.com/emanon_14/n/ne83063e33627)をご覧ください。

以下は私の検証です。適当に3Dのモデルを学習させました。

1枚目はそのまま学習、2枚目は3Dの画風を学習したモデルをweight=0.9で適用した上で学習したものです。
2枚目の画像は3Dっぽさがなくなっていると思われます。

00028-4280799944
00008-2089490422

@kohya-ss
Copy link
Owner

PRありがとうございます。素晴らしいですね。確認させていただきます。

@TingTingin
Copy link
Contributor

TingTingin commented May 27, 2023

when exactly would you want to use something like this? Im not clear on the effect that this has

@sdbds
Copy link
Contributor

sdbds commented May 27, 2023

when exactly would you want to use something like this? Im not clear on the effect that this has

see here
https://rentry.co/kopiki_lora

@sdbds
Copy link
Contributor

sdbds commented May 27, 2023

学習開始前に学習済みのLoRAモデルを適用して、差分のみを学習するオプションを追加します。

  • --base_modules: 差分学習用のベースモデル
  • --base_modules_weight: 差分学習用のベースモデルの比重
    複数のモデルを適用できるようにはなっていますが、2つ以上適用した場合の効果は未検証です。

差分学習の効果についてはエマノンさんの記事(note.com/emanon_14/n/ne83063e33627)をご覧ください。

以下は私の検証です。適当に3Dのモデルを学習させました。

1枚目はそのまま学習、2枚目は3Dの画風を学習したモデルをweight=0.9で適用した上で学習したものです。 2枚目の画像は3Dっぽさがなくなっていると思われます。

00028-4280799944 00008-2089490422

Negative weightを使ってもいいですか?

@u-haru
Copy link
Contributor Author

u-haru commented May 28, 2023

Negative weightを使ってもいいですか?

Of course you can use negative weight, but i'm not sure how it would affect.
Just try it :)

@kohya-ss kohya-ss merged commit 226db64 into kohya-ss:dev May 28, 2023
@kohya-ss
Copy link
Owner

moduleという単語が「networkのモジュール名(networks.loraなど)」として使われているため、オプション名を変更させていただこうと思います。ご理解いただければ幸いです。

@u-haru
Copy link
Contributor Author

u-haru commented May 31, 2023

なるほど、分かりました。
ありがとうございます。

@ymzlygw
Copy link

ymzlygw commented Jul 6, 2023

@u-haru Thanks for your work!
By the way, I want to train a lora using '差分学習機能', but I don't know how to write the caption of the image.
And how many repeats for the first train to get overfit and is the same reapeat number and epoch for the second train?
Looking forward to your reply!

@u-haru
Copy link
Contributor Author

u-haru commented Jul 6, 2023

Hello, @ymzlygw !
I usually use WD1.4 tagger to write captions for both training. Trigger words can be used in second training.
It'd be better to prune some tags. Please follow LoRA Training Guide.

In terms of training data, I use approximately 10 to 50 images with several angles and white background for both training. I typically train with batch_size=2 for around 2000 to 3000 steps, but I think it would be better to train more steps on first training.
Training steps example:

Number of Images: 20
Repeats: 20
Epochs: 10
Batch size: 2
-> Train for 2000 steps

@u-haru u-haru deleted the feature/differential_learning branch July 8, 2023 14:08
@ymzlygw
Copy link

ymzlygw commented Jul 10, 2023

LoRA Training Guide

Thanks! I'll try it later!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants