-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
DDIM produces incorrect samples with SDXL (epsilon or v-prediction) #6068
Comments
@yiyixuxu could you take a look here? |
for euler yes, but that already appends an additional scheduler step |
I thought ddim had incorrect samples regardless of ZSNR or not. If the solution is to simply use euler and leave ddim broken then it may as well be deprecated. The fact that euler needs an extra 0 sigma to avoid the residual noise issue and DPM has such options as |
This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread. Please note that issues that do not follow the contributing guidelines are likely to be ignored. |
that stale bot is the worst! @patrickvonplaten it should probably just be removed from the project due to how many good issues just get juked. |
also kinda crazy this remains an issue for more than a month? |
no and that pr didnt fix dpm multistep solver either, it still has residual noise cc @AmericanPresidentJimmyCarter |
I am using the code from #6647 with DPMSolverMultistep, karras_timesteps, euler_at_final=True, and things like logos still have residual noise instead of outputting a flat colour as expected. Euler and DDIM do not seem to fix this And here it is with DPMSolverMultistep, karras_timesteps, final_sigmas_type="denoise_to_zero" |
the red dots are the "invisible" watermarker. #4014 |
I am using: class NoWatermark:
def apply_watermark(self, img):
return img
...
pipe.watermarker = NoWatermark edit: Oh, I see. class NoWatermark:
def apply_watermark(self, img):
return img
...
- pipe.watermarker = NoWatermark
+ pipe.watermark = NoWatermark Now there is still some noise, but it is reduced. |
I think I have a similar or related issue. I created an image with diffusers and auto1111 with the same parameters, but got different images, with diffusers being worse quality (especially more noise). Relevant diffusers code with parameters: pipe = StableDiffusionXLPipeline.from_single_file(".\models\Stable-diffusion\sdxl\sd_xl_base_1.0_0.9vae.safetensors", torch_dtype=torch.float16)
prompt = "concept art Amber Temple, snow, frigid air, snow-covered peaks of the mountains, dungeons and dragons style, dark atmosphere . digital artwork, illustrative, painterly, matte painting, highly detailed"
negative_prompt = "photo, photorealistic, realism, ugly"
pipe.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config)
image = pipe(prompt, negative_prompt=negative_prompt, guidance_scale=8, num_inference_steps=20, width=1024, height=1024, generator=torch.Generator(device='cuda').manual_seed(1337), use_karras_sigmas=True).images[0] Auto1111 (DPM++ 2M Karras): Slightly different results. |
@djdookie, I think you have a typo in your code snippet. Note that you should pass pipe = StableDiffusionXLPipeline.from_single_file(".\models\Stable-diffusion\sdxl\sd_xl_base_1.0_0.9vae.safetensors", torch_dtype=torch.float16)
prompt = "concept art Amber Temple, snow, frigid air, snow-covered peaks of the mountains, dungeons and dragons style, dark atmosphere . digital artwork, illustrative, painterly, matte painting, highly detailed"
negative_prompt = "photo, photorealistic, realism, ugly"
pipe.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config, use_karras_sigmas=True)
image = pipe(prompt, negative_prompt=negative_prompt, guidance_scale=8, num_inference_steps=20, width=1024, height=1024, generator=torch.Generator(device='cuda').manual_seed(1337)).images[0] see the diff: - pipe.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config)
+ pipe.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config, use_karras_sigmas=True) |
When I run the correct code in a colab, I'm getting good results: https://colab.research.google.com/drive/1IXZRZk6TYVG9uTDjocsUEfynfp5gyeoe?usp=sharing (make sure to use current diffusers main here) |
using karras sigmas is incompatible with zero-terminal SNR, no? i wouldn't say it looks very similar other than compositionally. the contrast is totally washed out |
@patrickvonplaten Good finding. This indeed solved my issue. And I don't have washed out colors btw. Thank you so much! |
that still has residual noise in the sky, you can see the splotchy colouring there. try a retrieving a vector style image or any of the demo prompts from above. |
I don't see any splotchy colouring tbh, but maybe I'm also just getting old and my vision is weaker than it used to haha |
Not in my experience |
Using diffusers master d4c7ab7 with my own app I think this is a fairly obvious demonstration that both DDIM and probably DPM have timestep issues. DPM doesn't have a ZSNR patch yet so it'll naturally have less contrast. |
@patrickvonplaten i understand, it's something that you have to see quite a lot to really recognise it. one oddity is that the same seed has the same splotchy pattern across every image. it's simply some deterministic noise being added/not removed completely |
@bghira
|
no, i havent had great experiences opening PRs for this project for the last handful of months, they become stale and close automatically. |
Hi @bghira I reopened this one #5969 - is there any other issues from your project that have been automatically closed? please let me know I'm sorry that we let perfectly good issues go stale. This particular issue is a relatively low priority for me and I haven't been able to find time to work on this because I should have been more upfront about this and should be more clear about the expectations. I'm sorry and I will do better next time. And please be a little bit patient with us in the meantime. Thanks YiYi |
well since that time, a colleague has ported zero terminal snr to Euler. DDIM was the only choice til that. i dont personally meed this fixed, i dont think ddim is very useful considering euler works basically the same. if you wanted to simply remove ddim i would think thats fine |
it could be for some cases, but in this one the user didn't move away from |
DDIM is still used a lot, no? just not a popular choice with SDXL I think. maybe we can add a note in our doc? |
ideally it would be mapped to euler so that the behaviour remains the same for end users. ComfyUI just did this a few months back to reduce duplicate code maintenance overhead as well. |
FWIW he only removed the ddim sampler, there's still the "ddim_uniform" scheduler which gives a different sigma spread for what is now the Euler sampler. |
I think we should move this issue to a discussion. We're talking about the quality of different schedulers and scheduler variants such as |
So doing some more in-depth research I actually feel there's a few issues going on simultaneously. 1.The official SAI config for SDXL has
|
I moved this to a discussion here so more people can participate #6931 |
This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread. Please note that issues that do not follow the contributing guidelines are likely to be ignored. |
This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread. Please note that issues that do not follow the contributing guidelines are likely to be ignored. |
@apolinario can you do that? i'll close this one out. but we need the SAI configs updated |
Describe the bug
When generating images with SDXL and DDIM, there is some residual noise in the outputs.
This leads to a "smudgy" look, and in cases where fewer steps are used, DDIM and Euler diverge a lot more than they should because of the cumulative impact of not having the timesteps aligned properly.
In some brief tests, it looks like simply adding an extra timestep with a zero sigma to the end of the schedule resolves the problem.
Reproduction
This script uses a modified Euler scheduler to create fully-denoised images:
It uses the Sigmas code ported by @Beinsezii in #6024
However, with vanilla DDIM, the results are far worse:
Logs
No response
System Info
diffusers
version: 0.21.4Who can help?
@patrickvonplaten @yiyixuxu
The text was updated successfully, but these errors were encountered: