ComfyUI icon indicating copy to clipboard operation
ComfyUI copied to clipboard

added SamplerHeunCFGpp

Open Extraltodeus opened this issue 1 year ago • 4 comments

I just slapped the Heun part at the end of EulerCFGpp and it slapped me back.

To compare:

Heun / HeunCFGpp / EulerCFGpp

combined_3_images

The fact that the Heun part rolls over the result of the CFGpp method seems to rebalance the effect of the CFG scale, which is also appreciable (basically burns less).

Extraltodeus avatar Aug 22 '24 22:08 Extraltodeus

    temp = [0]
    def post_cfg_function(args):
        temp[0] = args["uncond_denoised"]
        return args["denoised"]

this hack is unnecessary, it can just be written as:

    uncond = None
    def post_cfg_function(args):
        nonlocal uncond
        uncond = args["uncond_denoised"]
        return args["denoised"]

edit: i guess this is also the alternative version, not the official CFG++.

blepping avatar Aug 23 '24 15:08 blepping

Hello, indeed I simply took the Euler version as it can be found here. Would you prefer it if I adapted the function before any merging?

Extraltodeus avatar Aug 23 '24 17:08 Extraltodeus

Would you prefer it if I adapted the function before any merging?

i'm just a random person suggesting there's a more idiomatic way to extract the uncond into a variable. i have no authority whatsoever. :)

blepping avatar Aug 23 '24 18:08 blepping

oh okay! :)

Extraltodeus avatar Aug 23 '24 18:08 Extraltodeus

I added it to a new repository along with a sampler of mine,

Extraltodeus avatar Aug 27 '24 07:08 Extraltodeus