-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Fix use_lu_lambdas
and use_karras_sigmas
with beta_schedule=squaredcos_cap_v2
in DPMSolverMultistepScheduler
#10740
base: main
Are you sure you want to change the base?
Conversation
…redcos_cap_v2` in `DPMSolverMultistepScheduler`
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. |
I use a test like this for scheduler changes, can you run for relevant configs (need to add need to make sure outputs are same as in # slow test for dpm
import torch
from diffusers import StableDiffusionXLPipeline
from diffusers import EulerDiscreteScheduler, DEISMultistepScheduler, HeunDiscreteScheduler, UniPCMultistepScheduler
import os
from diffusers.utils import make_image_grid
config_zero = {"final_sigmas_type":"zero"}
schedulers = {
"Euler": {
"zero": (EulerDiscreteScheduler, config_zero),
},
"Euler_K": {
"zero": (EulerDiscreteScheduler, {"use_karras_sigmas": True, **config_zero}),
},
"Euler_EXP": {
"zero": (EulerDiscreteScheduler, {"use_exponential_sigmas": True, **config_zero}),
},
"Euler_B": {
"zero": (EulerDiscreteScheduler, {"use_beta_sigmas": True, **config_zero}),
},
"DEIS": {
"zero": (DEISMultistepScheduler, config_zero),
},
"DEIS_K": {
"zero": (DEISMultistepScheduler, {"use_karras_sigmas": True, **config_zero}),
},
"DEIS_EXP": {
"zero": (DEISMultistepScheduler, {"use_exponential_sigmas": True, **config_zero}),
},
"DEIS_B": {
"zero": (DEISMultistepScheduler, {"use_beta_sigmas": True, **config_zero}),
},
"Heun": {
"zero": (HeunDiscreteScheduler, config_zero),
},
"Heun_K": {
"zero": (HeunDiscreteScheduler, {"use_karras_sigmas": True, **config_zero}),
},
"Heun_EXP": {
"zero": (HeunDiscreteScheduler, {"use_exponential_sigmas": True, **config_zero}),
},
"Heun_B": {
"zero": (HeunDiscreteScheduler, {"use_beta_sigmas": True, **config_zero}),
},
"UniP": {
"zero": (UniPCMultistepScheduler, config_zero),
},
"UniP_K": {
"zero": (UniPCMultistepScheduler, {"use_karras_sigmas": True, **config_zero}),
},
"UniP_EXP": {
"zero": (UniPCMultistepScheduler, {"use_exponential_sigmas": True, **config_zero}),
},
"UniP_B": {
"zero": (UniPCMultistepScheduler, {"use_beta_sigmas": True, **config_zero}),
},
}
## Test SD-XL
# model_id = "stabilityai/stable-diffusion-xl-base-1.0"
model_id = "frankjoshua/juggernautXL_version6Rundiffusion"
pipe = StableDiffusionXLPipeline.from_pretrained(
model_id,
torch_dtype=torch.float16,
use_safetensors=True,
variant="fp16",
add_watermarker=False)
pipe = pipe.to('cuda')
prompt = "Adorable infant playing with a variety of colorful rattle toys."
save_dir = './test_juggernautxl_baby_main'
if not os.path.exists(save_dir):
os.mkdir(save_dir)
steps = 25
params = {
"prompt": [prompt],
"num_inference_steps": steps,
"guidance_scale": 7,
}
for scheduler_name in schedulers.keys():
for seed in [123]:
out_imgs = []
scheduler_configs = schedulers[scheduler_name]
for scheduler_config_name in scheduler_configs.keys():
generator = torch.Generator(device='cuda').manual_seed(seed)
scheduler = scheduler_configs[scheduler_config_name][0].from_pretrained(
model_id,
subfolder="scheduler",
**scheduler_configs[scheduler_config_name][1],
)
pipe.scheduler = scheduler
img = pipe(**params, generator=generator).images[0]
out_imgs.append(img)
out_img = make_image_grid(out_imgs, rows=1, cols=2)
out_img.save(os.path.join(save_dir, f"seed_{seed}_steps_{steps}_{scheduler_name}.png")) |
|
What does this PR do?
.round()
was applied withuse_lu_lambdas
anduse_karras_sigmas
, this seems to give incorrect_step_index
fromindex_for_timestep
as multiple timesteps are the same.Reproduction
`use_karras_sigmas`
`use_lu_lambdas`
Fixes #10738
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.
@yiyixuxu @vladmandic