From d2e27b48f169b0e5def6b9b2c7874e4010282921 Mon Sep 17 00:00:00 2001 From: comfyanonymous Date: Wed, 1 Nov 2023 20:49:37 -0400 Subject: [PATCH] sampler_cfg_function now gets the noisy output as argument again. This should make things that use sampler_cfg_function behave like before. Added an input argument for those that want the denoised output. This means you can calculate the x0 prediction of the model by doing: (input - cond) for example. --- comfy/samplers.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/comfy/samplers.py b/comfy/samplers.py index 92ba5f8ecee..22a9b68aefb 100644 --- a/comfy/samplers.py +++ b/comfy/samplers.py @@ -251,8 +251,8 @@ def calc_cond_uncond_batch(model_function, cond, uncond, x_in, timestep, max_tot cond, uncond = calc_cond_uncond_batch(model_function, cond, uncond, x, timestep, max_total_area, model_options) if "sampler_cfg_function" in model_options: - args = {"cond": cond, "uncond": uncond, "cond_scale": cond_scale, "timestep": timestep} - return model_options["sampler_cfg_function"](args) + args = {"cond": x - cond, "uncond": x - uncond, "cond_scale": cond_scale, "timestep": timestep, "input": x} + return x - model_options["sampler_cfg_function"](args) else: return uncond + (cond - uncond) * cond_scale