-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
add PAG support for SD architecture #8725
Conversation
**kwargs, | ||
): | ||
deprecation_message = "`_encode_prompt()` is deprecated and it will be removed in a future version. Use `encode_prompt()` instead. Also, be aware that the output format changed from a concatenated tensor to a tuple." | ||
deprecate("_encode_prompt()", "1.0.0", deprecation_message, standard_warn=False) |
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.
@yiyixuxu should I remove all the deprecate messages, I think this is long deprecated
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.
I think we can remove this method here since it is not used in the pipeline
|
||
return prompt_embeds, negative_prompt_embeds | ||
|
||
def encode_image(self, image, device, num_images_per_prompt, output_hidden_states=None): |
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 you add # Copied from
comments at every method that requires it in similar fashion to how it's done in other pipelines?
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.
Ahh, forgot to do that, done!
Hi @shauray8, I just have one query. How did you compare the |
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! very nice work!
I think there are some deprecated method from SD1.5 that we do not need to add in PAG, other than that, it is perfect!
**kwargs, | ||
): | ||
deprecation_message = "`_encode_prompt()` is deprecated and it will be removed in a future version. Use `encode_prompt()` instead. Also, be aware that the output format changed from a concatenated tensor to a tuple." | ||
deprecate("_encode_prompt()", "1.0.0", deprecation_message, standard_warn=False) |
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.
I think we can remove this method here since it is not used in the pipeline
return image, has_nsfw_concept | ||
|
||
# Copied from diffusers.pipelines.stable_diffusion.pipeline_stable_diffusion.StableDiffusionPipeline.decode_latents | ||
def decode_latents(self, latents): |
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.
we can remove this method here if it is not used by this pipeline :)
callback_on_step_end_tensor_inputs: List[str] = ["latents"], | ||
pag_scale: float = 3.0, | ||
pag_adaptive_scale: float = 0.0, | ||
**kwargs, |
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.
**kwargs, |
can remove this if not used
@@ -76,7 +76,7 @@ | |||
>>> pipe = AutoPipelineForText2Image.from_pretrained( | |||
... "stabilityai/stable-diffusion-xl-base-1.0", | |||
... torch_dtype=torch.float16, | |||
... enabe_pag=True, | |||
... enable_pag=True, |
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.
thank you!!
hi @Bhavay-2001
|
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. |
can get the CI to pass too: run |
@yiyixuxu removed the methods mentioned above, with all the changes necessary for the CI to go green. |
@shauray8 thanks for your contribution! |
What does this PR do?
Adds PAG (Perturbed-Attention Guidance) support for SD models (
StableDiffusionPAGPipeline
). Continuation of #7944Fixes #8710 (partially)
Before submitting
documentation guidelines, and
here are tips on formatting docstrings.
Who can review?
@yiyixuxu
Anyone in the community is free to review the PR once the tests have passed.
for the wonderers, here are some of my results I found during testing
I thought attention applied on the latter layers should give out much better quality and applying on middle layers would be much faster.
Usage [SD+PAG]