Skip to content

Add Euler, Heun and DPM++ (2M) samplers #50

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

Merged
merged 6 commits into from
Sep 8, 2023
Merged

Conversation

ursg
Copy link
Contributor

@ursg ursg commented Sep 7, 2023

I don't like ancestral samplers, so I implemented the simplest deterministic ones: Euler and Heun sampling, based on their python equivalents from the k-diffusers package.

This also includes code to do the --sampling-method parameter parsing. And fixes the spelling of Euler. :)

Also adds the command line parsing mechanism for actually selecting the
sampler.

And fixes the misspelling of Euler.
@Green-Sky
Copy link
Contributor

🚀
I usually prefer the looks of Euler a over Euler. not sure if we should change the default.

@JohnClaw
Copy link

JohnClaw commented Sep 7, 2023

Add ddim sampler, please.

@ursg
Copy link
Contributor Author

ursg commented Sep 7, 2023

Also added DPM++ (2M) sampler, because I like that one, too!

@ursg ursg changed the title Add Euler and Heun samplers Add Euler, Heun and DPM++ (2M) samplers Sep 7, 2023
@JohnClaw
Copy link

JohnClaw commented Sep 7, 2023

Also added DPM++ (2M) sampler, because I like that one, too!

Would you be so kind to compile and upload an avx2 windows executable for your SD.cpp fork, please?

@Green-Sky
Copy link
Contributor

Also added DPM++ (2M) sampler, because I like that one, too!

Would you be so kind to compile and upload an avx2 windows executable for your SD.cpp fork, please?

😆 someone cant wait for @leejet to merge this.

Copy link
Contributor

@Green-Sky Green-Sky left a comment

Choose a reason for hiding this comment

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

you are missing "sampling-method" and "sample-method"
eg. help tells you to use "sample-method" but its actually "sampling-method"

edit: you also changed "euler a" to "euler_a" as the parameter

@Happenedtostumblein
Copy link

Happenedtostumblein commented Sep 7, 2023

Would inpainting be a separate mode altogether, or is it a sampling type?

Edit: I guess inpainting is just part of img2img but does anyone know how to apply mask technique vs sketch?

@Green-Sky
Copy link
Contributor

did a test run of the samplers with default settings (20steps, 512x512) and the artiusV21 model

euler:

output_euler

euler a:

output_euler_a

heun:

output_heun

dpm++ 2m:

output_dpm++2m

@Green-Sky
Copy link
Contributor

Would inpainting be a separate mode altogether, or is it a sampling type?

Edit: I guess inpainting is just part of img2img but does anyone know how to apply mask technique vs sketch?

It is very much a different mode, yes, iirc img2img with masking or something like that.
Sketch was something else entirely iirc, i think that was with a ControlNet.

This was proposed in a issue discussion of the stable diffusion webui,
at AUTOMATIC1111/stable-diffusion-webui#8457
and apparently works around overstepping of the DPM++ (2M) method with
small step counts.

The parameter is called dpmpp2mv2 here.
@ursg
Copy link
Contributor Author

ursg commented Sep 7, 2023

Added another one: The modified version of DPM++ (2M) from this thread over in AUTOMATIC1111's webui discussions. Apparently, there are mathematical arguments why the unmodified method could sometimes overstep and produce exaggerated edge artefacts, and this change fixes that.

@ursg
Copy link
Contributor Author

ursg commented Sep 7, 2023

you are missing "sampling-method" and "sample-method" eg. help tells you to use "sample-method" but its actually "sampling-method"

That one is fixed now, thanks!

@ursg
Copy link
Contributor Author

ursg commented Sep 7, 2023

you also changed "euler a" to "euler_a" as the parameter

True, I considered it more practical not to have spaces inside command line arguments like that. Not good?

@Green-Sky
Copy link
Contributor

dpm++ 2 v2

output_dpm++2mv2

@ursg
Copy link
Contributor Author

ursg commented Sep 8, 2023

Also note PR #51, which allows all these samplers to run with the "Karras" schedule, by specifying --schedule karras.

match code style
update README.md
set euler_a as the default sampling method
@leejet
Copy link
Owner

leejet commented Sep 8, 2023

Great! Thank you for your contribution. However, I prefer to use euler a as the default sampling method, as stable-diffusion-weiui does. So I made some small changes.

@leejet leejet merged commit b6899e8 into leejet:master Sep 8, 2023
@ursg ursg deleted the samplers branch September 8, 2023 18:46
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