ComfyUI Node

SAM3 Draw BBox

See what your boxes actually look like before SAM3 ever runs.

By SuLU-K·Created 9 months ago·Updated 7 months ago· 9
SAM3 Draw BBox
  • images
  • bboxs
  • images
stroke_width4

SAM3 (Meta's Segment Anything 3) is promptable, and its favorite prompt is a box. Which means half of building a SAM3 workflow is just getting the boxes right - from a VLM, from a YOLO pass, from the interactive editor, from whatever. Sam3DrawBBox is the "show your work" node: it takes an image and a BBOX collection and paints a red rectangle around every box, so you can actually see what you're about to segment before you burn GPU time on it.

In: images (IMAGE), bboxs (BBOX), stroke_width (INT, 1–64, default 4). Out: images - the same tensor with boxes drawn on top. There's nothing clever beyond that, and there doesn't need to be. It's a debug/visualization tool, and it's genuinely useful when your boxes come from an auto-detector you don't fully trust.

Why the format tolerance matters

The BBOX type is shared across this ecosystem (kijai's KJNodes and the easy-sam3 pack both speak it), and the ecosystem is sloppy about exactly what it hands you. This node tries to accept all of it:

  • KJ-format dicts - {startX, startY, endX, endY}, what the interactive editor in this pack emits.
  • {x, y, w, h} dicts - treated as top-left plus size.
  • Raw lists - a 4-element list is read as xyxy unless x2 <= x1, in which case the node guesses it's xywh.
  • Normalized coordinates - if everything's ≤ 1.0, it scales up to the image size.
  • JSON strings and per-batch lists - a string gets parsed, and a list with one entry per image gets applied image-by-image; otherwise one set of boxes applies to the whole batch.

That's a lot of guessing baked in, and it mostly works - which is the honest description: mostly. When boxes don't draw, it's usually because your source used a format the heuristics didn't recognize, so the node silently skipped it rather than crash.

The one knob

  • stroke_width (INT, 1–64, default 4) - the only parameter you'll touch. 4 is a good middle ground; on high-res images you may want a heavier line, on previews a thinner one. All boxes render in red; there's no color option, so if you need per-class colors this isn't your node.

Installing it

The pack-level install:

  • ComfyUI Manager → search comfyui-easy-sam3-tools → Install → restart.
  • Or:
cd ComfyUI/custom_nodes
git clone https://github.com/SuLU-K/comfyui-easy-sam3-tools

Then restart ComfyUI. No requirements.txt, no model downloads - drawing rectangles needs only Pillow, which ComfyUI already has. The node appears under Test Nodes/SAM3, the pack's honest label for its personal-utility origins.

Troubleshooting

  • Nothing draws. Either bboxs is empty/None, or your format fell through the heuristics. Check the shape of what you're feeding: if it's a list of four numbers, is it xyxy or xywh? If it's a dict, does it have the keys above? A degenerate box (zero width/height) is also dropped silently.
  • Boxes in the wrong spot. The node clamps everything to image bounds, and normalized values get multiplied up by image size. If your boxes came in already-pixel-scaled and under 1.0 in magnitude, they'll be treated as normalized - check your upstream's coordinate space.
  • Every image in a batch gets the same boxes unless your input is explicitly per-batch. That's the default, and it's usually what you want for a preview.

If your goal is just "confirm the detector found the right thing," this is the node. If you need to author boxes, you want Sam3InteractiveBBoxEditor in the same pack instead.

CategoryTest Nodes/SAM3

Inputs (3)

NameTypeDefaultDescription
imagesIMAGE
bboxsBBOX
stroke_widthINT41–64

Outputs (1)

NameTypeDescription
imagesIMAGE