r/StableDiffusion • • 7h ago

No Workflow Self-Refining Sampler+

https://github.com/Alex240z/ComfyUI-SelfRefiningSamplerPlus
Before/After
Before/After
Before/After
After

Based on: https://arxiv.org/html/2601.18577v1 and builds on pre-existing work by Kijai (The SamplerSelfRefineVideo Node).

I have found that Minimax H3-Image loves the Self-Refining Sampler. Seeing this, I spun up an improved version (SRS+) that is compatible with sampling methods besides Euler, has more easily adjustable sub-step and perturb amounts per step.
It seems to significantly improve the model's ability to resolve fine details, especially when combined with the "Empty-Image Trick" I shared previously (if using T2V). One place this is evident are patterns like fishnet, lace, sequins and other challenging fabrics/textiles. It seems to improve line-art for anime/illustration styles, and can often fix self-correct body-horror deformities.

As a starting point, try running it from steps 2-4 with 3 sub-steps and an uncertainty threshold of 0.03. But I'm much more curious what settings you try and results you get with them. Since it does sub-step, it increases gen time but I think it is well worth it.

I've tested it less with video, but it has shown promise there, too.

Just socket this chungus into a SamplerCustomAdvanced like any other sampler. Let me know if you have any issues, or what kind of results you get.

103 Upvotes

31 comments sorted by

12

u/ninjazombiemaster 7h ago

Video example of it fixing a Pika H3 gen using the paper's preset:
https://imglink.cc/cdn/8oCs6N3f93.mp4

0

u/[deleted] 5h ago

[deleted] — view deleted comment

4

u/a-ijoe 5h ago

it's got 3 legs in the first one.

1

u/Diabolicor 4h ago

If you take a look at the original paper it's a technique for self-correcting physics dynamics, motion and physical realism without additional model training.

7

u/Dante_77A 7h ago edited 7h ago

Interestingly, these fishnet outfits usually glitch on most models if the character isn’t close to the camera.

But note that the girl’s face has been drastically altered 

6

u/ninjazombiemaster 7h ago edited 6h ago

This is to be expected, due to the spatial compression of the VAE. But In the case of H3 it also just doesn't seem to get enough time with the 6 steps to resolve these details, and simply increasing step count or using higher order samplers normally seems to destroy the image. But for some reason, the SRS substeps do not degrade it.

As for the face alteration, it is injecting noise so this also expected depending on the settings. You can tune the strength and time steps. This was t2i so no ref - neither face can be judged for accuracy. 

6

u/YeahlDid 5h ago

Pretty neat stuff, thank you. About how much does this add to generate time?

1

u/ninjazombiemaster 1h ago

Depends on how you configure the sub-stepping. You control when and how many. It could barely add any time or double it. 

4

u/JorG941 2h ago

Is this aplicable on other models?

4

u/ninjazombiemaster 1h ago

Yes, it can be used with other video and image models. 

2

u/VasaFromParadise 1h ago edited 53m ago

threshold of 0.03
My image changes dramatically after this method. Has anyone figured out why yet? Or is it just me?
PS. perturb_strength_scale - must be less than 1, otherwise the image changes significantly.

3

u/ninjazombiemaster 56m ago

It's like SDE samplers, it injects nose at each substep. You can reduce this by doing fewer substeps, waiting til later to engage them so the image is more locked in, or decreasing the perturbation strength. 

1

u/VasaFromParadise 41m ago

Something like this?)

2

u/nixudos 3h ago

I tried it on a 9 step Ref2video Minimax H3 workflow.
Just the default settings, as I have no idea what to tweak.
It seemed to improve the audio noticeably, but there was one artifact in it. I'm trying to make another test and see if it was just a fluke.

Are there any recommended settings for Minimax video generations?

1

u/ninjazombiemaster 1h ago

I haven't done enough tests with video to really recommend settings.But I would start with the "paper" preset since the original paper was meant for video correction.

1

u/mac404 2h ago edited 2h ago

Interesting, definitely going to try it out!

Loading it up, seems like the defaults baked into the node are different from what you're suggesting to start with in the post here? Any reason why you're setting uncertainty threshold so much lower than the 0.25 node default and running it on one fewer step? And which metric is being used (mean or norm) related to your 0.03 suggestion?

Edit: Okay, a few dumb questions as I try to make sense of the settings:

  • Given the 0 indexing in the node, are you saying you ran with the steps labeled 2-4, or actually the ones labeled 1-3?
  • Are you suggesting to run 1 substep per step for the remaining steps? Or is the correct setting actually 0?
  • Looks like a value of 1.0 for perturb per step follows the paper, so keeping that. But does it matter what those values are set to for steps that don't run any substeps?

2

u/ninjazombiemaster 1h ago

Node defaults were based on the paper and/or Kijais beta node. Honestly I'm hoping people try lots of settings and share their results. The settings I mentioned were the ones used for the example images though. 

Low uw% keeps the refine engaged longer by preventing it from masking as early.   

Yes, the samples were generated with the steps labeled 2,3,4 at 3 and the others at 0. But definitely try other configs too. 

It doesn't matter what is set at if substeps are 0. 

0

u/mac404 31m ago

Thanks for the reply!

Some very initial results are encouraging, but definitely need to try out more combinations of settings to get a feel for things. One thing that seems nice is that ramping up substeps across all steps doesn't seem to meaningfully destroy the image.

1

u/Ill_Resolve8424 2h ago

How to use this in comfy? Looks promising

2

u/ninjazombiemaster 1h ago

You plug it into the "sampler" input of a sampler custom advanced node. 

1

u/Estwhy 1h ago

Im so dumb, could you provide us a workflow please?

0

u/Diabolicor 6h ago edited 5h ago

Really interesting paper. Can you describe the config you used for your video tests and did you run it with your Re-Time pass or was it just 1 Pass ?

1

u/ninjazombiemaster 1h ago

That was with the "paper" preset, no re-time. 

0

u/Enshitification 2h ago

I wonder if this would combine well with the Lakonik team's pi-H3 to get better results from their low-step adapters? I'm not near a machine to test it right now, so this is my reminder note.

1

u/ninjazombiemaster 1h ago

I think it would. Of course it also makes them slower so the question becomes how does it compare to higher step options given the same length of time. 

0

u/Silonom3724 26m ago

I tried it. It improves frame to frame variance but mostly because you throw more steps (substeps) at it. It's a trade off quality for more compute. Not a win in my book.

0

u/celialoriaart 1h ago

The difference on the fishnet texture and the hand structure in the "after" shot is wild. Definitely plugging this into my SamplerCustomAdvanced node to test those 2-to-4 step settings!

1

u/ninjazombiemaster 1h ago

Yeah it blew my mind with how much/consistently it was improving things. 

-2

u/fallengt 2h ago

Neat, but sampling speed decreases quite a bit. It's not free lunch

3

u/ninjazombiemaster 1h ago

Naturally. But it's worth the wait imo.