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

Mask by Touch πŸ†Ž

Click the jacket, not the whole person

By ausbossΒ·Created 3 months agoΒ·Updated about 16 hours agoΒ· 107
Mask by Touch πŸ†Ž
  • image
  • model
  • clip
  • mask
  • cut_out
  • names
β—„touchesβ–Ί
β—„grow0β–Ί
β—„soften0.0β–Ί
β—„smooth0β–Ί
β—„fill_holestrueβ–Ί
β—„if_nothingstop the runβ–Ί
β—„free_vramfalseβ–Ί
β—„invertfalseβ–Ί
β—„askβ–Ί
β—„fine_edgesoffβ–Ί

ComfyUI's built-in MaskEditor is the thing everyone uses and nobody enjoys: right-click, open an editor, paint with a brush, save, hope. Mask by Touch throws that away. The picture is on the node. Move the pointer over it and whatever a click would select lights up in teal, with the name beside your cursor. Click the jacket and you get the jacket - not the person wearing it, which is the failure a brush gives you on a fur collar.

How it works

Under the hood it's the same engine as its sibling, ComfyUI's own SAM 3, so model and clip come from a Load Checkpoint holding the SAM 3 file, and the pack wants ComfyUI 0.20 or newer. The difference is the prompt: instead of a phrase you give it clicks.

touches is the string that carries your picks, and you never type into it - the node writes it when you click, and Clear empties it. A click resolves to a whole object, and when one point could mean several things you get the picker with arrows - β€Ή jacket Β· 1 of 3 β€Ί - so you can swap to the other thing under that pixel instead of accepting SAM 3's first guess. Stroke across both shoes and you take both. Pick | Draw switches to a plain brush for areas you want to paint yourself; + and βˆ’ add or remove, Undo takes back a pick, and each pick lands as a chip you can delete or open.

Two one-click shortcuts save most of the effort. Subject takes the picture's main subject, Background everything else. Fine edges is the mode for hair and fur: instead of living with SAM 3's outline, the edge is taken from ComfyUI's own background-removal node and the BiRefNet model (birefnet.safetensors, ComfyUI 0.21 or newer) - and the cut-out comes back without the old background's colour bleeding into the wisps. That's exactly the case where generic cutouts look like scissors work.

The mask-shaping inputs are the ones you'd expect, with sensible defaults: grow (βˆ’128 to 256 shrinks the selection when negative, which matters for a mask that's bleeding onto the background), soften, smooth, fill_holes (on by default - it closes pinholes but leaves a mug's handle open), and invert for background-only work. if_nothing defaults to stop the run, so an unpicked node fails loudly instead of sending an empty mask into your sampler. You get three outputs: mask, cut_out (RGBA), and names - the picks by name as text, which is handy for captions or filenames.

Because it's an output node, the node's own picture can run it alone, and picks are cached per picture, so re-running to tweak grow doesn't re-segment from scratch. That's the difference between this being a toy and being usable: click, adjust, re-run, see the mask.

Install

Through ComfyUI Manager, search AusBoss; or:

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

Restart, then find it under πŸ†Ž AusBoss/Mask. No pip extras for this one. One thing worth saying plainly, since it's the standard complaint about SAM 3 nodes: that Triton/Windows headache is a third-party pack problem (the RMBG-style all-in-one masking bundles). This node leans on ComfyUI's own SAM 3 and background-removal nodes instead, so there's nothing extra to compile.

Where people get burned

Subject and Fine edges need a model you may not have. They run on ComfyUI's own background-removal node with BiRefNet, and they need both the model file in the right folder and ComfyUI 0.21 or newer. Without either you get a message naming the file, not a mask. Plain clicking doesn't touch BiRefNet at all, so if you're on 0.20 the core feature still works.

Clicking the background and getting nothing. The mask is exactly what's lit. If nothing lights up, nothing was segmented - press Subject, or use Draw and mask it yourself. Don't assume the run will sort it out; with the default if_nothing it stops and tells you.

An empty mask reaching your sampler, once. If you set if_nothing to empty mask while experimenting, remember that's a real mask of nothing - your inpainter will happily repaint the whole frame with it.

Hair still looking cut out. SAM 3's outline includes the frizz, but it also carries the old background's colour. Turn Fine edges on for that case specifically, and give grow a small negative value if the subject is now losing a halo of its own fringe.

CategoryπŸ†Ž AusBoss/Mask

Inputs (13)

NameTypeDefaultDescription
imageIMAGEThe picture to pick from.
modelMODELSAM 3: MODEL from a Load Checkpoint that loads the SAM 3 file.
clipCLIPSAM 3's text reader: CLIP from the same Load Checkpoint.
touchesSTRINGWhat you picked on the node's picture. The node writes this itself when you click or paint; Clear on the node empties it.
growINT0-128–256Grow the picked area by this many pixels. Below zero shrinks it. 0 keeps the exact outline.
softenFLOAT0.00–100Soften the mask's edge by this many pixels. 0 keeps a hard edge.
smoothINT00–64Round off a ragged outline by this many pixels. 0 leaves the outline as found.
fill_holesBOOLEANtrueCloses pinholes inside the picked area. Larger openings stay open, like a mug's handle.
if_nothingCOMBOstop the runWhen nothing is picked. 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.
free_vramoptBOOLEANfalseTakes SAM 3 out of the graphics card's memory when the workflow has run this node. Turn it on in a workflow that loads a big model after this node.
invertoptBOOLEANfalseTurns the mask round: white everywhere except what you picked. With nothing picked the mask stays empty.
askoptSTRINGUsed by the node's own picture for a single run. Leave it empty: it is never saved with the workflow.
fine_edgesoptCOMBOoffHair and fur, strand by strand: where what you picked ends at the outline of the picture's main subject, that outline is taken from ComfyUI's background-removal model. The cut-out also loses the colour of the old background. Off keeps the edge as found. The ? page says where to get the model file.

Outputs (3)

NameTypeDescription
maskMASKWhite where the picked area is. One mask per picture.
cut_outIMAGEThe picture with everything but the picked area see-through (RGBA).
namesSTRINGThe names of the things you picked, in the order you picked them, like: jacket, hat. Empty when nothing you picked has a name.