SEGSRoundCornersDetailerHookProvider
Rounded Masks, So Detail Patches Stop Announcing Their Edges
- DETAILER_HOOK
Detected masks are lumpy. A YOLO box dilated by a few pixels gives you a rectangle with soft edges, and when you paste a refined crop back through that mask you sometimes see exactly what it is: a patch. Squared-off corners of slightly different skin tone or sharply different grain. SEGSRoundCornersDetailerHookProvider is a small, oddly satisfying fix - it rounds the corners of each detected mask, so the composite edge has nothing to give itself away.
The mechanism
The hook runs on the SEGS after detection, so the mask it receives is the post-dilation one. For each segment it finds the bounds of the actual mask (the non-zero pixels, not the bbox - so an irregular silhouette's true extent), then stamps a rounded rectangle into a fresh mask: two crossing rectangles and four circles at the corners, which is the classic way to draw a rounded box. That rounded mask multiplies the original, so what's left is the original mask minus its square corners.
The radius is capped at half the shorter side of those bounds, which is the correct guard - a radius bigger than that doesn't round the corner, it eats the whole side.
Then the detailer does its thing and feathers the rounded mask on the way out, so the corners aren't just rounded, they're soft. Order of operations is worth remembering: dilation, then rounding, then feathering. You can't round a mask that hasn't been dilated yet, and you don't want to feather before you've got the shape you want.
The one input
radius - INT, default 16, 0 to 512, in pixels. 0 leaves the mask untouched, which makes this a handy node to leave in a graph and switch off. 8–24 is the sweet spot for faces and hands at typical detail sizes; go higher for large regions, lower for tiny detections where a 16-pixel radius starts eating the chin.
Output is a DETAILER_HOOK. Connect it to FaceDetailer's detailer_hook, or to a detector's detailer_hook in split workflows where the SEGS come from BBOX Detector (SEGS) or Simple Detector (SEGS). Note the node's file location in the pack (ImpactPack/Util) doesn't match the category it gets filed under conceptually, so if you're hunting for it in the menu, it's near the SEGS filter hooks.
Combining with other hooks - a tiled VAE, a sampling size, a custom sampler - goes through DetailerHookCombine.
Where it earns its keep
The honest use case is cosmetic smoothing at paste boundaries, and it's a real one: on tall crops where a rectangular mask produces visible vertical seams either side of a face, or on hands where the mask corners land on a knuckle. It's also genuinely useful with Make Tile SEGS-style pipelines: tiles with rounded masks overlap more gracefully than a grid of hard rectangles, and the seams between tiles get much less obvious.
The less obvious use case is deliberately stylised. Round the mask a lot and you're compositing through a circular vignette, which is a legitimate look for portrait work and a fun thing to have in a hook slot.
Install
It's an Impact Pack node - nothing extra.
cd ComfyUI/custom_nodes
git clone https://github.com/ltdrdata/ComfyUI-Impact-Pack
cd ComfyUI-Impact-Pack
pip install -r requirements.txt
Windows portable: ..\..\..\python_embeded\python.exe -m pip install -r requirements.txt, then restart. Manager users search ComfyUI Impact Pack. On first launch the pack creates impact-pack.ini and downloads the default SAM checkpoint to models/sams; an empty file named skip_download_model in custom_nodes skips the download.
That mask blur work happens through OpenCV, and the pack has a gpu_gaussian_blur setting in impact-pack.ini - off by default, and it should stay off unless you have VRAM to spare. If mask feathering is slow on huge tile sets, that's the knob, but flipping it costs memory and needs a restart.
What it won't fix
Rounding corners hides a hard edge; it doesn't fix a content mismatch. If the refined crop has different lighting, a different colour cast, or a totally different face because your detailer prompt disagrees with your base prompt, rounded corners just frame the problem more attractively. And if the mask you're rounding is already the full crop - which happens with heavily dilated detections - there are no corners left to round and the node silently does nothing useful.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| radius | INT | 160–512 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| DETAILER_HOOK | DETAILER_HOOK | — |