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

allow explicit tokenizer & text_encoder in unload_textual_inversion #6977

Merged
merged 15 commits into from
Feb 22, 2024

Conversation

H3zi
Copy link
Contributor

@H3zi H3zi commented Feb 14, 2024

What does this PR do?

Fixes #6974

Currently, unload_textual_inversion only performs unload to tokenizer & text_encoder, originally designed for SD pipelines but doesn't support SDXL, which also uses tokenizer_2 & text_encoder_2.

By allowing passing explicitly the tokenizer & text_encoder to unload textual inversion modules (just like it allows in the load_textual_inversion function) we can support fully unload in SDXL pipelines as well.

Before submitting

Who can review?

@sayakpaul @linoytsaban

@linoytsaban linoytsaban self-requested a review February 14, 2024 13:43
@sayakpaul
Copy link
Member

Hi,

Thanks for your PR. Could you also add an example snippet that shows the usage?

@yiyixuxu WDYT?

@linoytsaban linoytsaban removed their request for review February 14, 2024 13:45
@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.

@H3zi
Copy link
Contributor Author

H3zi commented Feb 14, 2024

@sayakpaul Ive added a snippet based on the example demonstrated here by @linoytsaban, I hope it's OK.

@yiyixuxu
Copy link
Collaborator

cc @fabiorigano can you take a look here?

Copy link
Contributor

@fabiorigano fabiorigano left a comment

Choose a reason for hiding this comment

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

thanks @yiyixuxu for adding me here

looks good to me. I left a few nits

src/diffusers/loaders/textual_inversion.py Outdated Show resolved Hide resolved
src/diffusers/loaders/textual_inversion.py Outdated Show resolved Hide resolved
src/diffusers/loaders/textual_inversion.py Outdated Show resolved Hide resolved
src/diffusers/loaders/textual_inversion.py Outdated Show resolved Hide resolved
src/diffusers/loaders/textual_inversion.py Outdated Show resolved Hide resolved
src/diffusers/loaders/textual_inversion.py Outdated Show resolved Hide resolved
H3zi and others added 7 commits February 18, 2024 09:19
Co-authored-by: Fabio Rigano <fabio2rigano@gmail.com>
Co-authored-by: Fabio Rigano <fabio2rigano@gmail.com>
Co-authored-by: Fabio Rigano <fabio2rigano@gmail.com>
Co-authored-by: Fabio Rigano <fabio2rigano@gmail.com>
Co-authored-by: Fabio Rigano <fabio2rigano@gmail.com>
@H3zi H3zi requested a review from fabiorigano February 18, 2024 10:06
Copy link
Contributor

@fabiorigano fabiorigano left a comment

Choose a reason for hiding this comment

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

LGTM!

@yiyixuxu yiyixuxu merged commit f0216b7 into huggingface:main Feb 22, 2024
13 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.

unload_textual_inversion doesn't unload tokenizer_2 & text_encoder_2
6 participants