TBG SAM3 Segmentation
SAM3 segmentation that hands you Impact Pack-ready SEGS
- sam3_model
- image
- sam3_selectors_pipe
- mask_prompt
- masks
- visualization
- boxes
- scores
- segs
- combined_mask
- combined_segs
This is the node the pack exists for. TBG SAM3 Segmentation runs Meta's Segment Anything Model 3 on a single image and hands you back masks, boxes, scores, a visualization, and SEGS that plug straight into Impact Pack detailers or the TBG-ETUR tile upscaler. The headline feature isn't that it segments - it's that the output speaks the language the rest of ComfyUI's detect-crop-refine machinery already speaks.
What it actually is
SAM3 is a "prompt everything" model: you can drive it with text, points, boxes, masks, or any combination. This node wires all of that to SAM3's official image processor, then adds the cleanup that makes the results actually useful - a min-size filter, a hole filler, and an instance toggle so "detect every instance of a thing" and "just give me the thing I pointed at" don't fight each other. The author frames the whole pack as "SAM3 with the rough edges filed off", and the segmentation node is where that framing earns its keep.
The inputs that matter
Most of the required inputs are fine at their defaults. The ones worth touching:
- confidence_threshold - default 0.4, but the tooltip is honest: "lower threshold (0.2) works better with SAM3's presence scoring." If you get zero or sparse detections, this is the first knob.
- instances - the toggle that decides what "detect" means. Off returns all SAM3 detections including instances. On keeps only detections whose boxes overlap a positive box or contain a positive point. The trap: turn it on with no positive prompts in the pipeline and you'll filter everything out.
- min_size - discards segments smaller than a square of that side in pixels (default 100 = 100×100). Raises it when SAM3 floods you with specks, lowers it when real objects vanish.
- fill_holes - fills gaps inside masks so segments come out solid. Nice-to-have; it's a flood-fill cleanup pass, not magic.
- pipeline_mode -
all,boxes_only,points_only,positive_only,negative_only, ordisabled. Controls which prompts from the TBG SAM3 Selector pipeline reach the model. - detect_all / max_detections - detect everything, or cap the count at
max_detections.
Optional inputs: text_prompt for semantic text segmentation (e.g. "person in red"), sam3_selectors_pipe from the Selector node, and mask_prompt to refine with an existing mask.
The outputs
- masks - per-detection masks.
- visualization - the image with masks, boxes and scores drawn over it.
- boxes and scores - JSON strings, handy for logging.
- segs - per-instance SEGS, built one SEG per detection. This is the Impact Pack / TBG-ETUR hook: it goes straight into a Detailer or the ETUR upscaler's SEGS input.
- combined_mask - union of all instance masks.
- combined_segs - one SEGS built from that combined mask via the same
mask_to_segslogic Impact Pack uses, with the crop_factor input (1.5 default, 1.0 = tight bounding box) controlling how much padding the crop regions get.
Installing
Same pack-wide story: ComfyUI Manager (search "TBG-SAM3"), or git clone https://github.com/Ltamann/ComfyUI-TBG-SAM3 into ComfyUI/custom_nodes and pip install -r requirements.txt. Before this node does anything you also need the gated SAM3 checkpoint (request access at huggingface.co/facebook/sam3) and an HF_TOKEN exported, plus the sam3 package itself - if nodes load but crash, run python install.py in the pack folder.
Where people get burned
- No detections → lower
confidence_thresholdto 0.2 and check you've got a prompt wired in at all. - Everything filtered out → either
min_sizeis too aggressive for your image, orinstancesis on with no positive prompts. - Installing the same-segment-from-scratch loop. The real payoff is chaining: Selector → Segmentation → SEGS → Impact Pack FaceDetailer or Detailer, so the crop-resample-paste loop runs over your SAM3 segments automatically. Pointing the SEGS output at a raw image node instead is leaving the whole point on the table.
It's a heavier node than the one-click SAM2 masks you might have used before - more inputs, more cleanup logic, a gated model to fetch. The payoff is that the segments come out clean and end up exactly where ComfyUI's detailing ecosystem expects them.
Inputs (13)
| Name | Type | Default | Description |
|---|---|---|---|
| sam3_model | SAM3_MODEL | SAM3 model loaded from LoadSAM3Model node | |
| image | IMAGE | Input image to perform segmentation on | |
| confidence_threshold | FLOAT | 0.400–1 | Minimum confidence score to keep detections. Lower threshold (0.2) works better with SAM3's presence scoring |
| pipeline_mode | COMBO | all | Which prompts from pipeline to use. |
| detect_all | BOOLEAN | true | When enabled, detects all objects. When disabled, uses max_detections value. |
| max_detections | INT | 501–100 | Maximum detections when detect_all is disabled. |
| instances | BOOLEAN | false | When ON: keep only detections whose boxes overlap a positive box or contain a positive point. When OFF: return all SAM3 detections including instances. |
| crop_factor | FLOAT | 1.51–4 | Crop factor used when building combined SEGS (Impact Pack style). 1.0 = tight bbox. |
| min_size | INT | 1001–500 | Minimum segment size in pixels as a square side. 1=1x1, 200=200x200; smaller masks are discarded. |
| fill_holes | BOOLEAN | false | When enabled, fills holes inside each mask (solid segments). |
| text_promptopt | STRING | Text to guide segmentation (optional). | |
| sam3_selectors_pipeopt | SAM3_PROMPT_PIPELINE | Unified pipeline containing boxes/points). | |
| mask_promptopt | MASK | Optional mask to refine the segmentation. |
Outputs (7)
| Name | Type | Description |
|---|---|---|
| masks | MASK | — |
| visualization | IMAGE | — |
| boxes | STRING | — |
| scores | STRING | — |
| segs | SEGS | — |
| combined_mask | MASK | — |
| combined_segs | SEGS | — |