mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2025-04-19 19:03:51 +00:00
Cleanup SkipLayerGuidanceSD3 node.
This commit is contained in:
parent
954683d0db
commit
770ab200f2
@ -119,11 +119,12 @@ class SkipLayerGuidanceSD3:
|
|||||||
if layers == "" or layers == None:
|
if layers == "" or layers == None:
|
||||||
return (model, )
|
return (model, )
|
||||||
# check if layer is comma separated integers
|
# check if layer is comma separated integers
|
||||||
assert layers.replace(",", "").isdigit(), "Layers must be comma separated integers"
|
|
||||||
def skip(args, extra_args):
|
def skip(args, extra_args):
|
||||||
return args
|
return args
|
||||||
|
|
||||||
model_sampling = model.get_model_object("model_sampling")
|
model_sampling = model.get_model_object("model_sampling")
|
||||||
|
sigma_start = model_sampling.percent_to_sigma(start_percent)
|
||||||
|
sigma_end = model_sampling.percent_to_sigma(end_percent)
|
||||||
|
|
||||||
def post_cfg_function(args):
|
def post_cfg_function(args):
|
||||||
model = args["model"]
|
model = args["model"]
|
||||||
@ -137,10 +138,9 @@ class SkipLayerGuidanceSD3:
|
|||||||
for layer in layers:
|
for layer in layers:
|
||||||
model_options = comfy.model_patcher.set_model_options_patch_replace(model_options, skip, "dit", "double_block", layer)
|
model_options = comfy.model_patcher.set_model_options_patch_replace(model_options, skip, "dit", "double_block", layer)
|
||||||
model_sampling.percent_to_sigma(start_percent)
|
model_sampling.percent_to_sigma(start_percent)
|
||||||
sigma_start = model_sampling.percent_to_sigma(start_percent)
|
|
||||||
sigma_end = model_sampling.percent_to_sigma(end_percent)
|
|
||||||
sigma_ = sigma[0].item()
|
sigma_ = sigma[0].item()
|
||||||
if scale > 0 and sigma_ > sigma_end and sigma_ < sigma_start:
|
if scale > 0 and sigma_ >= sigma_end and sigma_ <= sigma_start:
|
||||||
(slg,) = comfy.samplers.calc_cond_batch(model, [cond], x, sigma, model_options)
|
(slg,) = comfy.samplers.calc_cond_batch(model, [cond], x, sigma, model_options)
|
||||||
cfg_result = cfg_result + (cond_pred - slg) * scale
|
cfg_result = cfg_result + (cond_pred - slg) * scale
|
||||||
return cfg_result
|
return cfg_result
|
||||||
|
Loading…
Reference in New Issue
Block a user