SegToMask SegToMask
Type 'sky, person, car' and get a mask — SegToMask does exactly that
- image
- model
- processor
- IMAGE
- MASK
What it does
SegToMask is the node this pack is named after, and it does one genuinely useful thing: you give it an image and a list of class names, it hands you back a mask of everything that matches. Want a mask of all the sky, all the people, all the cars, without hand-painting a single pixel? Type them in, run, done. It's the same job CLIPSeg or Grounding DINO + SAM do - semantic segmentation by class label - wrapped into a two-node ComfyUI pair.
How it works
Here's the whole mechanism. A segmentation model labels every pixel of your image with a class ("sky", "person", "chair", ...). The node keeps only the pixels whose label appears in your list, collapses them into a mask, and also renders a color-overlay image so you can see what actually matched. Nothing about the pixel math is exotic; the trick is purely that you select the regions by typing instead of drawing.
The inputs that matter
classes- a multiline STRING box. This is the only thing you'll touch from image to image. One class per line (comma-separated also works) and the model keeps everything matching.image- what you're segmenting.modelandprocessor- both come straight from the pack's PipelineLoader node. They're typed as MODEL, but they're really the segmentation pipeline's weights and its image processor.
Outputs are just two: MASK (the grayscale mask you actually want) and IMAGE (the overlay, so you can sanity-check that the mask matched the right stuff before you spend a generation on it).
What the mask is for
The classic use is inpainting. Wire MASK into a SetLatentNoiseMask or a crop-and-stitch inpaint workflow, and you can regenerate only the sky, only the background, only the table - with the denoise dial as your control. This is where masks still beat instruction-editing models: you get bit-identical pixels everywhere outside the mask and exact placement of the edit. Same idea works for compositing (cut the subject, drop it somewhere else) and for background removal.
Two limits to know before you get burned. First, the class vocabulary is whatever the frozen model knows - if it's an ADE20k-class checkpoint, that's roughly 150 everyday scene labels ("sky, person, car, chair, table, tree...") and precisely zero of "my favorite character." Second, same class means one mask: every person merges into a single blob. If you need per-person masks, that's instance segmentation - Impact Pack's SEGS route - not this node.
Install and troubleshooting
Install is the standard two-lane road, via Manager (search segment_to_mask_comfyui or SegToMask) or:
cd ComfyUI/custom_nodes
git clone https://github.com/ginlov/segment_to_mask_comfyui
then restart ComfyUI. First run downloads the model checkpoint from the HuggingFace Hub, so expect one slow queue at the start.
The honest verdict
Honest verdict, with full transparency: this pack is nearly abandoned - empty README, the repo 404s, about two installs on comfy.icu. If it installs and runs, it's a genuinely handy little node. If it doesn't, don't sink an evening into it. CLIPSeg and Grounding DINO + SAM are maintained, strictly more capable, and will happily produce the same mask with a model you can actually pick. The most common failure - a mask that comes back empty - is usually a class name that isn't in the model's vocabulary. Check spelling and case before you blame the pack.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| classes | STRING | — | |
| image | IMAGE | — | |
| model | MODEL | — | |
| processor | MODEL | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |
| MASK | MASK | — |