diff --git a/comfy_extras/nodes_mask.py b/comfy_extras/nodes_mask.py index 8f87e4cd..aa13cac0 100644 --- a/comfy_extras/nodes_mask.py +++ b/comfy_extras/nodes_mask.py @@ -1,5 +1,5 @@ import numpy as np -from scipy.ndimage import grey_dilation +import scipy.ndimage import torch import comfy.utils @@ -311,7 +311,7 @@ class GrowMask: return { "required": { "mask": ("MASK",), - "expand": ("INT", {"default": 0, "min": 0, "max": MAX_RESOLUTION, "step": 1}), + "expand": ("INT", {"default": 0, "min": -MAX_RESOLUTION, "max": MAX_RESOLUTION, "step": 1}), "tapered_corners": ("BOOLEAN", {"default": True}), }, } @@ -328,8 +328,11 @@ class GrowMask: [1, 1, 1], [c, 1, c]]) output = mask.numpy().copy() + while expand < 0: + output = scipy.ndimage.grey_erosion(output, footprint=kernel) + expand += 1 while expand > 0: - output = grey_dilation(output, footprint=kernel) + output = scipy.ndimage.grey_dilation(output, footprint=kernel) expand -= 1 output = torch.from_numpy(output) return (output,)