"...lm-evaluation-harness.git" did not exist on "2c18e367c6ded428863cd1fd4cf9558ca49d68dc"
Commit d76d71de authored by comfyanonymous's avatar comfyanonymous
Browse files

GrowMask can now be used with negative numbers to erode it.

parent d2cec6cd
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,)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment