diff --git a/nodes.py b/nodes.py index 9fea98b..47e9448 100644 --- a/nodes.py +++ b/nodes.py @@ -137,7 +137,7 @@ class CreateFadeMask: "height": ("INT", {"default": 256,"min": 16, "max": 4096, "step": 1}), "interpolation": (["linear", "ease_in", "ease_out", "ease_in_out"],), "start_level": ("FLOAT", {"default": 1.0,"min": 0.0, "max": 1.0, "step": 0.01}), - "midpoint_level": ("FLOAT", {"default": 1.0,"min": 0.0, "max": 1.0, "step": 0.01}), + "midpoint_level": ("FLOAT", {"default": 0.5,"min": 0.0, "max": 1.0, "step": 0.01}), "end_level": ("FLOAT", {"default": 0.0,"min": 0.0, "max": 1.0, "step": 0.01}), }, } @@ -291,7 +291,6 @@ class GrowMaskWithBlur: else: expand += abs(incremental_expandrate) # Use abs(growrate) to ensure positive change output = torch.from_numpy(output) - print(output.shape) out.append(output) blurred = torch.stack(out, dim=0).reshape((-1, 1, mask.shape[-2], mask.shape[-1])).movedim(1, -1).expand(-1, -1, -1, 3) @@ -456,13 +455,93 @@ class ConditioningSetMaskAndCombine: n[1]['mask_strength'] = strength c2.append(n) return (c, c2) - + +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", ), + "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" + + def append(self, positive_1, negative_1, positive_2, positive_3, negative_2, negative_3, mask_1, mask_2, mask_3, set_cond_area, 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: + n = [t[0], t[1].copy()] + _, h, w = mask_1.shape + n[1]['mask'] = mask_1 + n[1]['set_area_to_bounds'] = set_area_to_bounds + n[1]['mask_strength'] = strength + c.append(n) + for t in positive_2: + n = [t[0], t[1].copy()] + _, h, w = mask_2.shape + n[1]['mask'] = mask_2 + n[1]['set_area_to_bounds'] = set_area_to_bounds + n[1]['mask_strength'] = strength + c.append(n) + for t in positive_3: + n = [t[0], t[1].copy()] + _, h, w = mask_3.shape + n[1]['mask'] = mask_3 + n[1]['set_area_to_bounds'] = set_area_to_bounds + n[1]['mask_strength'] = strength + c.append(n) + for t in negative_1: + n = [t[0], t[1].copy()] + _, h, w = mask_1.shape + n[1]['mask'] = mask_1 + n[1]['set_area_to_bounds'] = set_area_to_bounds + n[1]['mask_strength'] = strength + c2.append(n) + for t in negative_2: + n = [t[0], t[1].copy()] + _, h, w = mask_2.shape + n[1]['mask'] = mask_2 + n[1]['set_area_to_bounds'] = set_area_to_bounds + n[1]['mask_strength'] = strength + c2.append(n) + for t in negative_3: + n = [t[0], t[1].copy()] + _, h, w = mask_3.shape + n[1]['mask'] = mask_3 + n[1]['set_area_to_bounds'] = set_area_to_bounds + n[1]['mask_strength'] = strength + c2.append(n) + return (c, c2) NODE_CLASS_MAPPINGS = { "INTConstant": INTConstant, "ConditioningMultiCombine": ConditioningMultiCombine, "ConditioningSetMaskAndCombine": ConditioningSetMaskAndCombine, + "ConditioningSetMaskAndCombine3": ConditioningSetMaskAndCombine3, "GrowMaskWithBlur": GrowMaskWithBlur, "ColorToMask": ColorToMask, "CreateGradientMask": CreateGradientMask, @@ -474,6 +553,7 @@ NODE_DISPLAY_NAME_MAPPINGS = { "INTConstant": "INT Constant", "ConditioningMultiCombine": "Conditioning Multi Combine", "ConditioningSetMaskAndCombine": "ConditioningSetMaskAndCombine", + "ConditioningSetMaskAndCombine3": "ConditioningSetMaskAndCombine3", "GrowMaskWithBlur": "GrowMaskWithBlur", "ColorToMask": "ColorToMask", "CreateGradientMask": "CreateGradientMask",