mirror of
https://git.datalinker.icu/comfyanonymous/ComfyUI
synced 2026-09-13 13:57:15 +08:00
Added Combine versions of Cond/Cond Pair Set Props nodes, renamed Pair Cond to Cond Pair, fixed default conds never applying hooks (due to hooks key typo)
This commit is contained in:
parent
0f7d379d24
commit
0c8bd63aa9
@ -619,6 +619,12 @@ def combine_conditioning(conds: list):
|
|||||||
combined_conds.extend(cond)
|
combined_conds.extend(cond)
|
||||||
return combined_conds
|
return combined_conds
|
||||||
|
|
||||||
|
def combine_with_new_conds(conds: list, new_conds: list):
|
||||||
|
combined_conds = []
|
||||||
|
for c, new_c in zip(conds, new_conds):
|
||||||
|
combined_conds.append(combine_conditioning([c, new_c]))
|
||||||
|
return combined_conds
|
||||||
|
|
||||||
def set_mask_conds(conds: list, strength: float, set_cond_area: str,
|
def set_mask_conds(conds: list, strength: float, set_cond_area: str,
|
||||||
opt_mask: torch.Tensor=None, opt_hooks: HookGroup=None, opt_timestep_range: tuple[float,float]=None):
|
opt_mask: torch.Tensor=None, opt_hooks: HookGroup=None, opt_timestep_range: tuple[float,float]=None):
|
||||||
masked_conds = []
|
masked_conds = []
|
||||||
|
|||||||
@ -178,7 +178,7 @@ def finalize_default_conds(hooked_to_run: dict[comfy.hooks.HookGroup,list[tuple[
|
|||||||
continue
|
continue
|
||||||
# replace p's mult with calculated mult
|
# replace p's mult with calculated mult
|
||||||
p = p._replace(mult=mult)
|
p = p._replace(mult=mult)
|
||||||
hook: comfy.hooks.HookGroup = x.get('hook', None)
|
hook: comfy.hooks.HookGroup = x.get('hooks', None)
|
||||||
hooked_to_run.setdefault(hook, list())
|
hooked_to_run.setdefault(hook, list())
|
||||||
hooked_to_run[hook] += [(p, i)]
|
hooked_to_run[hook] += [(p, i)]
|
||||||
|
|
||||||
|
|||||||
@ -17,7 +17,7 @@ import folder_paths
|
|||||||
#------------------------------------------
|
#------------------------------------------
|
||||||
class PairConditioningSetProperties:
|
class PairConditioningSetProperties:
|
||||||
NodeId = 'PairConditioningSetProperties'
|
NodeId = 'PairConditioningSetProperties'
|
||||||
NodeName = 'Pair Cond Set Props'
|
NodeName = 'Cond Pair Set Props'
|
||||||
@classmethod
|
@classmethod
|
||||||
def INPUT_TYPES(s):
|
def INPUT_TYPES(s):
|
||||||
return {
|
return {
|
||||||
@ -47,6 +47,41 @@ class PairConditioningSetProperties:
|
|||||||
opt_mask=opt_mask, opt_hooks=opt_hooks, opt_timestep_range=opt_timesteps)
|
opt_mask=opt_mask, opt_hooks=opt_hooks, opt_timestep_range=opt_timesteps)
|
||||||
return (final_positive, final_negative)
|
return (final_positive, final_negative)
|
||||||
|
|
||||||
|
class PairConditioningSetPropertiesAndCombine:
|
||||||
|
NodeId = 'PairConditioningSetPropertiesAndCombine'
|
||||||
|
NodeName = 'Cond Pair Set Props Combine'
|
||||||
|
@classmethod
|
||||||
|
def INPUT_TYPES(s):
|
||||||
|
return {
|
||||||
|
"required": {
|
||||||
|
"positive": ("CONDITIONING", ),
|
||||||
|
"negative": ("CONDITIONING", ),
|
||||||
|
"positive_NEW": ("CONDITIONING", ),
|
||||||
|
"negative_NEW": ("CONDITIONING", ),
|
||||||
|
"strength": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 10.0, "step": 0.01}),
|
||||||
|
"set_cond_area": (["default", "mask bounds"],),
|
||||||
|
},
|
||||||
|
"optional": {
|
||||||
|
"opt_mask": ("MASK", ),
|
||||||
|
"opt_hooks": ("HOOKS",),
|
||||||
|
"opt_timesteps": ("TIMESTEPS_RANGE",),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
RETURN_TYPES = ("CONDITIONING", "CONDITIONING")
|
||||||
|
RETURN_NAMES = ("positive", "negative")
|
||||||
|
CATEGORY = "advanced/hooks/cond pair"
|
||||||
|
FUNCTION = "set_properties"
|
||||||
|
|
||||||
|
def set_properties(self, positive, negative, positive_NEW, negative_NEW,
|
||||||
|
strength: float, set_cond_area: str,
|
||||||
|
opt_mask: torch.Tensor=None, opt_hooks: comfy.hooks.HookGroup=None, opt_timesteps: tuple=None):
|
||||||
|
positive_NEW, negative_NEW = comfy.hooks.set_mask_conds(conds=[positive_NEW, negative_NEW],
|
||||||
|
strength=strength, set_cond_area=set_cond_area,
|
||||||
|
opt_mask=opt_mask, opt_hooks=opt_hooks, opt_timestep_range=opt_timesteps)
|
||||||
|
final_positive, final_negative = comfy.hooks.combine_with_new_conds(conds=[positive, negative], new_conds=[positive_NEW, negative_NEW])
|
||||||
|
return (final_positive, final_negative)
|
||||||
|
|
||||||
class ConditioningSetProperties:
|
class ConditioningSetProperties:
|
||||||
NodeId = 'ConditioningSetProperties'
|
NodeId = 'ConditioningSetProperties'
|
||||||
NodeName = 'Cond Set Props'
|
NodeName = 'Cond Set Props'
|
||||||
@ -77,9 +112,41 @@ class ConditioningSetProperties:
|
|||||||
opt_mask=opt_mask, opt_hooks=opt_hooks, opt_timestep_range=opt_timesteps)
|
opt_mask=opt_mask, opt_hooks=opt_hooks, opt_timestep_range=opt_timesteps)
|
||||||
return (final_cond,)
|
return (final_cond,)
|
||||||
|
|
||||||
|
class ConditioningSetPropertiesAndCombine:
|
||||||
|
NodeId = 'ConditioningSetPropertiesAndCombine'
|
||||||
|
NodeName = 'Cond Set Props Combine'
|
||||||
|
@classmethod
|
||||||
|
def INPUT_TYPES(s):
|
||||||
|
return {
|
||||||
|
"required": {
|
||||||
|
"cond": ("CONDITIONING", ),
|
||||||
|
"cond_NEW": ("CONDITIONING", ),
|
||||||
|
"strength": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 10.0, "step": 0.01}),
|
||||||
|
"set_cond_area": (["default", "mask bounds"],),
|
||||||
|
},
|
||||||
|
"optional": {
|
||||||
|
"opt_mask": ("MASK", ),
|
||||||
|
"opt_hooks": ("HOOKS",),
|
||||||
|
"opt_timesteps": ("TIMESTEPS_RANGE",),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
RETURN_TYPES = ("CONDITIONING",)
|
||||||
|
CATEGORY = "advanced/hooks/cond single"
|
||||||
|
FUNCTION = "set_properties"
|
||||||
|
|
||||||
|
def set_properties(self, cond, cond_NEW,
|
||||||
|
strength: float, set_cond_area: str,
|
||||||
|
opt_mask: torch.Tensor=None, opt_hooks: comfy.hooks.HookGroup=None, opt_timesteps: tuple=None):
|
||||||
|
(cond_NEW,) = comfy.hooks.set_mask_conds(conds=[cond_NEW],
|
||||||
|
strength=strength, set_cond_area=set_cond_area,
|
||||||
|
opt_mask=opt_mask, opt_hooks=opt_hooks, opt_timestep_range=opt_timesteps)
|
||||||
|
(final_cond,) = comfy.hooks.combine_with_new_conds(conds=[cond], new_conds=[cond_NEW])
|
||||||
|
return (final_cond,)
|
||||||
|
|
||||||
class PairConditioningCombine:
|
class PairConditioningCombine:
|
||||||
NodeId = 'PairConditioningCombine'
|
NodeId = 'PairConditioningCombine'
|
||||||
NodeName = 'Pair Cond Combine'
|
NodeName = 'Cond Pair Combine'
|
||||||
@classmethod
|
@classmethod
|
||||||
def INPUT_TYPES(s):
|
def INPUT_TYPES(s):
|
||||||
return {
|
return {
|
||||||
@ -102,7 +169,7 @@ class PairConditioningCombine:
|
|||||||
|
|
||||||
class PairConditioningSetDefaultAndCombine:
|
class PairConditioningSetDefaultAndCombine:
|
||||||
NodeId = 'PairConditioningSetDefaultCombine'
|
NodeId = 'PairConditioningSetDefaultCombine'
|
||||||
NodeName = 'Pair Cond Set Default Combine'
|
NodeName = 'Cond Pair Set Default Combine'
|
||||||
@classmethod
|
@classmethod
|
||||||
def INPUT_TYPES(s):
|
def INPUT_TYPES(s):
|
||||||
return {
|
return {
|
||||||
@ -759,7 +826,9 @@ node_list = [
|
|||||||
CombineHooksEight,
|
CombineHooksEight,
|
||||||
# Attach
|
# Attach
|
||||||
ConditioningSetProperties,
|
ConditioningSetProperties,
|
||||||
|
ConditioningSetPropertiesAndCombine,
|
||||||
PairConditioningSetProperties,
|
PairConditioningSetProperties,
|
||||||
|
PairConditioningSetPropertiesAndCombine,
|
||||||
ConditioningSetDefaultAndCombine,
|
ConditioningSetDefaultAndCombine,
|
||||||
PairConditioningSetDefaultAndCombine,
|
PairConditioningSetDefaultAndCombine,
|
||||||
PairConditioningCombine,
|
PairConditioningCombine,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user