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

Staircase/Scanline artifacts with SDXL 1.0 #4310

Closed
n00mkrad opened this issue Jul 27, 2023 · 20 comments
Closed

Staircase/Scanline artifacts with SDXL 1.0 #4310

n00mkrad opened this issue Jul 27, 2023 · 20 comments
Labels
bug Something isn't working stale Issues that haven't received updates

Comments

@n00mkrad
Copy link

n00mkrad commented Jul 27, 2023

Describe the bug

SDXL creates colorful scanline-like artifacts, especially on areas with high-frequency detail.

SDXL - Diffusers 0.19.0 - 25 Steps of DPMSolverMultistepScheduler with Karras - 20% refine steps - CFG Scale 7

Left: SDXL 1.0 - Right: SDXL 0.9

image
image

Reproduction

Run SDXL 1.0 and compare results with SDXL 0.9

Logs

No response

System Info

Diffusers 0.19.0 - Windows 10 22H2 - RTX 4090 with drivers 536.40 - FP16 model

Who can help?

No response

@n00mkrad n00mkrad added the bug Something isn't working label Jul 27, 2023
@n00mkrad
Copy link
Author

Also happens without refiner model.

@n00mkrad
Copy link
Author

n00mkrad commented Jul 27, 2023

Workaround: Copy the 0.9 VAE to the 1.0 model.

The 1.0 VAE is broken.

LEFT: New VAE - RIGHT: Old VAE

image

@sayakpaul
Copy link
Member

Thanks for investigating. We think it will be beneficial for potentially similar future issues :)

@catboxanon
Copy link

catboxanon commented Aug 13, 2023

Did StabilityAI ever address this other than just silently dropping a "fixed" version (using the 0.9 VAE in the 1.0 checkpoints, as described above) in their respective repos? There's so much confusion and miscommunication around this that even the ControlNet author wasn't aware of this. (see discussion starting from here)

https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0/blob/main/sd_xl_base_1.0_0.9vae.safetensors
https://huggingface.co/stabilityai/stable-diffusion-xl-refiner-1.0/blob/main/sd_xl_refiner_1.0_0.9vae.safetensors

@fralumz
Copy link

fralumz commented Aug 22, 2023

The onnx vae should be reverted to 0.9 as well.

@github-actions
Copy link

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.

@github-actions github-actions bot added the stale Issues that haven't received updates label Oct 18, 2023
@catboxanon
Copy link

catboxanon commented Oct 18, 2023

Still interested to know whether or not StabilityAI officially addressed this, outside of silently releasing a "fixed" version. Seems awfully fishy to me.

Copy link

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.

@catboxanon
Copy link

Bumping again.

@patrickvonplaten
Copy link
Contributor

As always, we need a reproducible code snippet here :-)

@catboxanon
Copy link

catboxanon commented Nov 14, 2023

You made this change though.

https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0/discussions/30
https://huggingface.co/stabilityai/stable-diffusion-xl-refiner-1.0/discussions/8

So, technically this issue has already been addressed. However, my question in #4310 (comment) has not been.

@Woisek
Copy link

Woisek commented Dec 21, 2023

This VAE fixed it for me:
https://huggingface.co/madebyollin/sdxl-vae-fp16-fix/tree/main

@catboxanon
Copy link

catboxanon commented Dec 21, 2023

That VAE works because it also had to be reverted back to the 0.9 VAE.

https://huggingface.co/madebyollin/sdxl-vae-fp16-fix/commit/6d1073461cd0b5a6ea4fda10b812e3d9d58a8330

Further-reduced discrepancies with original SDXL-VAE (0.9) decoder

It still does not answer why this had to be done, and why StabilityAI made no official announcement regarding it. I believe it's incredibly misleading that a VAE labeled a version number higher, as "1.0", would have a scanline-like "watermark".

Copy link

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.

@catboxanon
Copy link

Bumping again.

@sayakpaul
Copy link
Member

It is still missing a reproducible code snippet.

@catboxanon
Copy link

catboxanon commented Jan 16, 2024

from diffusers.pipelines.stable_diffusion_xl.pipeline_stable_diffusion_xl import StableDiffusionXLPipeline
import torch
import gc
from PIL import Image

for url in [
    "https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0/blob/main/sd_xl_base_1.0.safetensors",
    "https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0/blob/main/sd_xl_base_1.0_0.9vae.safetensors",
]:
    generator = torch.Generator(device="cuda").manual_seed(42)
    pipeline_text2image = StableDiffusionXLPipeline.from_single_file(
        url, torch_dtype=torch.float16, variant="fp16", use_safetensors=True,
    ).to("cuda")
    prompt = "Astronaut in a jungle, cold color palette, muted colors, detailed, 8k"
    image: Image.Image = pipeline_text2image(prompt=prompt, generator=generator).images[0]
    image.save(f'{".".join(url.split('/')[-1].split('.')[:-1])}.png')
    del pipeline_text2image
    gc.collect()
sd_xl_base_1.0.png sd_xl_base_1.0_0.9vae.png
sd_xl_base_1 0 sd_xl_base_1 0_0 9vae

1600% zoom of each.

sd_xl_base_1.0.png sd_xl_base_1.0_0.9vae.png
sd_xl_base_1 0_1600 sd_xl_base_1 0_0 9vae_1600

The docs use sd_xl_base_1.0.safetensors for from_single_file() as well. https://huggingface.co/docs/diffusers/using-diffusers/sdxl#load-model-checkpoints

A user should expect something labeled "1.0" to be the model to use and to not contain VAE decoding artifacts. They should not need insider knowledge that something additionally labeled "0.9" is actually the better model to use because VAE decoding artifacts are not present.

@sayakpaul
Copy link
Member

@patrickvonplaten WDYT?

@patrickvonplaten
Copy link
Contributor

Hey @catboxanon,

This is really more an issue for the repo here: https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0/discussions as Stability AI decides how to name the files in their repo. Could you open an issue there?

Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working stale Issues that haven't received updates
Projects
None yet
Development

No branches or pull requests

6 participants