Koishi-Star / Euler-Smea-Dyn-Sampler

A sampler base on Euler, aim at generating better picture/一种基于Euler的采样方法,旨在生成更好的图片
Apache License 2.0
158 stars 13 forks source link

Striped noise #11

Open ryukra opened 5 months ago

ryukra commented 5 months ago

Very good sampler, but it has a striped noise all over the image?

Thresholded image to exaggerate the effect: ShadowPCDisplay_1EP8lhvStl

Koishi-Star commented 5 months ago

I don't sure……maybe in SDXL? More steps may help.

SDXL and SD1.5 have many differences, which could be the cause of the issue. SDXL has a unique positional encoding technique, and its latent space dimensions are also larger. I will work on adapting SDXL in the future. Thank you for your issue.

ryukra commented 5 months ago

More steps fixes it for the most part, 30 already enough.

pamparamm commented 5 months ago

@Koishi-Star The striped noise could be a byproduct of using gamma = max(s_churn... in both samplers (all other default samplers use gamma = min(s_churn...). Since gamma is used as a multiplier of sigma_hat (and always multiplies is by 1.41), we are skipping some essential denoising at last steps. I've tested replacing max with min entirely - it makes both samplers perform much worse by reducing color range of generated images. Maybe we could mitigate the noise by partially replacing gamma = max(s_churn... in both sample_euler_dy and sample_euler_smea_dy with something like this:

        if i > ((len(sigmas) - 1) / 3) * 2:
            gamma = min(s_churn / (len(sigmas) - 1), 2 ** 0.5 - 1) if s_tmin <= sigmas[i] <= s_tmax else 0.
        else:
            gamma = max(s_churn / (len(sigmas) - 1), 2 ** 0.5 - 1) if s_tmin <= sigmas[i] <= s_tmax else 0.
Koishi-Star commented 5 months ago

@Koishi-Star The striped noise could be a byproduct of using in both samplers (all other default samplers use ). Since is used as a multiplier of (and always multiplies is by ), we are skipping some essential denoising at last steps. I've tested replacing max with min entirely - it makes both samplers perform much worse by reducing color range of generated images. Maybe we could mitigate the noise by partially replacing in both and with something like this:gamma = max(s_churn...``gamma = min(s_churn...``gamma``sigma_hat``1.41``gamma = max(s_churn...``sample_euler_dy``sample_euler_smea_dy

        if i > ((len(sigmas) - 1) / 3) * 2:
            gamma = min(s_churn / (len(sigmas) - 1), 2 ** 0.5 - 1) if s_tmin <= sigmas[i] <= s_tmax else 0.
        else:
            gamma = max(s_churn / (len(sigmas) - 1), 2 ** 0.5 - 1) if s_tmin <= sigmas[i] <= s_tmax else 0.

1231241 I'm not sure if it works, not sure what will cause striped noise. Default s_churn is 0. , so at most time gamma will not be used. Even delte these codes will not result in error.

Here is metadata, you can test them if you want:

Positive promot:1girl,manhattan cafe \(umamusume\),umamusume,ask \(askzy\),torino aqua,migolu,(jiu ye sang:1.1),(rumoon:0.9),(mizumi zumi:1.1), heart hands,upper body, black gloves,indoors,black choker,long sleeves,collared shirt,yellow necktie,black vest,black coat,belt,black skirt,pleated skirt,black pantyhose, masterpiece,best quality,very aesthetic,absurdres, Negative prompt:lowres,(bad),text,error,fewer,extra,missing,worst quality,jpeg artifacts,low quality,watermark,unfinished,displeasing,oldest,early,chromatic aberration,signature,extra digits,artistic error,username,scan, Steps: 20, Sampler: Euler Dy, Schedule type: Automatic, CFG scale: 6, Seed: 56745646, Size: 832x1216, Model hash: e3c47aedb0, Model: animagineXLV31_v31, FP8 weight: Enable for SDXL, Cache FP16 weight for LoRA: False, Clip skip: 2, Pad conds: True, Version: v1.9.0

pamparamm commented 5 months ago

Will try to troubleshoot the problem with your example, thanks.

Default s_churn is 0. , so at most time gamma will not be used.

No, the current implementation works as follows:

pamparamm commented 5 months ago

Hmm, maybe for me it was just a side effect of combining perturbed-attention with samplers. The effect was sometimes noticeable on backgrounds and gradients, so I've done some testing with SDXL, Animagine and PDXL-based checkpoints. Looks like PDXL checkpoints suffer the most. Without fix:

With:

Again, the problem mostly appears when using PAG (and with big scale values), and I'm not sure if it's really worth fixing right now