-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Fix AsymmetricAutoencoderKL forward #8378
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
Conversation
|
Thanks for opening this PR! |
The def forward(
self,
sample: torch.Tensor,
mask: Optional[torch.Tensor] = None,
sample_posterior: bool = False,
return_dict: bool = True,
generator: Optional[torch.Generator] = None,
) -> Union[DecoderOutput, Tuple[torch.Tensor]]:
...
- dec = self.decode(z, sample, mask).sample
+ dec = self.decode(z, generator, sample, mask).sample
... |
|
But |
| else: | ||
| z = posterior.mode() | ||
| dec = self.decode(z, sample, mask).sample | ||
| dec = self.decode(z, generator, sample, mask).sample |
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.
Tend to agree with @tolgacangoz's comments here. It's not used in the decode() function. Similar to AutoencoderKL. It's used in the forward():
| z = posterior.sample(generator=generator) |
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 don't think there's a stochastic component in the decode() function in the first place. So, I further think there's no need to have generator in here too:
| def decode(self, z: torch.Tensor, return_dict: bool = True, generator=None) -> Union[DecoderOutput, torch.Tensor]: |
@yiyixuxu WDYT here?
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 this comment answered the question:
https://github.com/huggingface/diffusers/pull/5694/files#r1387349283
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.
@sayakpaul I had the same questions, but their explanation makes sense I think
I think this is to maintain consistency of ...
from diffusers import AsymmetricAutoencoderKL, StableDiffusionInpaintPipeline
...
pipe = StableDiffusionInpaintPipeline.from_pretrained("runwayml/stable-diffusion-inpainting")
pipe.vae = AsymmetricAutoencoderKL.from_pretrained("cross-attention/asymmetric-autoencoder-kl-x-1-5")
pipe.to("cuda")
image = pipe(prompt=prompt, image=image, mask_image=mask_image).images[0]
image.save("image.jpeg")in this case, when origin vae is replaced with image = self.vae.decode(
latents / self.vae.config.scaling_factor, return_dict=False, generator=generator, **condition_kwargs
)[0] |
|
Hmm, you are right. The |
yiyixuxu
left a comment
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!
|
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. |
|
@tolgacangoz @sayakpaul is there a different way to use |
|
@yiyixuxu Most use cases call the I'm not sure if there is any
|
What does this PR do?
Fixes # (issue)
Fix incorrect call to
self.decode()withinAsymmetricAutoencoderKL.forward():related to: issue#8317
Before submitting
documentation guidelines, and
here are tips on formatting docstrings.
Who can review?
Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.
@sayakpaul @yiyixuxu @DN6