OnnxStream icon indicating copy to clipboard operation
OnnxStream copied to clipboard

SDXL moire/dither effect - picture quality

Open lustfeind opened this issue 2 years ago • 5 comments

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)

lustfeind avatar Nov 11 '23 11:11 lustfeind

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

vitoplantamura avatar Nov 12 '23 10:11 vitoplantamura

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

lustfeind avatar Nov 13 '23 15:11 lustfeind

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

vitoplantamura avatar Nov 14 '23 09:11 vitoplantamura

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

lustfeind avatar Nov 26 '23 20:11 lustfeind

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 https://github.com/vitoplantamura/OnnxStream/pull/50

AeroX2 avatar Jan 01 '24 05:01 AeroX2