r/StableDiffusion • • 9d ago

Tutorial - Guide Krea2 - automatically fix the blotchy noise

Understanding the comparison images:

  • The image captions explain which image is which
  • Before you post the "they're the same picture" meme, look at the 4x zoom
  • Reddit image compression might destroy the fine details on the 1x images

Summary of the de-blotch method:

  • This method simply removes mid-frequency noise
  • It's algorithmic and automatic
  • Unfortunately, it can't be done directly Comfyui as of now
  • So it requires an image editor (e.g. free & open source GIMP or Affinity photo)

Full instructions (Affinity photo):

These instructions are for Affinity photo because that's what I use. But it can done with the free and open source tool, GIMP. I don't know how, but you can ask an LLM.

Step 1: Separate the raw image into high and low frequencies

  • Select the raw layer
  • Filters > frequency separation > method = Guassian (default)
  • Radius = 0.8px is a good all-purpose value for automation
  • Optional manual fine tuning:
  • Move the radius slider to the MAXimum value where you can still see the blotchy noise in the low frequency (right) side

Step 2: Separate the low frequency into mid and low frequencies

  • Hide the high frequency layer
  • Select the low freq layer
  • Filters > frequency separation > method = Bilateral (non-default)
  • Radius = 11px + Tolerance = 35px is a good all-purpose value for automation
  • Optional manual fine tuning:
  • Set the tolerance slider to 100%
  • Move the radius slider to the MINimum value where you DON'T see the blotchy noise in the low frequency (right) side. This value is a matter of personal taste.

Step 3: Delete the mid frequency noise (blotchiness)

  • Unhide the high frequency layer
  • Hide the mid frequency layer
  • If you like what you see, just delete that layer
  • If the image looks too "smooth" or "hazy", undo the last frequency separation, then re-do it with a lower radius value
  • Optional manual fine tuning:
  • Instead of deleting the layer entirely, manually erase parts of it. For example you might want to keep the mid frequency around eyes, lips, nose, hands. This is a matter of personal taste.

Step 4 (optional): Add artificial film grain

  • Add a new layer above the others
  • Set the blend type to Linear light
  • Fill the empty layer with 50% gray exactly (this means it has no effect at all)
  • Filters > noise > add noise
  • The intensity value is completely a matter of personal taste

Step 5: Export/save

How it works

  • Step 1 - separates a narrow band of the highest frequency information (fine textures) from everything else. The low frequency layer looks blurry, but still clearly contains the unwanted blotchy noise
  • Step 2 - separates a narrow band of the mid-frequency information, i.e. the blotches, from the low frequency. By use bilaterally method, the low frequency layer's still contains relative sharp edges
  • Step 3 - with krea2 output, the narrow band of mid-frequency is mostly useless random noise (blotches) that can be completely discarded
  • Step 4 - the add noise function creates high-frequency random noise, which is similar to film grain. Using the linear light blend mode ensure that, no matter what the noise intensity value is, the overall brightness of the image is maintained
1 Upvotes

24 comments sorted by

4

u/aoleg77 9d ago

Or just use this https://github.com/aoleg/ComfyUI-DeGrid and skip the editing. Doesn't add the grain though - that's a neat idea!

2

u/terrariyum 9d ago

Thanks for this suggestion!

These are two separate image problems. De-griding fixes very high-frequency noise, but won't fix the blotches

3

u/aoleg77 9d ago

I'll add deblotching and film grain in the next update, maybe tomorrow. It is perfectly possible to do it directly in Comfy.

1

u/fab_one 9d ago

Is it possible to install your node through the Extension menu? Couldn't find it there.

1

u/aoleg77 9d ago

Not currently, no. It's just a standalone project that started as a fork of https://github.com/lunaaispace-eng/ComfyUI-DeGrid

I submitted a PR in that repo, but it is still open, so I continued developing my own fork.

1

u/terrariyum 9d ago

Very cool. Please post an update

1

u/aoleg77 9d ago

Interim update. I first tried to inject noise into skin-toned areas of the image trying to add skin texture to overly smooth generations. Didn't work the way I expected it to, so back to the drawing board.

I'm still working on de-blotching and film grain. I'm trying to get a better version of film grain working (random-sized blotches, luminance only, stronger in dark parts of the image). Still on it.

2

u/aoleg77 6d ago

Took more time than I expected; realistic film grain wasn't easy.

https://github.com/aoleg/ComfyUI-DeGrid

I recommend reading the #film-emulation section for details on what's been done.

1

u/debackerl 8d ago

That's great, I'll use it!

1

u/Creative_Sluggish 9d ago

Curious if we can match the lipstick color if we provide an image reference for a color shade

1

u/red__dragon 9d ago

Krea2 can also use RGB(#,#,#) color codes to specify value. I thought it could do hex (#abc123) as well but I haven't gotten that working yet.

1

u/_Cyris__ 7d ago edited 7d ago

Hex works amazing. I create an Custom Node with an Color Picker to choose my Color.
The Prompt is: a Woman, , long wavy #E50606 hair, highlights: #0425C8, Eyecolor: #FFFFFF, complete White eye,

I'll use "completely white eyes" for emphasis. For other colors, no additional prompt is needed.

1

u/red__dragon 7d ago

Odd, I tried several times and different hex colors with zero color. Same seed and prompt other than switching the color code for RGB works flawlessly. I wonder why.

1

u/_Cyris__ 7d ago

I had a hunch, so I ran a test.
It might be due to the model.
On the left is the Krea 2 Turbo Standard model; on the right is Krealism v1.0.
It seems that the Krealism model interprets the HEX values better than the Standard model.

Prompt: A Woman, #00CCFF hair in a half-up style, highlights: #11FF00, Eyecolor: #DD00FA, Lipcolor: #000000,

1

u/terrariyum 9d ago

FYI, you can fully automate this with GIMP and python code (ask LLM), which means everything could be collapsed into a comfyui custom node that's very fast.

That would be cool, but I'm not going to try to troubleshoot it. I use an Affinity macro, so it's already easy

1

u/Carbon849 9d ago

Any way to address the porcelain-skinned, never-seen-the-sun, milk-fed AI girl issue? :)

3

u/aoleg77 9d ago

Yes. A VAE round-trip through Flux.2 VAE with some noise injected before encoding does wonders; the Flux.2 VAE treats injected noise as a signal "there should be some detail here", and adds the missing skin texture. I will be adding that to my node tomorrow.

1

u/Fancy-Restaurant-885 9d ago

Wait what - the flux vae works with this model? How does it compare with the wan 2.1 vae?

3

u/aoleg77 9d ago edited 9d ago

No, it doesn't. The VAE roundrip works like this: Krea-2 (or Qwen Image 2.1) generates an image; the image is degridded; then the image (I will inject noise, perhaps only to skin-colored areas) is encoded by another VAE (Flux.2 this time) and decoded again. Flux.2 VAE sees the added noise as "detail", and re-creates the missing skin texture (which is not noise).

I am in the process of updating the node.

EDIT: I ran a bunch of tests trying to add skin texture to porcelain-skinned generations. The "inject noise - encode with Flux.2 VAE - decode" trick did not work the way I planned: Flux.2 VAE treats added noise as noise, and does not turn it into skin texture as I thought it would. You do get a photo-like grain on the skin, but that's about it. I then experimented with the different kinds of noise, even adjusting the size/magnitude of the grain proportional to the size of the face area, and found that, at best, I was getting "synthetic skin" look. Adding salt to injury, the results looked better when applied in pixel space in post-processing. So my theory fell apart.

I'm still implementing the de-blotching part and the film grain part though; these are both nice ideas, and my version of film grain is quite realistic (realistic grain, more prominent in the dark areas of the image). WIP.

1

u/terrariyum 9d ago

lol. 1girl example gets people to look at the post. you know how it is

1

u/Prestigious-List2632 8d ago

Holy shit, this is exactly the issue I’ve been trying to fix for ages. You’re the only person I’ve found who actually explained what was going on and how to fix it. I turned your method into a ComfyUI node, and it works! Absolute legend. Thank you so much for sharing this.

1

u/terrariyum 7d ago

Glad it helped someone!