Nodes/ComfyUI-TBG-SAM3/TBG SAM3 Batch Selector
ComfyUI Node

TBG SAM3 Batch Selector

SAM3 batch segmentation for when Impact Pack gets in the way

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

TBG SAM3 Batch Selector is the sibling of the main segmentation node, built for one specific situation: you have a batch of images - frames from a video, a folder of shots, a stack of generations - and you want to segment all of them without Impact Pack in the loop. The README is blunt about why this node exists: "Impactpack does not handle batch segmentation." So this one does.

What it actually is

Same segmentation engine as TBG SAM3 Segmentation - the official SAM3 image processor, points/boxes/text/mask prompting, the instance filter, min-size filter, hole filler, and SEGS conversion - but it takes an image batch and iterates over every frame. Each frame gets its own detection pass, its own combined mask, and its own visualization; per-frame SEGS are merged into one SEGS list at the end. It's the "no Impact Pack required" output path.

The inputs that matter

The input list is nearly identical to the single-image node, so everything you learned there transfers:

  • image - now a batch, (B, H, W, C). ComfyUI treats a stack of images as one batch, so anything producing multiple images feeds it directly.
  • confidence_threshold - default 0.4; same note as the single-image node, 0.2 tends to work better with SAM3's presence scoring.
  • instances - on keeps only detections overlapping positive prompts; off returns all detections. Same trap: on with no positive prompts filters everything.
  • min_size - drops segments smaller than that square side in pixels.
  • fill_holes - solidifies masks by filling interior gaps.
  • pipeline_mode, detect_all / max_detections, crop_factor - identical behavior to the single-image node.

Optional inputs mirror the single-image node too: text_prompt for text-guided segmentation, sam3_selectors_pipe from the TBG SAM3 Selector, and mask_prompt, which here accepts either a batch mask (B, H, W) or a single (1, H, W) applied to every frame.

The outputs

  • segs - merged SEGS across all frames, still Impact Pack-compatible. So if you do want to feed a Detailer, you can.
  • visualization - the annotated image(s).
  • combined_mask - one combined mask per frame, stacked as (B, H, W).
  • batch_masks - all the per-detection masks across every frame in one tensor. This is the one output the single-image node doesn't have, and it's what you want if you're saving masks out or feeding them into per-frame processing.

Installing

Same pack-wide routine: ComfyUI Manager (search "TBG-SAM3"), or git clone https://github.com/Ltamann/ComfyUI-TBG-SAM3 into ComfyUI/custom_nodes, then pip install -r requirements.txt. It needs the loader nodes and the gated SAM3 checkpoint (request access at huggingface.co/facebook/sam3, export an HF_TOKEN) - and if the nodes crash on load, the sam3 package itself is the usual suspect; python install.py in the pack folder reinstalls it.

Where people get burned

  • Memory. Running the full SAM3 pass per frame on a big batch is real VRAM work. It's sequential per frame, so it won't blow up instantly, but a long video will churn.
  • Confusing it with the single-image node. This one deliberately skips the boxes/scores JSON outputs the single-image node has - you get SEGS, visualization, and masks. If you were logging detections per frame, that's not here.
  • Batch vs. single. Feed it a single image and it still works - batch of one. The reason to pick this over the main node is purely whether your input is a batch and whether you want the batch_masks output.

If Impact Pack is already central to your workflow, the single-image node's per-instance SEGS are the better fit. The Batch Selector is for the rest of the time - when you've got a pile of frames and just want clean masks out the other side without dragging a SEGS pipeline into it.

CategoryTBG/SAM3

Inputs (13)

NameTypeDefaultDescription
sam3_modelSAM3_MODELSAM3 model loaded from LoadSAM3Model node
imageIMAGEInput image batch to perform segmentation on (B,H,W,C)
confidence_thresholdFLOAT0.400–1Minimum confidence score to keep detections
pipeline_modeCOMBOallWhich prompts from pipeline to use
detect_allBOOLEANtrueWhen enabled, detects all objects. When disabled, uses max_detections
max_detectionsINT501–100Maximum detections when detect_all is disabled
instancesBOOLEANfalseWhen ON: keep only detections overlapping positive prompts
crop_factorFLOAT1.51–4Crop factor for SEGS. 1.0 = tight bbox
min_sizeINT1001–500Minimum segment size (square side in pixels)
fill_holesBOOLEANfalseFill holes inside masks
text_promptoptSTRINGText to guide segmentation
sam3_selectors_pipeoptSAM3_PROMPT_PIPELINEUnified pipeline containing boxes/points
mask_promptoptMASKOptional batch mask (B,H,W or 1,H,W)

Outputs (4)

NameTypeDescription
segsSEGS
visualizationIMAGE
combined_maskMASK
batch_masksMASK