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

Support LoRA for clip text encoder in diffusers #2479

Closed
wants to merge 1 commit into from

Conversation

haofanwang
Copy link
Contributor

Fix #2469.

Made a PR in transformers first, @sgugger suggests that LoRA has been supported in peft. This PR leans on peft to further support adding LoRA in text encoder.

@haofanwang haofanwang changed the title Update train_text_to_image_lora.py Support LoRA for clip text encoder in diffusers Feb 24, 2023
@HuggingFaceDocBuilderDev
Copy link

HuggingFaceDocBuilderDev commented Feb 24, 2023

The documentation is not available anymore as the PR was closed or merged.

@haofanwang
Copy link
Contributor Author

haofanwang commented Feb 24, 2023

I have run black --check examples tests src utils scripts along with make style and make quality. The fail doesn't seem to be related to this PR. I don't directly change previous API now, but add an if.

GreggHelt2 added a commit to invoke-ai/InvokeAI that referenced this pull request Feb 27, 2023
…ace PEFT library.

Based on huggingface/diffusers#2479 from haofanwang, then modified to get working.
@camenduru
Copy link
Contributor

thanks @haofanwang

@haofanwang
Copy link
Contributor Author

@patrickvonplaten can u take a look at this PR, this support should be very useful for training a LoRA.

lora_dropout=args.lora_text_encoder_dropout,
bias=args.lora_text_encoder_bias,
)
text_encoder = LoraModel(config, text_encoder)
Copy link
Contributor

Choose a reason for hiding this comment

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

The problem is that we cannot really load LoraModel later for inference currently as it's created in a somewhat hacky way here: https://github.com/huggingface/peft/blob/8358b2744555e8c18262f7befd7ef040527a6f0f/src/peft/tuners/lora.py#L90

Could we maybe move everything to the research_folder project instead of adding it to the "easy" LoRA example script?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

make senses to me

@patrickvonplaten
Copy link
Contributor

Maybe cc @williamberman here as well

@haofanwang
Copy link
Contributor Author

will move this to research_folder.

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.

LoRA can not be used in text encoder in "train_text_to_image_lora.py"?
4 participants