Nodes/ComfyUI-SAM3/SAM3 BBox Collector 📦
ComfyUI Node

SAM3 BBox Collector 📦

Draw boxes on the image to guide SAM3

By PozzettiAndrea·Created 9 months ago·Updated 27 days ago· 557
SAM3 BBox Collector 📦
  • image
  • positive_bboxes
  • negative_bboxes
bboxes[]
neg_bboxes[]

The box counterpart to the Point Collector. Instead of clicking dots, you draw rectangles right on the image - one or more around the things you want, and negatives around regions to exclude - and it packages them as box prompts for SAM3. Boxes are the right tool when the object is a clean rectangular-ish region and pointing is fiddly: draw a box around the whole car, done, no need to place three careful clicks and hope.

It sits at the same spot in the graph as the Point Collector - a prompt source that feeds the segmentation nodes - just speaking in boxes rather than points. This is the interactive, draw-it-yourself route; if you'd rather set box coordinates numerically, that's SAM3 Create Box plus Combine Boxes.

How it works

You draw boxes on the node's image canvas; it stores them and emits two SAM3_BOXES_PROMPT outputs - positive boxes and negative boxes. It's an output node, so it renders that interactive canvas in the graph. A positive box says "the object is roughly in here, mask it," and SAM3 refines a precise mask inside that region; a negative box tells it to steer clear of an area.

The inputs and outputs that matter

  • image (IMAGE) - the picture you draw on. Required, and the canvas needs it before you can box anything.
  • bboxes / neg_bboxes - the stored box data (both default []). The interactive editor fills these as you draw; you don't normally type them.

Outputs: positive_bboxes and negative_bboxes, both SAM3_BOXES_PROMPT. Wire positive_bboxes into the box input of SAM3 Point Segmentation, or the positive_boxes input on SAM3 Text Segmentation / Video Segmentation; send negative_bboxes to the matching negative input. Note the type is already the plural SAM3_BOXES_PROMPT - this collector outputs a ready-to-use box set, no Combine Boxes needed after it.

How to install it

Comes with the pack. Manager: search SAM3, install the highest version. Manual:

cd ComfyUI/custom_nodes
git clone https://github.com/PozzettiAndrea/ComfyUI-SAM3.git
cd ComfyUI-SAM3
pip install -r requirements.txt --upgrade
python install.py

then restart. sam3.pt goes in ComfyUI/models/sam3/ for the segmentation nodes downstream. The README mentions an experimental comfy-env/pixi one-click installer.

Common issues & troubleshooting

No image on the canvas. Connect an image and run the graph once so the node has the picture to draw over.

The box grabbed the background instead of the object. A box tells SAM3 where to look, not exactly what to keep - if the box is loose around a small subject it may latch onto the wrong thing. Draw tighter, or add a positive point (via a separate Point prompt into the segmentation node) to disambiguate.

Type mismatch when wiring. positive_bboxes is a SAM3_BOXES_PROMPT. The segmentation node's box input wants exactly that, so it connects directly - but don't confuse it with the single SAM3_BOX_PROMPT that Create Box emits; those need Combine Boxes first, this collector doesn't.

Prefer exact coordinates? Use SAM3 Create Box (numeric center/size) → Combine Boxes for a repeatable, no-mouse setup. This collector is for when eyeballing the box is faster than doing arithmetic.

CategorySAM3

Inputs (3)

NameTypeDefaultDescription
imageIMAGEImage to display in interactive canvas. Click and drag to draw positive bboxes (cyan), Shift+Click/Right-click and drag to draw negative bboxes (red). Bounding boxes are automatically normalized to image dimensions.
bboxesSTRING[]
neg_bboxesSTRING[]

Outputs (2)

NameTypeDescription
positive_bboxesSAM3_BOXES_PROMPT
negative_bboxesSAM3_BOXES_PROMPT