MASK to SEGS
Bring any mask into Impact Pack's detailer pipeline
- mask
- SEGS
Impact Pack's detailers and upscalers eat SEGS, not masks. So when you already have a mask - you painted it by hand, or you got it from CLIPSeg, or SAM, or a background remover - and you want the detailer to work on that exact area, you need a converter. MASK to SEGS is it. Hand it a mask, get back a SEGS you can feed straight into DetailerForEachPipe or SEGS Upscaler. It's the bridge that lets you skip the built-in detectors entirely and detail wherever you decide.
This is genuinely handy. It means the whole detect-crop-refine machine isn't limited to what a YOLO model can find. Anything you can mask, you can detail.
How it works
It reads the mask, finds the distinct blobs in it, and wraps each one in a SEG with a crop region sized around it. By default each separated region becomes its own SEG, so a mask with three painted spots produces three detections the detailer will handle independently. Flip combined and the whole mask collapses into one region instead.
The inputs and outputs that matter
mask(MASK) - your source mask. Any mask node upstream works.combined(default off) - off means each separate blob becomes its own SEG; on means the entire mask is treated as a single region. Turn it on when you want one unified detail pass over everything you masked, rather than one pass per blob.crop_factor(default 3) - how much surrounding context each crop includes. Same idea as on the detectors: more context blends better but works a bigger area. 3 is a sane start.bbox_fill(default off) - fill the whole bounding box as the mask rather than following the painted shape.contour_fill(default off) - fill the interior of each contour, useful when your mask is an outline rather than a solid shape.drop_size(default 10) - ignore blobs smaller than this, so stray specks in a rough mask don't each become a detection.
The single output is SEGS - wire it into a Detailer, a filter, or a preview.
How to install it
ComfyUI Manager: search ComfyUI Impact Pack, Install, restart.
Manual:
cd ComfyUI/custom_nodes
git clone https://github.com/ltdrdata/ComfyUI-Impact-Pack
cd ComfyUI-Impact-Pack
pip install -r requirements.txt
Run that in ComfyUI's Python environment and restart. This node needs no detection model of its own - that's the whole point, you're supplying the "detection" as a mask. It does depend on the pack's normal libraries (OpenCV, scikit-image), which the requirements file installs.
Common issues & troubleshooting
One big mask became a dozen tiny SEGs. Your mask has speckle. Raise drop_size to ignore the little blobs, or turn on combined to force it all into one region.
The detail pass has a hard rectangular edge. You're probably running with bbox_fill on, which masks the full box instead of the painted shape. Turn it off so the region follows your actual mask outline, and give it some crop_factor for context to blend into.
A thin outline mask detailed nothing useful. If your mask is a hollow contour, turn on contour_fill so the enclosed area becomes solid before it's converted - otherwise there's barely any masked region for the detailer to work in.
Remember to composite. SEGS from a mask still run through the normal detailer, which crops, re-renders and pastes back. As always with this pattern, keep denoise moderate on the downstream detailer so the fixed region blends rather than reinventing itself.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| mask | MASK | — | |
| combined | BOOLEAN | false | — |
| crop_factor | FLOAT | 3.01–100 | — |
| bbox_fill | BOOLEAN | false | — |
| drop_size | INT | 101–16384 | — |
| contour_fill | BOOLEAN | false | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| SEGS | SEGS | — |