Dilate Mask (SEGS)
Grow every detection's mask at once
- segs
- SEGS
This is the SEGS-native version of a mask trick everyone eventually needs: growing the mask a little so a detail pass has room to blend. When a detector nails a face outline exactly, the refined region can end up with a visible edge right where the mask stopped. Pad the mask outward and the seam moves into forgiving territory. Dilate Mask (SEGS) does that padding to every mask inside a SEGS in one shot, so you don't have to decompose the SEGS, dilate each mask by hand, and reassemble it.
You'll want it in detailing workflows where the fix looks pasted-on, or where the detected box is clipping part of what you actually want redone - a face mask that cuts off the jaw, say.
How it works
The README describes it as "Dilate/Erosion Mask in SEGS," and that erosion half is the quietly useful part. dilation is a signed number. Positive values grow each SEG's mask outward (more room to blend, more surrounding pixels pulled into the fix); negative values shrink it inward (tighter fix, less spill into the background). It's a morphological operation applied per detection, and it leaves everything else about the SEGS - the crop boxes, labels, images - untouched. Only the masks change.
Growing the mask matters because the detail pass regenerates whatever the mask covers. Too tight and you get a hard seam or a fix that doesn't cover the whole feature; too loose and you start redrawing background you meant to keep. This node is where you dial that in for the whole batch of detections at once.
The inputs and outputs
segs- the detections whose masks you want to resize. Required.dilation(default 10) - pixels to grow (positive) or shrink (negative). Range is wide (−512 to 512), but you're usually living in single or low double digits. Start around 10 to soften a seam; go negative when the mask is grabbing too much.
Output is a SEGS with the same detections and resized masks, ready for a detailer or a paste.
How to install it
ComfyUI Manager: search ComfyUI Impact Pack, install, restart. By hand: cd ComfyUI/custom_nodes && git clone https://github.com/ltdrdata/ComfyUI-Impact-Pack, install requirements into ComfyUI's own Python (pip install -r requirements.txt, or ..\..\..\python_embeded\python.exe -m pip install -r requirements.txt on Windows portable), and restart. The pack dropped auto-install at v7.6, so run requirements yourself. First launch pulls a small SAM model into ComfyUI/models/sams.
Common issues
You over-dilated and the fix bled into the background. Big positive dilation on a face means the detail pass now regenerates hair, neck, and a chunk of scenery, which can drift the surrounding style. Ease the number down. The README's own note on FaceDetailer makes the same point in reverse - heavy dilation is useful when you want to reshape more than the face, and a liability when you don't.
Nothing looks different. If the SEGS is empty, or the dilation is tiny relative to your image, the change won't be visible. Bump the value or check the detector actually produced detections.
Don't confuse it with Dilate Mask. That sibling node works on a plain MASK; this one works inside a SEGS. Wrong node for the type you're holding and it simply won't connect.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| segs | SEGS | — | |
| dilation | INT | 10-512–512 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| SEGS | SEGS | — |