Skip to content

SD 1.5 Support For Advanced Lora Training (train_dreambooth_lora_sdxl_advanced.py) #6449

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

Merged
merged 12 commits into from
Jan 24, 2024

Conversation

brandostrong
Copy link
Contributor

A quick adaptation to support people interested in using this method on 1.5 models.

What does this PR do?

Adds support for 1.5 models on the advanced dreambooth training method laid out by @linoytsaban

Who can review?

@linoytsaban @sayakpaul

A quick adaptation to support people interested in using this method on 1.5 models.
@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

Copy link
Collaborator

@linoytsaban linoytsaban left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR! looks great, excited to see what LoRAs will come out of the advanced script with SD!

I left a few comments regarding compatibility issues for the prompt text encoding, and unet added conditions. I think all should be quite quick to fix if you don't mind taking another look 😊
examples/dreambooth/train_dreambooth_lora.py - this might help with making those adjustments :)

@brandostrong
Copy link
Contributor Author

Thank you so much for the comments Linoy! I appreciate how much detail you just provided me. Admittedly, this was something I quickly put together since I saw a demand for 1.5. It's rather late right now, so when I find time tomorrow I'll make the necessary changes.

Also, did you happen to test your script at all on 1.5, and do you have any comments on the efficacy of it?

@linoytsaban
Copy link
Collaborator

Awesome thanks so much😁
admittedly I only tried the advanced features with sdxl, so I'm intrigued!

as per @linoytsaban 's recommendations. Testing would be appreciated,
@brandostrong
Copy link
Contributor Author

brandostrong commented Jan 4, 2024

I've made the suggested changes, and I've gotten it to train a style so I would appreciate some testing. There seems to be some fundamental differences(at least in naming, this is a bit over my head) between the base sdxl and 1.5 training scripts, but despite this it seems to work. Could you give it a test as well? Also, is there an example dataset and full list of parameters that can be shared and compared?

@linoytsaban
Copy link
Collaborator

Thanks a lot!

There seems to be some fundamental differences(at least in naming, this is a bit over my head) between the base sdxl and 1.5 training scripts, but despite this it seems to work. Could you give it a test as well?

Sure! I'll go over it and run some experiments :)

@brandostrong
Copy link
Contributor Author

Hi, I've spent the last few days testing and it holds up against my similar training in kohya. Both styles and likenesses are successful, though it really excels at styles.

@sayakpaul
Copy link
Member

Thanks so much for your work!

Could we see some results? Also, let's get the code quality fixed, so that we can merge :)

@linoytsaban linoytsaban self-assigned this Jan 9, 2024
Removed some mentions of SDXL, and some arguments that don't apply to sd 1.5, and cleaned up some comments.
@brandostrong
Copy link
Contributor Author

brandostrong commented Jan 22, 2024

Here are some results training a 2d style off the base sd 1.5 checkpoint, I've attached the embedding and lora of a style(and somewhat character) train.
I would say it trains just fine :). @sayakpaul @linoytsaban , thanks for the help, hopefully this meets the quality requirements.

offscriptstyleadv.zip
The instance prompt is "in the style of offscriptstyle"

And attached are some example images from comfyui and wandb:
NVIDIA_Share_MrarE8lvp1
NVIDIA_Share_m5PQrQRVTq
image

@sayakpaul
Copy link
Member

Cc: @linoytsaban

@linoytsaban
Copy link
Collaborator

Looks good @brandostrong! if you don't mind taking a look and merge my 2 suggestions (bug fixes for checkpoint saving) I think we'd be good to go 😁

@linoytsaban
Copy link
Collaborator

Here are some results training a 2d style off the base sd 1.5 checkpoint, I've attached the embedding and lora of a style(and somewhat character) train. I would say it trains just fine :). @sayakpaul @linoytsaban , thanks for the help, hopefully this meets the quality requirements.

offscriptstyleadv.zip The instance prompt is "in the style of offscriptstyle"

And attached are some example images from comfyui and wandb: NVIDIA_Share_MrarE8lvp1 NVIDIA_Share_m5PQrQRVTq image

btw @brandostrong - did you try prompting "in the style of <s0><s1> offscriptstyle"? Just curious because that way we also leverage the new optimized embeddings which should improve results even more :)

@brandostrong
Copy link
Contributor Author

Ah oops, the entire essence of this training workflow, totally forgot. I'll send screenshots in an hour or so with the same seed/prompt. I'm running a long animatediff so my VRAM is currently parked at max

@brandostrong
Copy link
Contributor Author

Looks good @brandostrong! if you don't mind taking a look and merge my 2 suggestions (bug fixes for checkpoint saving) I think we'd be good to go 😁

Was the merge I just made the suggestions? I'm not that experienced with much more than solo git.

@linoytsaban
Copy link
Collaborator

Ah oops, the entire essence of this training workflow, totally forgot. I'll send screenshots in an hour or so with the same seed/prompt. I'm running a long animatediff so my VRAM is currently parked at max

no worries! 😁

@linoytsaban
Copy link
Collaborator

Looks good @brandostrong! if you don't mind taking a look and merge my 2 suggestions (bug fixes for checkpoint saving) I think we'd be good to go 😁

Was the merge I just made the suggestions? I'm not that experienced with much more than solo git.

I believe they were not merged yet :) can you see my new comments? I think that would do it 😊

@brandostrong
Copy link
Contributor Author

brandostrong commented Jan 22, 2024

I'm super sorry, you may need to hold my hand on this one. They are not the original suggested changes, or are they(I see I can review changes and comment but not approve or request)? Can you link me to your new ones?

Here are the updated results with the proper tokens.
ComfyUI_samplerupscale_00112_
ComfyUI_samplerupscale_00109_

Very cool stuff.

@linoytsaban
Copy link
Collaborator

@brandostrong I just committed 2 minor changes to save_model_hook - makes sure we save checkpoints correctly, as per the bug fix in #6464. I think we can ship now 😁🛳️

Copy link
Contributor Author

@brandostrong brandostrong left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thank you :D

@linoytsaban linoytsaban merged commit 16748d1 into huggingface:main Jan 24, 2024
AmericanPresidentJimmyCarter pushed a commit to AmericanPresidentJimmyCarter/diffusers that referenced this pull request Apr 26, 2024
…_advanced.py) (huggingface#6449)

* sd1.5 support in separate script

A quick adaptation to support people interested in using this method on 1.5 models.

* sd15 prompt text encoding and unet conversions

as per @linoytsaban 's recommendations. Testing would be appreciated,

* Readability and quality improvements

Removed some mentions of SDXL, and some arguments that don't apply to sd 1.5, and cleaned up some comments.

* make style/quality commands

* tracker rename and run-it doc

* Update examples/advanced_diffusion_training/train_dreambooth_lora_sd15_advanced.py

* Update examples/advanced_diffusion_training/train_dreambooth_lora_sd15_advanced.py

---------

Co-authored-by: Linoy Tsaban <[email protected]>
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.

4 participants