On Cond/Cond Pair nodes, removed opt_ prefix from optional inputs

This commit is contained in:
Jedrzej Kosinski 2024-11-21 15:50:10 -06:00
parent d38c535771
commit 1c86976f8e
2 changed files with 33 additions and 33 deletions

View File

@ -648,43 +648,43 @@ def combine_with_new_conds(conds: list, new_conds: list):
return combined_conds return combined_conds
def set_conds_props(conds: list, strength: float, set_cond_area: str, def set_conds_props(conds: list, strength: float, set_cond_area: str,
opt_mask: torch.Tensor=None, opt_hooks: HookGroup=None, opt_timestep_range: tuple[float,float]=None, append_hooks=True): mask: torch.Tensor=None, hooks: HookGroup=None, timesteps_range: tuple[float,float]=None, append_hooks=True):
final_conds = [] final_conds = []
for c in conds: for c in conds:
# first, apply lora_hook to conditioning, if provided # first, apply lora_hook to conditioning, if provided
c = set_hooks_for_conditioning(c, opt_hooks, append_hooks=append_hooks) c = set_hooks_for_conditioning(c, hooks, append_hooks=append_hooks)
# next, apply mask to conditioning # next, apply mask to conditioning
c = set_mask_for_conditioning(cond=c, mask=opt_mask, strength=strength, set_cond_area=set_cond_area) c = set_mask_for_conditioning(cond=c, mask=mask, strength=strength, set_cond_area=set_cond_area)
# apply timesteps, if present # apply timesteps, if present
c = set_timesteps_for_conditioning(cond=c, timestep_range=opt_timestep_range) c = set_timesteps_for_conditioning(cond=c, timestep_range=timesteps_range)
# finally, apply mask to conditioning and store # finally, apply mask to conditioning and store
final_conds.append(c) final_conds.append(c)
return final_conds return final_conds
def set_conds_props_and_combine(conds: list, new_conds: list, strength: float=1.0, set_cond_area: str="default", def set_conds_props_and_combine(conds: list, new_conds: list, strength: float=1.0, set_cond_area: str="default",
opt_mask: torch.Tensor=None, opt_hooks: HookGroup=None, opt_timestep_range: tuple[float,float]=None, append_hooks=True): mask: torch.Tensor=None, hooks: HookGroup=None, timesteps_range: tuple[float,float]=None, append_hooks=True):
combined_conds = [] combined_conds = []
for c, masked_c in zip(conds, new_conds): for c, masked_c in zip(conds, new_conds):
# first, apply lora_hook to new conditioning, if provided # first, apply lora_hook to new conditioning, if provided
masked_c = set_hooks_for_conditioning(masked_c, opt_hooks, append_hooks=append_hooks) masked_c = set_hooks_for_conditioning(masked_c, hooks, append_hooks=append_hooks)
# next, apply mask to new conditioning, if provided # next, apply mask to new conditioning, if provided
masked_c = set_mask_for_conditioning(cond=masked_c, mask=opt_mask, set_cond_area=set_cond_area, strength=strength) masked_c = set_mask_for_conditioning(cond=masked_c, mask=mask, set_cond_area=set_cond_area, strength=strength)
# apply timesteps, if present # apply timesteps, if present
masked_c = set_timesteps_for_conditioning(cond=masked_c, timestep_range=opt_timestep_range) masked_c = set_timesteps_for_conditioning(cond=masked_c, timestep_range=timesteps_range)
# finally, combine with existing conditioning and store # finally, combine with existing conditioning and store
combined_conds.append(combine_conditioning([c, masked_c])) combined_conds.append(combine_conditioning([c, masked_c]))
return combined_conds return combined_conds
def set_default_conds_and_combine(conds: list, new_conds: list, def set_default_conds_and_combine(conds: list, new_conds: list,
opt_hooks: HookGroup=None, opt_timestep_range: tuple[float,float]=None, append_hooks=True): hooks: HookGroup=None, timesteps_range: tuple[float,float]=None, append_hooks=True):
combined_conds = [] combined_conds = []
for c, new_c in zip(conds, new_conds): for c, new_c in zip(conds, new_conds):
# first, apply lora_hook to new conditioning, if provided # first, apply lora_hook to new conditioning, if provided
new_c = set_hooks_for_conditioning(new_c, opt_hooks, append_hooks=append_hooks) new_c = set_hooks_for_conditioning(new_c, hooks, append_hooks=append_hooks)
# next, add default_cond key to cond so that during sampling, it can be identified # next, add default_cond key to cond so that during sampling, it can be identified
new_c = conditioning_set_values(new_c, {'default': True}) new_c = conditioning_set_values(new_c, {'default': True})
# apply timesteps, if present # apply timesteps, if present
new_c = set_timesteps_for_conditioning(cond=new_c, timestep_range=opt_timestep_range) new_c = set_timesteps_for_conditioning(cond=new_c, timestep_range=timesteps_range)
# finally, combine with existing conditioning and store # finally, combine with existing conditioning and store
combined_conds.append(combine_conditioning([c, new_c])) combined_conds.append(combine_conditioning([c, new_c]))
return combined_conds return combined_conds

View File

@ -28,9 +28,9 @@ class PairConditioningSetProperties:
"set_cond_area": (["default", "mask bounds"],), "set_cond_area": (["default", "mask bounds"],),
}, },
"optional": { "optional": {
"opt_mask": ("MASK", ), "mask": ("MASK", ),
"opt_hooks": ("HOOKS",), "hooks": ("HOOKS",),
"opt_timesteps": ("TIMESTEPS_RANGE",), "timesteps": ("TIMESTEPS_RANGE",),
} }
} }
@ -41,10 +41,10 @@ class PairConditioningSetProperties:
def set_properties(self, positive_NEW, negative_NEW, def set_properties(self, positive_NEW, negative_NEW,
strength: float, set_cond_area: str, strength: float, set_cond_area: str,
opt_mask: torch.Tensor=None, opt_hooks: comfy.hooks.HookGroup=None, opt_timesteps: tuple=None): mask: torch.Tensor=None, hooks: comfy.hooks.HookGroup=None, timesteps: tuple=None):
final_positive, final_negative = comfy.hooks.set_conds_props(conds=[positive_NEW, negative_NEW], final_positive, final_negative = comfy.hooks.set_conds_props(conds=[positive_NEW, negative_NEW],
strength=strength, set_cond_area=set_cond_area, strength=strength, set_cond_area=set_cond_area,
opt_mask=opt_mask, opt_hooks=opt_hooks, opt_timestep_range=opt_timesteps) mask=mask, hooks=hooks, timesteps_range=timesteps)
return (final_positive, final_negative) return (final_positive, final_negative)
class PairConditioningSetPropertiesAndCombine: class PairConditioningSetPropertiesAndCombine:
@ -62,9 +62,9 @@ class PairConditioningSetPropertiesAndCombine:
"set_cond_area": (["default", "mask bounds"],), "set_cond_area": (["default", "mask bounds"],),
}, },
"optional": { "optional": {
"opt_mask": ("MASK", ), "mask": ("MASK", ),
"opt_hooks": ("HOOKS",), "hooks": ("HOOKS",),
"opt_timesteps": ("TIMESTEPS_RANGE",), "timesteps": ("TIMESTEPS_RANGE",),
} }
} }
@ -75,10 +75,10 @@ class PairConditioningSetPropertiesAndCombine:
def set_properties(self, positive, negative, positive_NEW, negative_NEW, def set_properties(self, positive, negative, positive_NEW, negative_NEW,
strength: float, set_cond_area: str, strength: float, set_cond_area: str,
opt_mask: torch.Tensor=None, opt_hooks: comfy.hooks.HookGroup=None, opt_timesteps: tuple=None): mask: torch.Tensor=None, hooks: comfy.hooks.HookGroup=None, timesteps: tuple=None):
final_positive, final_negative = comfy.hooks.set_conds_props_and_combine(conds=[positive, negative], new_conds=[positive_NEW, negative_NEW], final_positive, final_negative = comfy.hooks.set_conds_props_and_combine(conds=[positive, negative], new_conds=[positive_NEW, negative_NEW],
strength=strength, set_cond_area=set_cond_area, strength=strength, set_cond_area=set_cond_area,
opt_mask=opt_mask, opt_hooks=opt_hooks, opt_timestep_range=opt_timesteps) mask=mask, hooks=hooks, timesteps_range=timesteps)
return (final_positive, final_negative) return (final_positive, final_negative)
class ConditioningSetProperties: class ConditioningSetProperties:
@ -93,9 +93,9 @@ class ConditioningSetProperties:
"set_cond_area": (["default", "mask bounds"],), "set_cond_area": (["default", "mask bounds"],),
}, },
"optional": { "optional": {
"opt_mask": ("MASK", ), "mask": ("MASK", ),
"opt_hooks": ("HOOKS",), "hooks": ("HOOKS",),
"opt_timesteps": ("TIMESTEPS_RANGE",), "timesteps": ("TIMESTEPS_RANGE",),
} }
} }
@ -105,10 +105,10 @@ class ConditioningSetProperties:
def set_properties(self, cond_NEW, def set_properties(self, cond_NEW,
strength: float, set_cond_area: str, strength: float, set_cond_area: str,
opt_mask: torch.Tensor=None, opt_hooks: comfy.hooks.HookGroup=None, opt_timesteps: tuple=None): mask: torch.Tensor=None, hooks: comfy.hooks.HookGroup=None, timesteps: tuple=None):
(final_cond,) = comfy.hooks.set_conds_props(conds=[cond_NEW], (final_cond,) = comfy.hooks.set_conds_props(conds=[cond_NEW],
strength=strength, set_cond_area=set_cond_area, strength=strength, set_cond_area=set_cond_area,
opt_mask=opt_mask, opt_hooks=opt_hooks, opt_timestep_range=opt_timesteps) mask=mask, hooks=hooks, timesteps_range=timesteps)
return (final_cond,) return (final_cond,)
class ConditioningSetPropertiesAndCombine: class ConditioningSetPropertiesAndCombine:
@ -124,9 +124,9 @@ class ConditioningSetPropertiesAndCombine:
"set_cond_area": (["default", "mask bounds"],), "set_cond_area": (["default", "mask bounds"],),
}, },
"optional": { "optional": {
"opt_mask": ("MASK", ), "mask": ("MASK", ),
"opt_hooks": ("HOOKS",), "hooks": ("HOOKS",),
"opt_timesteps": ("TIMESTEPS_RANGE",), "timesteps": ("TIMESTEPS_RANGE",),
} }
} }
@ -136,10 +136,10 @@ class ConditioningSetPropertiesAndCombine:
def set_properties(self, cond, cond_NEW, def set_properties(self, cond, cond_NEW,
strength: float, set_cond_area: str, strength: float, set_cond_area: str,
opt_mask: torch.Tensor=None, opt_hooks: comfy.hooks.HookGroup=None, opt_timesteps: tuple=None): mask: torch.Tensor=None, hooks: comfy.hooks.HookGroup=None, timesteps: tuple=None):
(final_cond,) = comfy.hooks.set_conds_props_and_combine(conds=[cond], new_conds=[cond_NEW], (final_cond,) = comfy.hooks.set_conds_props_and_combine(conds=[cond], new_conds=[cond_NEW],
strength=strength, set_cond_area=set_cond_area, strength=strength, set_cond_area=set_cond_area,
opt_mask=opt_mask, opt_hooks=opt_hooks, opt_timestep_range=opt_timesteps) mask=mask, hooks=hooks, timesteps_range=timesteps)
return (final_cond,) return (final_cond,)
class PairConditioningCombine: class PairConditioningCombine:
@ -190,7 +190,7 @@ class PairConditioningSetDefaultAndCombine:
def set_default_and_combine(self, positive, negative, positive_DEFAULT, negative_DEFAULT, def set_default_and_combine(self, positive, negative, positive_DEFAULT, negative_DEFAULT,
opt_hooks: comfy.hooks.HookGroup=None): opt_hooks: comfy.hooks.HookGroup=None):
final_positive, final_negative = comfy.hooks.set_default_conds_and_combine(conds=[positive, negative], new_conds=[positive_DEFAULT, negative_DEFAULT], final_positive, final_negative = comfy.hooks.set_default_conds_and_combine(conds=[positive, negative], new_conds=[positive_DEFAULT, negative_DEFAULT],
opt_hooks=opt_hooks) hooks=opt_hooks)
return (final_positive, final_negative) return (final_positive, final_negative)
class ConditioningSetDefaultAndCombine: class ConditioningSetDefaultAndCombine:
@ -215,7 +215,7 @@ class ConditioningSetDefaultAndCombine:
def set_default_and_combine(self, cond, cond_DEFAULT, def set_default_and_combine(self, cond, cond_DEFAULT,
opt_hooks: comfy.hooks.HookGroup=None): opt_hooks: comfy.hooks.HookGroup=None):
(final_conditioning,) = comfy.hooks.set_default_conds_and_combine(conds=[cond], new_conds=[cond_DEFAULT], (final_conditioning,) = comfy.hooks.set_default_conds_and_combine(conds=[cond], new_conds=[cond_DEFAULT],
opt_hooks=opt_hooks) hooks=opt_hooks)
return (final_conditioning,) return (final_conditioning,)
class SetClipHooks: class SetClipHooks: