Nodes/ComfyUI-TBG-SAM3/TBG SAM3 Segmentation
ComfyUI Node

TBG SAM3 Segmentation

SAM3 segmentation that hands you Impact Pack-ready SEGS

By Ltamann·Created 10 months ago·Updated about a month ago· 169
TBG SAM3 Segmentation
  • sam3_model
  • image
  • sam3_selectors_pipe
  • mask_prompt
  • masks
  • visualization
  • boxes
  • scores
  • segs
  • combined_mask
  • combined_segs
confidence_threshold0.40
pipeline_modeall
detect_alltrue
max_detections50
instancesfalse
crop_factor1.5
min_size100
fill_holesfalse
text_prompt

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, or disabled. 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_segs logic 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_threshold to 0.2 and check you've got a prompt wired in at all.
  • Everything filtered out → either min_size is too aggressive for your image, or instances is 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.

CategoryTBG/SAM3

Inputs (13)

NameTypeDefaultDescription
sam3_modelSAM3_MODELSAM3 model loaded from LoadSAM3Model node
imageIMAGEInput image to perform segmentation on
confidence_thresholdFLOAT0.400–1Minimum confidence score to keep detections. Lower threshold (0.2) works better with SAM3's presence scoring
pipeline_modeCOMBOallWhich prompts from pipeline to use.
detect_allBOOLEANtrueWhen enabled, detects all objects. When disabled, uses max_detections value.
max_detectionsINT501–100Maximum detections when detect_all is disabled.
instancesBOOLEANfalseWhen ON: keep only detections whose boxes overlap a positive box or contain a positive point. When OFF: return all SAM3 detections including instances.
crop_factorFLOAT1.51–4Crop factor used when building combined SEGS (Impact Pack style). 1.0 = tight bbox.
min_sizeINT1001–500Minimum segment size in pixels as a square side. 1=1x1, 200=200x200; smaller masks are discarded.
fill_holesBOOLEANfalseWhen enabled, fills holes inside each mask (solid segments).
text_promptoptSTRINGText to guide segmentation (optional).
sam3_selectors_pipeoptSAM3_PROMPT_PIPELINEUnified pipeline containing boxes/points).
mask_promptoptMASKOptional mask to refine the segmentation.

Outputs (7)

NameTypeDescription
masksMASK
visualizationIMAGE
boxesSTRING
scoresSTRING
segsSEGS
combined_maskMASK
combined_segsSEGS