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

画像のアルファチャンネルをlossのマスクとして使用するオプションを追加 #1223

Open
wants to merge 16 commits into
base: dev
Choose a base branch
from

Conversation

u-haru
Copy link
Contributor

@u-haru u-haru commented Mar 29, 2024

透過画像のアルファチャンネルをlossのマスクとして利用出来るようにします。

  • デフォルトだとImage.open().convert("RGB")の際にアルファチャンネルが消えて単色の背景(灰色?)が設定されるため、学習したモデルにも背景が移りやすい
  • 背景を学習させないために、lossに対してアルファチャンネルをマスクとして適用することで透過部分のlossを0にする
  • alpha_maskオプションで使用

ControlNetで使われていた(?) apply_masked_lossを少し変更して使用しています。

例:
tmpb2pm9slo
(Layer Diffusionを用いて生成)

透過画像30枚をそのまま学習データとし、alpha_maskをon/offでそれぞれ800step程度学習
image

@u-haru u-haru marked this pull request as ready for review May 8, 2024 08:55
@u-haru
Copy link
Contributor Author

u-haru commented May 8, 2024

SD1.5では上手く動いていますが、SDXLでの検証がVRAM不足により行えていません…😭

@kohya-ss
Copy link
Owner

kohya-ss commented May 8, 2024

ありがとうございます。原理的にはSDXLでもそのまま動きそうですね。こちらで検証したいと思います。時間でき次第確認、マージいたします。

@u-haru
Copy link
Contributor Author

u-haru commented May 8, 2024

お手数おかけします…🙏🙏🙏

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.

None yet

2 participants