ComfyUI Node

Prepare BBoxes for SAM2

The adapter node that keeps SAM2 from choking on your bounding boxes

By TTPlanetPig·Created about a year ago·Updated 9 months ago· 149
Prepare BBoxes for SAM2
  • bboxes
  • sam2_bboxes

Prepare BBoxes for SAM2 is the pack's plumber. One input, one output, no AI involved, and it exists for a single reason: the boxes that QwenVLDetection hands you aren't in the shape SAM2 nodes expect, and this node does the conversion.

When the detection node returns a list of [x1, y1, x2, y2] boxes, SAM2 node packs want a list of lists - a batch, even if it's a batch of one. This node takes your bboxes, wraps them in that extra layer, and emits sam2_bboxes of type BBOXES. Feed it something that's already batched and it passes it through untouched. That's the entire mechanism - the node is a few lines of reshaping. If something in this chain is failing, it isn't here; it's upstream (a model that never finished loading) or downstream (a SAM2 node missing its own SAM2 checkpoint).

Why does the adapter matter at all? Because the VLM detector and the segmentation nodes speak different dialects. kijai's ComfyUI-segment-anything-2 expects the BBOXES batch format, and so do compatible nodes like LayerStyle's sam_2_ultra.py - the README names both. Skip this handshake and you'll get a red connection error that reads like a personality clash between two packs rather than a fixable shape mismatch. The pack's example workflow runs LayerStyle's SAM2UltraV2 right after this node, so the intended chain is:

QwenVLDetectionBBoxesToSAM2 → SAM2 segmentation → mask

The one input is bboxes (BBOX, straight off the detection node's bboxes output), and the one output is sam2_bboxes (BBOXES), which feeds into a SAM2 node's bbox input. No widgets, no options, nothing to misconfigure - which is rare and refreshing in a ComfyUI custom-node world full of 40-knob utilities.

Installation is the same as the rest of the pack: ComfyUI Manager, search "ComfyUI Qwen2.5-VL Object Detection Node", install, restart. Remember this node only converts boxes - you still need the SAM2 side installed separately (kijai's ComfyUI-segment-anything-2 or LayerStyle) plus a SAM2 model checkpoint in models/sam2. This node itself adds no heavy dependencies; it's just the handshake between a vision model that sees and a segmentation model that cuts.

CategoryQwen2.5-VL

Inputs (1)

NameTypeDefaultDescription
bboxesBBOX

Outputs (1)

NameTypeDescription
sam2_bboxesBBOXES