The most powerful and modular diffusion model GUI, api and backend with a graph/nodes interface. The fastest local inference engine in the world.
Fix cfg being calculated more than once if sampler_cfg_function.
comfyanonymous6c5990f7dba2
diff --git a/comfy/samplers.py b/comfy/samplers.pyindex 106e72876..7dc27528a 100644--- a/comfy/samplers.py+++ b/comfy/samplers.py@@ -250,10 +250,11 @@ def sampling_function(model, x, timestep, uncond, cond, cond_scale, model_optionuncond_ = uncondcond_pred, uncond_pred = calc_cond_uncond_batch(model, cond, uncond_, x, timestep, model_options)- cfg_result = uncond_pred + (cond_pred - uncond_pred) * cond_scaleif "sampler_cfg_function" in model_options:args = {"cond": x - cond_pred, "uncond": x - uncond_pred, "cond_scale": cond_scale, "timestep": timestep, "input": x, "sigma": timestep}cfg_result = x - model_options["sampler_cfg_function"](args)+ else:+ cfg_result = uncond_pred + (cond_pred - uncond_pred) * cond_scalefor fn in model_options.get("sampler_post_cfg_function", []):args = {"denoised": cfg_result, "cond": cond, "uncond": uncond, "model": model, "uncond_denoised": uncond_pred, "cond_denoised": cond_pred,