TBG SAM3 Batch Selector
SAM3 batch segmentation for when Impact Pack gets in the way
- sam3_model
- image
- sam3_selectors_pipe
- mask_prompt
- segs
- visualization
- combined_mask
- batch_masks
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/scoresJSON 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_masksoutput.
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.
Inputs (13)
| Name | Type | Default | Description |
|---|---|---|---|
| sam3_model | SAM3_MODEL | SAM3 model loaded from LoadSAM3Model node | |
| image | IMAGE | Input image batch to perform segmentation on (B,H,W,C) | |
| confidence_threshold | FLOAT | 0.400–1 | Minimum confidence score to keep detections |
| pipeline_mode | COMBO | all | Which prompts from pipeline to use |
| detect_all | BOOLEAN | true | When enabled, detects all objects. When disabled, uses max_detections |
| max_detections | INT | 501–100 | Maximum detections when detect_all is disabled |
| instances | BOOLEAN | false | When ON: keep only detections overlapping positive prompts |
| crop_factor | FLOAT | 1.51–4 | Crop factor for SEGS. 1.0 = tight bbox |
| min_size | INT | 1001–500 | Minimum segment size (square side in pixels) |
| fill_holes | BOOLEAN | false | Fill holes inside masks |
| text_promptopt | STRING | Text to guide segmentation | |
| sam3_selectors_pipeopt | SAM3_PROMPT_PIPELINE | Unified pipeline containing boxes/points | |
| mask_promptopt | MASK | Optional batch mask (B,H,W or 1,H,W) |
Outputs (4)
| Name | Type | Description |
|---|---|---|
| segs | SEGS | — |
| visualization | IMAGE | — |
| combined_mask | MASK | — |
| batch_masks | MASK | — |