Skip to content

Conversation

@NormXU
Copy link

@NormXU NormXU commented Apr 14, 2023

As StableDiffusionLongPromptWeightingPipeline inherits from StableDiffusionPipeline, we can utilize the functions of TextualInversionLoaderMixin directly to convert negative / prompts if any text inversion tokens are available.

# textual inversion: process multi-vector tokens if necessary
if isinstance(self, TextualInversionLoaderMixin):
    prompt = self.maybe_convert_prompt(prompt, self.tokenizer)
    negative_prompt = self.maybe_convert_prompt(negative_prompt, self.tokenizer)

text_embeddings, uncond_embeddings = get_weighted_text_embeddings(
    pipe=self,
    prompt=prompt,
    uncond_prompt=negative_prompt if do_classifier_free_guidance else None,
    max_embeddings_multiples=max_embeddings_multiples,
)

@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint.

Copy link
Contributor

@patrickvonplaten patrickvonplaten left a comment

Choose a reason for hiding this comment

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

Cool this looks good to me - wdyt @SkyTNT ?

@SkyTNT
Copy link
Contributor

SkyTNT commented Apr 27, 2023

This is already done in lpw_stable_diffusion.py by #3265

@NormXU
Copy link
Author

NormXU commented Apr 28, 2023

Since it is already done, I will close this PR.

@NormXU NormXU closed this Apr 28, 2023
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