Nodes/ComfyUI-AusBoss/Mask by Name πŸ†Ž
ComfyUI Node

Mask by Name πŸ†Ž

Type \"the dog\" and get the mask, no painting

By ausbossΒ·Created 3 months agoΒ·Updated about 9 hours agoΒ· 107
Mask by Name πŸ†Ž
  • image
  • model
  • clip
  • mask
  • cut_out
  • found
β—„namethe personβ–Ί
β—„severalall of themβ–Ί
β—„grow0β–Ί
β—„soften0.0β–Ί
β—„if_nothingstop the runβ–Ί
β—„previewtrueβ–Ί
β—„threshold0.70β–Ί
β—„fill_holesfalseβ–Ί
β—„free_vramfalseβ–Ί

Painting a mask by hand is the least fun part of an inpainting workflow, and it's the part that quietly ruins results - a sloppy mask edge is a visible seam. Mask by Name replaces it with a text box. Type the dog, or the red jacket, and you get a mask back. Until SAM 3 you couldn't do that in core ComfyUI at all: you needed GroundingDINO to find the thing and SAM to cut it, two models glued together.

How it works

The node is a thin, opinionated front end on ComfyUI's own SAM 3 Detect node. You wire image, plus model and clip from a Load Checkpoint that loads the SAM 3 file - the pack's error message names it, sam3.1_multiplex_fp16.safetensors. SAM 3 is the version of Segment Anything that takes a text phrase instead of a click, open-vocabulary across a claimed 270,000 concepts. So the node hands your phrase to that text reader, gets back per-object masks and confidence scores, and then does the mask cleanup around it.

The output that matters is mask - white where the thing is, one mask per picture. Then cut_out, the same picture with everything else see-through (RGBA), which is genuinely useful on its own: that's your background removal done, no second node. And found, an integer count of matches in the first picture, so you can tell "it worked" from "it found five dogs" without looking.

The inputs you'll actually touch:

  • name - what to find, in a few plain words. Commas separate several things (the dog, the ball), and a name you end in :2 keeps your own count rather than the node's generous match limit.
  • several - when more than one thing matches, mask all of them or just the biggest. the biggest is the quiet hero here; it turns a noisy multi-match into a single clean subject.
  • if_nothing - default stop the run, which is a deliberate choice. It stops with a readable message instead of quietly feeding an empty mask into your inpainter and producing a full-image repaint. Switch to empty mask only if you have downstream logic that handles it.
  • threshold (under More) - how sure SAM 3 must be. Read the author's reasoning before you fiddle: measured across 16 pictures, correct names scored 0.89–0.99, small real things like lips and shoes 0.67–0.79, while a name that wasn't in the picture scored above 0.5 half the time. That's why the default is 0.7 and not ComfyUI's own 0.5 - at 0.5, every second wrong name "finds" something. Lower it for a small thing you know is there; raise it when it grabs the wrong object.

grow and soften do the usual mask work (0 keeps the exact outline), fill_holes closes the speckle SAM 3 leaves in hair and cloth, and free_vram unloads SAM 3 right after the search - turn that on if a big model loads later in the same workflow. The node is an output node, so the FIND button runs it alone and lets you check the mask before committing to the rest of the graph.

Install

Search AusBoss in ComfyUI Manager, or:

cd ComfyUI/custom_nodes
git clone https://github.com/ausboss/ComfyUI-AusBoss.git

The pack needs no pip packages and downloads no weights. This node, though, needs ComfyUI 0.20 or newer, because SAM 3 Detect is core - install the pack on an older core and you get "Mask by Name needs ComfyUI 0.20 or newer" rather than a cryptic failure. You supply the checkpoint yourself: the pack never fetches models.

Where people get burned

Wrong checkpoint, confusing error. Wiring a normal SD checkpoint into model/clip doesn't work and you'll get "could not search the picture" pointing at the SAM 3 filename. Both sockets must come from one Load Checkpoint holding the SAM 3 file.

Empty mask, repainted image. If a run seems to do nothing but your inpainter repaints everything, you got an empty mask. Check found and the tinted preview before blaming the sampler.

Reaching for it where a detector is better. Promptable masking is for the one-off object nothing has a trained detector for. For faces, hands and people - the cases with fast, purpose-trained YOLO weights - describing "a face" to an open-vocabulary segmenter is slower and less reliable than a detector built for it, which is the standing split in the community. And when you do go promptable, remember grounding tends to return a tighter box than you want: give the mask some grow before you inpaint, or the seam lands on the outline.

CategoryπŸ†Ž AusBoss/Mask

Inputs (12)

NameTypeDefaultDescription
imageIMAGEThe picture to search.
modelMODELSAM 3: MODEL from a Load Checkpoint that loads the SAM 3 file.
clipCLIPSAM 3's text reader: CLIP from the same Load Checkpoint.
nameSTRINGthe personWhat to find, in a few plain words: "the dog", "the red jacket". Several things: put a comma between them.
severalCOMBOall of themWhen more than one thing matches: mask all of them, or only the biggest.
growINT00–512Pixels to grow the mask past the thing's edge. 0 keeps the exact outline.
softenFLOAT0.00–100Soften the mask's edge by this many pixels. 0 keeps a hard edge.
if_nothingCOMBOstop the runWhen nothing matches the name. Stop the run: the workflow stops here with a message, and nothing after this node runs. Empty mask: the run goes on with a mask of nothing.
previewoptBOOLEANtrueShow what was found on this node. Off skips writing the preview file to ComfyUI's temp folder.
thresholdoptFLOAT0.700.05–0.95How sure SAM 3 must be that something matches the name. Lower it when a small thing is missed. Raise it when it picks up something that is not the thing.
fill_holesoptBOOLEANfalseFill gaps that lie fully inside the mask, like the spots SAM 3 leaves in hair or cloth. On gives a solid shape.
free_vramoptBOOLEANfalseTakes SAM 3 out of the graphics card's memory right after the search. Turn it on in a workflow that loads a big model after this node; off keeps the next search a little faster.

Outputs (3)

NameTypeDescription
maskMASKWhite where the thing is. One mask per picture.
cut_outIMAGEThe picture with everything but the thing see-through (RGBA).
foundINTHow many things matched the name in the first picture.