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

SDXL moire/dither effect - picture quality #43

Open
lustfeind opened this issue Nov 11, 2023 · 5 comments
Open

SDXL moire/dither effect - picture quality #43

lustfeind opened this issue Nov 11, 2023 · 5 comments

Comments

@lustfeind
Copy link

Hello, I love OnnxStream and I think its a great project! Unbelievable that this is made possible!

I just want to ask about the SDXL picture quality - i know that this is not the main point for OnnxStream - but I've noticed in all my generated SDXL images some kind of moire, dither, scanline effect in details, while the rest of the image seems soft.
Can this be improved with someting? (parameter, prompts, compiling with different options)

@vitoplantamura
Copy link
Owner

hi,

I noticed this effect too.

If you try to generate an image here:

https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0?text=an+astronaut+riding+a+horse+on+mars

it is possible to notice the same effect, but I think it is less visible since the image is returned as JPEG rather than PNG.

Thanks, Vito

@lustfeind
Copy link
Author

I use SDXL in a1111 and ComfyUI, but only in OnnxStream this effect is clearly visible. Look at the face of this dude.
image_2023_11_11__00_27_20___xlsteps11_prompt_RAW_photo_wideangle_fisheye_photo_of_a_terminator_man_zombie_with_long_grey_hair__anatomical_gore_horror_d__death__beautiful_s

@vitoplantamura
Copy link
Owner

hi,

the OnnxStream models are exported directly from the Hugging Face SDXL models, so the inference result should be numerically (almost) the same.

But I think I understand what the "problem" is: for a low number of inference steps, dithering appears.

I did a series of tests with this code in a Colab with GPU:

from diffusers import AutoPipelineForText2Image, EulerAncestralDiscreteScheduler
import torch
from IPython.display import Image, display

pipeline = AutoPipelineForText2Image.from_pretrained(
    "stabilityai/stable-diffusion-xl-base-1.0", torch_dtype=torch.float16, variant="fp16", use_safetensors=True
).to("cuda")

pipeline.scheduler = EulerAncestralDiscreteScheduler.from_config(pipeline.scheduler.config)

prompt = "a photo of an astronaut riding a horse on mars"
image = pipeline(prompt=prompt, num_inference_steps=10).images[0]

display(image)

in this image, the dithering is present in the lower part, where there is sand:

download

Vito

@lustfeind
Copy link
Author

Hello Vito, thank you for your response.

You're right, this artifacts also are visible in a1111 generated SDXL images.
I noticed, that the SDXL images generated with Onnxstream are less saturated, and therefore the dither effect is more visible at lower steps.

Maybe its the VAE?

For comparing, the right image is generated with Onnxsteam
Bildschirmfoto 2023-11-26 um 21 37 30

@AeroX2
Copy link
Contributor

AeroX2 commented Jan 1, 2024

Hey @lustfeind

Decided to take a look at this myself and I think I found the issue or at least seems to substantially improve the image quality for XL models.
Have a look at the pull request below and let me know if this fixes your issue or not
#50

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

No branches or pull requests

3 participants