SAX SAM3 Multi Segmenter
Describe what to mask — SAX SAM3 Multi Segmenter
- sam3_model
- image
- mask
- MASK
- PREVIEW_IMAGE
SAX SAM3 Multi Segmenter is the "describe the mask instead of drawing it" node. It runs Meta's SAM3 - the open-vocabulary Segment Anything that understands text phrases, roughly 270,000 concepts per the KB - against your image, and lets you stack multiple positive and negative text entries to compose a mask. Want the hair but not the skin under it? That's a positive prompt "hair" minus a negative prompt "skin," and the node does the set arithmetic for you. No selection tools, no manual mask painting.
This is the case the KB's masking doc flags as promptable segmentation's home turf: one-off targets with no trained detector, or regions too specific for a face YOLO. For "faces in general," a YOLO pass is still faster and doesn't need Triton - more on that below.
How it works
You manage a list of segment entries in the node UI (the segments_json field is JS-managed; don't hand-edit it). Each entry has a prompt ("hair", "person", "ears"), a mode - positive (include) or negative (exclude) - and three tuning knobs:
threshold(default 0.2) - detection confidence cutoff. Lower is broader, more generous capture.presence_weight(default 0.5) - how much the model's presence score counts; 0.0 favors range, 1.0 favors precision.mask_grow- expand the mask (positive entries) or shrink it (negative entries) in pixels.
At runtime, each enabled entry runs SAM3 on the image. All positive masks are OR'd together, all negative masks are OR'd, and the final mask is clamp(positive − negative, 0, 1). An optional mask input ANDs with the result as a region-of-interest limit. The docs' advice: stack more conditions for more accuracy - "hair" minus "skin" minus "ears" gives you hair-only, and the more you layer, the cleaner the cut.
Two outputs: MASK (feed it to a SAX Detailer, Mask Adjust, or noise node) and PREVIEW_IMAGE, a heatmap visualizing the match scores - the fastest feedback loop you'll get for tuning thresholds.
What it needs
This is the one SAX_Bridge node with a real install requirement. The model comes from the SAX SAM3 Loader (sam3_model input - a CSAM3_MODEL), which expects a SAM3 checkpoint in your sam3 folder, and SAM3 itself must be installed:
pip install git+https://github.com/facebookresearch/sam3.git
On Windows, install triton first (PyTorch ≥ 2.7 + CUDA ≥ 12.8) or triton-windows on older setups - SAM3 depends on it and it was historically Linux-only. The pack will show you the underlying ImportError if something's missing, so read the console when the node refuses to load.
The pack itself installs the usual way:
cd ComfyUI/custom_nodes
git clone https://github.com/so16tm/SAX_Bridge
Gotchas
First run loads the SAM3 model and takes a real moment - that's normal, not a hang. The heatmap preview isn't just decoration; it's how you'll actually tune threshold and presence_weight, so keep it wired to a preview while you iterate. And remember SAM3 is a heavyweight dependency: if all you need is "find the face," a YOLO-based FaceDetailer is faster and lighter. Reach for this node when the thing you want to isolate has no detector that knows it.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| sam3_model | CSAM3_MODEL | Connect from SAX SAM3 Loader. | |
| image | IMAGE | — | |
| segments_json | STRING | [{"on": true, "mode": "positive", "prompt": "person", "threshold": 0.2, "presence_weight": 0.5, "mask_grow": 0}] | セグメントエントリーデータ(JSON)。JS が管理するため直接編集不要。 |
| maskopt | MASK | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| MASK | MASK | — |
| PREVIEW_IMAGE | IMAGE | — |