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

[Flux] Add advanced training script + support textual inversion inference #9434

Merged

Conversation

linoytsaban
Copy link
Collaborator

@linoytsaban linoytsaban commented Sep 13, 2024

This PR adds an advanced version of the dreambooth lora flux script, with additional accompanying update to FluxPipline:

  • adds an advanced script with pivotal tuning feature for CLIP & T5 encoder

    • --train_text_encoder_ti (enables CLIP pivotal tuning)
    • --enable_t5_ti adds T5 to the mix
    • --train_text_encoder_ti_frac the portion of epochs to train embeddings on, when using just clip
    • --train_transformer_frac the portion of epochs to train the transformer on, train_transformer_frac==0 will trigger a "pure_textual_inversion" train run (= "classical" textual inversion, no optimization of transformer lora layers)
    • --initializer_token the token to init the textual inversion embeddings with instead of randomly (random by default).
  • --lora_blocks the blocks\layers to apply lora training on.

  • modifies Flux Pipeline (and related pipelines) to allow for textual inversion inference (that is also required by Loras trained with pivotal tuning)

motivation: to allow for fast iterations & experimental features. I think it'd be good to fork the canonical script and bring the above changes into the advanced folder in a similar manner to what we have for SDXL.

cc @apolinario

linoytsaban and others added 28 commits August 12, 2024 17:30
@linoytsaban
Copy link
Collaborator Author

@sayakpaul @apolinario wdyt about me closing #9160 and moving the changes here as I suggest above?

@sayakpaul
Copy link
Member

I would prefer #9160 as it helps to review the changes to the canonical script in isolation. Would that work for you?

@sayakpaul
Copy link
Member

@linoytsaban let me know when you need another review.

Copy link
Member

@sayakpaul sayakpaul left a comment

Choose a reason for hiding this comment

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

Thanks!

@sayakpaul
Copy link
Member

@yiyixuxu could you also give the changes in the pipelines a look? It's just about adding TextualInversionMixin so that we can enable pivotal tuning on Flux.

Copy link
Collaborator

@yiyixuxu yiyixuxu left a comment

Choose a reason for hiding this comment

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

thanks!

Copy link
Collaborator

@apolinario apolinario left a comment

Choose a reason for hiding this comment

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

Let's go! 🚀

@linoytsaban linoytsaban merged commit 9a7f824 into huggingface:main Oct 17, 2024
15 checks passed
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