1
mirror of https://github.com/comfyanonymous/ComfyUI.git synced 2025-08-02 23:14:49 +08:00

Add sampler_pre_cfg_function (#3979)

* Update samplers.py

* Update model_patcher.py
This commit is contained in:
Extraltodeus
2024-07-09 22:20:49 +02:00
committed by GitHub
parent c3db344746
commit f1a01c2c7e
2 changed files with 15 additions and 0 deletions

View File

@@ -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_)