Fix AsymmetricAutoencoderKL forward#8378
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.
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():
There was a problem hiding this comment.
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:
@yiyixuxu WDYT here?
There was a problem hiding this comment.
i think this comment answered the question:
https://github.com/huggingface/diffusers/pull/5694/files#r1387349283
There was a problem hiding this comment.
@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 |
|
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