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 LMSDiscreteScheduler in LDMPipeline #891

Merged
merged 4 commits into from
Oct 21, 2022

Conversation

mkshing
Copy link
Contributor

@mkshing mkshing commented Oct 18, 2022

Hi, thank you for such a great repo. This is a small change to support all schedulers such as LMSDiscreteScheduler in LDMPipeline.

What's changed

  • Add the scale_model_input function before step to ensure correct denoising (L77)

This is a small change to support all schedulers such as LMSDiscreteScheduler in LDMPipeline.

What's changed
-------
* Add the `scale_model_input` function before `step` to ensure correct denoising (L77)
@HuggingFaceDocBuilderDev
Copy link

HuggingFaceDocBuilderDev commented Oct 18, 2022

The documentation is not available anymore as the PR was closed or merged.

@patrickvonplaten
Copy link
Contributor

This looks good to me! @anton-l could you also give it a quick review :-)

Copy link
Member

@anton-l anton-l left a comment

Choose a reason for hiding this comment

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

Great idea @mkshing, thank you!

You'll just need one more modification to make it work with LMS-like schedulers:

        latents = torch.randn(
            (batch_size, self.unet.in_channels, self.unet.sample_size, self.unet.sample_size),
            generator=generator,
        )
        latents = latents.to(self.device)
+       # scale the initial noise by the standard deviation required by the scheduler
+       latents = latents * self.scheduler.init_noise_sigma        

Happy to merge your PR after that :)

@mkshing
Copy link
Contributor Author

mkshing commented Oct 21, 2022

@patrickvonplaten @anton-l Thank you for your review! I added 2 lines as #891 (review)!

Copy link
Member

@anton-l anton-l left a comment

Choose a reason for hiding this comment

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

Awesome, thanks @mkshing!

@anton-l anton-l merged commit 31af4d1 into huggingface:main Oct 21, 2022
@patrickvonplaten
Copy link
Contributor

Great PR - thanks @mkshing :-)

PhaneeshB pushed a commit to nod-ai/diffusers that referenced this pull request Mar 1, 2023
Co-authored-by: Elias Joseph <elias@nod-labs.com>
yoonseokjin pushed a commit to yoonseokjin/diffusers that referenced this pull request Dec 25, 2023
* Support LMSDiscreteScheduler in LDMPipeline

This is a small change to support all schedulers such as LMSDiscreteScheduler in LDMPipeline.

What's changed
-------
* Add the `scale_model_input` function before `step` to ensure correct denoising (L77)

* Add "scale the initial noise by the standard deviation required by the scheduler"

* run `make style`

Co-authored-by: Anton Lozhkov <anton@huggingface.co>
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