Nodes/ComfyUI-SAM3/SAM3 Point Segmentation
ComfyUI Node

SAM3 Point Segmentation

Point-and-box masking when text isn't precise enough

By PozzettiAndrea·Created 9 months ago·Updated 27 days ago· 557
SAM3 Point Segmentation
  • sam3_model
  • image
  • positive_points
  • negative_points
  • box
  • mask
  • mask_logits
  • visualization
  • boxes
  • scores
refinement_iterations0
use_multimasktrue
output_best_masktrue
offload_modelfalse

Displayed as "SAM3 Point Segmentation," this is the node you reach for when a text prompt can't nail the exact thing you want. Text segmentation is great at "the dog," but useless at "that specific fold of fabric" or "just the left eye." Here you point at what you want - a foreground click or two, maybe a negative click to say not that - or draw a box around it, and SAM3 grows a precise mask from those hints. It's the classic interactive SAM workflow, the reason people fell for Segment Anything in the first place.

Where it fits: this is targeted selection feeding something else. You get a clean MASK, then that mask goes into inpainting, regional prompting, a composite, or an Impact Pack refinement chain. It's not a background remover - for plain subject-vs-background, BiRefNet is less fuss. It's for when you need surgical control over which pixels.

How it works

You feed it prompts - points and/or a box - and SAM3 predicts the mask that best explains them. Positive points say "include this region," negative points say "exclude this," and a box constrains the search to a rough area. The interesting knob is use_multimask: SAM models can return several candidate masks at different scales (the whole person, just the torso, just the shirt) and let you keep the best-scoring one. Turn it on when a single click is ambiguous about how much to grab.

The inputs and outputs that matter

Required are just sam3_model (from LoadSAM3Model) and image. Everything else is optional, and you supply the prompts through the pack's other nodes:

  • positive_points / negative_points (SAM3_POINTS_PROMPT) - include/exclude clicks, built by SAM3 Point Collector or Combine Points.
  • box (SAM3_BOXES_PROMPT) - a bounding box from Create Box / BBox Collector to focus the mask.
  • use_multimask (default on) - let SAM3 propose multiple candidate masks so it can pick the best fit.
  • output_best_mask (default on) - return the single top-scoring mask rather than the stack.
  • refinement_iterations (default 0, up to 10) - extra passes to tighten the mask edge; bump it a little if boundaries look rough.
  • offload_model (default off) - free VRAM after the run.

Outputs: mask (MASK) is the one you'll use. mask_logits (MASK) is the raw pre-threshold mask for advanced blending. visualization (IMAGE) is a preview overlay. boxes and scores (STRING) are the JSON box and confidence data.

How to install it

Ships with the pack. Manager: search SAM3, install the top version. Manual:

cd ComfyUI/custom_nodes
git clone https://github.com/PozzettiAndrea/ComfyUI-SAM3.git
cd ComfyUI-SAM3
pip install -r requirements.txt --upgrade
python install.py

restart, and make sure sam3.pt is in ComfyUI/models/sam3/ (the install.py step handles the download). The README notes an experimental comfy-env/pixi one-click path you may see kick in.

Common issues & troubleshooting

The mask grabs way more or less than you meant. That's the multimask ambiguity - one point can mean "the shirt" or "the whole person." Add a second positive point inside the object and a negative point on what you don't want, or keep use_multimask on with output_best_mask so SAM3 picks the sensible candidate.

Edges look ragged. Nudge refinement_iterations up a couple of steps. It's cheap and cleans boundaries without you re-clicking.

Nothing connects - where do the points come from? This node doesn't collect clicks itself. Feed it from SAM3 Point Collector (interactive), or build prompts numerically with SAM3 Create Point → Combine Points and Create Box. The box input wants the SAM3_BOXES_PROMPT type, so use BBox Collector or Combine Boxes, not a lone Create Box.

CategorySAM3

Inputs (9)

NameTypeDefaultDescription
sam3_modelSAM3_MODELSAM3 model loaded from LoadSAM3Model node
imageIMAGEInput image to perform segmentation on
positive_pointsoptSAM3_POINTS_PROMPTForeground points - segment objects at these locations. Connect from SAM3CombinePoints or SAM3PointCollector.
negative_pointsoptSAM3_POINTS_PROMPTBackground points - exclude these areas from segmentation. Connect from SAM3CombinePoints or SAM3PointCollector.
boxoptSAM3_BOXES_PROMPTBox prompt to constrain segmentation region. Only first box is used. Connect from SAM3CombineBoxes.
refinement_iterationsoptINT00–10Number of refinement passes. Each pass feeds the mask back for cleaner edges.
use_multimaskoptBOOLEANtrueIf True, generates 3 mask candidates at different granularities (subpart/part/whole). Better for ambiguous single clicks. If False, generates single mask directly - faster, good for multiple points.
output_best_maskoptBOOLEANtrueIf True, automatically selects the highest-scoring mask. If False, outputs all mask candidates (3 if use_multimask=True) so you can choose.
offload_modeloptBOOLEANfalseMove model to CPU after segmentation to free VRAM (slower next run)

Outputs (5)

NameTypeDescription
maskMASK
mask_logitsMASK
visualizationIMAGE
boxesSTRING
scoresSTRING