Skip to content
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 latents_mean and latents_std #7132

Merged
merged 6 commits into from
Mar 9, 2024
Merged

Conversation

haofanwang
Copy link
Contributor

As title.

This PR supports latents_mean and latents_std in the decoding stage of VAE as done in pipeline_stable_diffusion_xl.py to make the pipeline compatible to models like playgroundai/playground-v2.5-1024px-aesthetic that set latents_mean and latents_std in config. For now, all other pipelines lead to grey image except for pipeline_stable_diffusion_xl.py.

Tested locally.

Copy link
Contributor

@patil-suraj patil-suraj left a 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 the PR! Looks good, but we should leave other things un-touched in this PR, if there is some issue we a separate PR would be better.

@@ -1611,6 +1611,21 @@ def __call__(
self.upcast_vae()
latents = latents.to(next(iter(self.vae.post_quant_conv.parameters())).dtype)

# unscale/denormalize the latents
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
# unscale/denormalize the latents
# unscale/denormalize the latents


# cast back to fp16 if needed
if needs_upcasting:
self.vae.to(dtype=torch.float16)
else:
return StableDiffusionXLPipelineOutput(images=latents)
image = latents
Copy link
Contributor

Choose a reason for hiding this comment

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

why is this changed?


# cast back to fp16 if needed
if needs_upcasting:
self.vae.to(dtype=torch.float16)
else:
image = latents
return StableDiffusionXLPipelineOutput(images=image)
Copy link
Contributor

Choose a reason for hiding this comment

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

same comment as above ?

@patil-suraj patil-suraj requested a review from yiyixuxu February 28, 2024 16:37
@yiyixuxu
Copy link
Collaborator

agree with @patil-suraj here :)

@haofanwang
Copy link
Contributor Author

haofanwang commented Mar 5, 2024

Fixed. @patil-suraj @yiyixuxu

@HuggingFaceDocBuilderDev

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.

@yiyixuxu
Copy link
Collaborator

yiyixuxu commented Mar 9, 2024

@haofanwang hey I fixed a mistake here #7132 (comment) but now the quality test fail again
can you fix them thanks! 😛

@haofanwang
Copy link
Contributor Author

Sure.

@haofanwang
Copy link
Contributor Author

@yiyixuxu Formatted, pass my local check.

@yiyixuxu yiyixuxu merged commit 6c5f0de into huggingface:main Mar 9, 2024
15 checks passed
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.

6 participants