Files
CavinHuang-comfyui-nodes-docs/docs/ConditioningSetMaskAndCombine3.md
2024-07-04 08:39:03 +08:00

4.3 KiB

Documentation

ConditioningSetMaskAndCombine3节点用于将一组掩码应用于条件数据,可能会根据指定的参数修改条件区域,然后将这些条件元素组合成单一输出。它专注于通过应用具有不同强度和区域的多个掩码来增强或改变条件处理过程,从而实现复杂的条件场景。

Input types

Required

  • positive_i
    • 指定一组要被掩码处理和组合的正面条件元素。应用于这些元素的掩码的强度和区域可以调整,从而影响最终的条件输出。
    • Comfy dtype: CONDITIONING
    • Python dtype: List[torch.Tensor]
  • negative_i
    • 指定一组要被掩码处理和组合的负面条件元素。与正面输入类似,掩码的强度和区域设置会影响条件处理的结果。
    • Comfy dtype: CONDITIONING
    • Python dtype: List[torch.Tensor]
  • mask_i
    • 应用于条件元素的掩码。它定义了条件效果的区域和强度。
    • Comfy dtype: MASK
    • Python dtype: torch.Tensor
  • mask_i_strength
    • 定义应用于条件元素的掩码强度,影响条件处理的强度。
    • Comfy dtype: FLOAT
    • Python dtype: float
  • set_cond_area
    • 决定是将条件区域设置为掩码的边界还是使用默认设置,影响掩码的应用方式。
    • Comfy dtype: COMBO[STRING]
    • Python dtype: str

Output types

  • combined_positive
    • 掩码应用和处理后的正面条件元素的组合结果。
    • Comfy dtype: CONDITIONING
    • Python dtype: List[torch.Tensor]
  • combined_negative
    • 掩码应用和处理后的负面条件元素的组合结果。
    • Comfy dtype: CONDITIONING
    • Python dtype: List[torch.Tensor]

Usage tips

  • Infra type: CPU
  • Common nodes: unknown

Source code

class ConditioningSetMaskAndCombine3:
    @classmethod
    def INPUT_TYPES(cls):
        return {
            "required": {
                "positive_1": ("CONDITIONING", ),
                "negative_1": ("CONDITIONING", ),
                "positive_2": ("CONDITIONING", ),
                "negative_2": ("CONDITIONING", ),
                "positive_3": ("CONDITIONING", ),
                "negative_3": ("CONDITIONING", ),
                "mask_1": ("MASK", ),
                "mask_2": ("MASK", ),
                "mask_3": ("MASK", ),
                "mask_1_strength": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 10.0, "step": 0.01}),
                "mask_2_strength": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 10.0, "step": 0.01}),
                "mask_3_strength": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 10.0, "step": 0.01}),
                "set_cond_area": (["default", "mask bounds"],),
            }
        }

    RETURN_TYPES = ("CONDITIONING","CONDITIONING",)
    RETURN_NAMES = ("combined_positive", "combined_negative",)
    FUNCTION = "append"
    CATEGORY = "KJNodes/masking/conditioning"
    DESCRIPTION = """
Bundles multiple conditioning mask and combine nodes into one,functionality is identical to ComfyUI native nodes
"""

    def append(self, positive_1, negative_1, positive_2, positive_3, negative_2, negative_3, mask_1, mask_2, mask_3, set_cond_area, mask_1_strength, mask_2_strength, mask_3_strength):
        c = []
        c2 = []
        set_area_to_bounds = False
        if set_cond_area != "default":
            set_area_to_bounds = True
        if len(mask_1.shape) < 3:
            mask_1 = mask_1.unsqueeze(0)
        if len(mask_2.shape) < 3:
            mask_2 = mask_2.unsqueeze(0)
        if len(mask_3.shape) < 3:
            mask_3 = mask_3.unsqueeze(0)
        for t in positive_1:
            append_helper(t, mask_1, c, set_area_to_bounds, mask_1_strength)
        for t in positive_2:
            append_helper(t, mask_2, c, set_area_to_bounds, mask_2_strength)
        for t in positive_3:
            append_helper(t, mask_3, c, set_area_to_bounds, mask_3_strength)
        for t in negative_1:
            append_helper(t, mask_1, c2, set_area_to_bounds, mask_1_strength)
        for t in negative_2:
            append_helper(t, mask_2, c2, set_area_to_bounds, mask_2_strength)
        for t in negative_3:
            append_helper(t, mask_3, c2, set_area_to_bounds, mask_3_strength)
        return (c, c2)