From 8e976c736bcbb7bc881ee5d8a8e4335a9468f0ef Mon Sep 17 00:00:00 2001 From: Extraltodeus Date: Tue, 9 Jul 2024 03:44:47 +0200 Subject: [PATCH] Update samplers.py --- comfy/samplers.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/comfy/samplers.py b/comfy/samplers.py index c0aa12916..bbf9219f7 100644 --- a/comfy/samplers.py +++ b/comfy/samplers.py @@ -275,6 +275,12 @@ def sampling_function(model, x, timestep, uncond, cond, cond_scale, model_option conds = [cond, uncond_] out = calc_cond_batch(model, conds, x, timestep, model_options) + + for fn in model_options.get("sampler_pre_cfg_function", []): + args = {"conds":conds, "conds_out": out, "cond_scale": cond_scale, "timestep": timestep, + "input": x, "sigma": timestep, "model": model, "model_options": model_options} + out = fn(args) + return cfg_function(model, out[0], out[1], cond_scale, x, timestep, model_options=model_options, cond=cond, uncond=uncond_)