-
Notifications
You must be signed in to change notification settings - Fork 6.1k
Support for manual CLIP loading in StableDiffusionPipeline - txt2img. #3832
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 for manual CLIP loading in StableDiffusionPipeline - txt2img. #3832
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great to me! @sayakpaul wdyt?
The documentation is not available anymore as the PR was closed or merged. |
src/diffusers/loaders.py
Outdated
clip_text_model (`transformers.models.clip.modeling_clip.CLIPTextModel`, *optional*, defaults to `None`): | ||
An instance of `CLIPTextModel` to use. If this parameter is `None`, the function will load a new instance of `CLIPTextModel`, if needed. | ||
clip_tokenizer (`transformers.models.clip.tokenization_clip.CLIPTokenizer`, *optional*, defaults to `None`): | ||
An instance of `CLIPTokenizer` to use. If this parameter is `None`, the function will load a new instance of `CLIPTokenizer`, if needed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we maybe follow something similar to for the docstrings here?
text_encoder ([`CLIPTextModel`]): |
clip_text_model (`transformers.models.clip.modeling_clip.CLIPTextModel`, *optional*, defaults to `None`): | ||
An instance of `CLIPTextModel` to use. If this parameter is `None`, the function will load a new instance of `CLIPTextModel`, if needed. | ||
clip_tokenizer (`transformers.models.clip.tokenization_clip.CLIPTokenizer`, *optional*, defaults to `None`): | ||
An instance of `CLIPTokenizer` to use. If this parameter is `None`, the function will load a new instance of `CLIPTokenizer`, if needed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot for this important PR! Left some nits.
Regarding the failing test here, could you run |
@patrickvonplaten |
…huggingface#3832) * Support for manual CLIP loading in StableDiffusionPipeline - txt2img. * Update src/diffusers/pipelines/stable_diffusion/convert_from_ckpt.py * Update variables & according docs to match previous style. * Updated to match style & quality of 'diffusers' --------- Co-authored-by: Patrick von Platen <[email protected]>
…huggingface#3832) * Support for manual CLIP loading in StableDiffusionPipeline - txt2img. * Update src/diffusers/pipelines/stable_diffusion/convert_from_ckpt.py * Update variables & according docs to match previous style. * Updated to match style & quality of 'diffusers' --------- Co-authored-by: Patrick von Platen <[email protected]>
What does this PR do?
Fixes #3822
This pull request introduces a feature that enhances the loading mechanism of the
CLIP
model when used in conjunction withStableDiffusionPipeline.from_ckpt()
. This PR affects only thetxt2img
part of the mentioned pipeline. Users now have the flexibility to manually load the CLIP model and tokenizer, thereby bypassing the force loading behavior. This PR resolves the challenge of creating a fully portable solution, as the CLIP model and tokenizer would previously end up in the cache.With this enhancement, users can now specify their desired CLIP model and tokenizer location as follows:
It is important to note that this pull request does not impact the behavior if users choose not to provide any parameters for
clip_text_model
orclip_tokenizer
. In such cases, the code will behave as it did before the PR.Before submitting
documentation guidelines, and
here are tips on formatting docstrings.
Who can review?
@patrickvonplaten
@sayakpaul