SEGS to BBox
SEGS to BBox — the adapter that lets Impact Pack detections drive SAM2
- segs
- BBOX
ComfyUI has two very popular ways to talk about "stuff I found in an image." One is Impact Pack's SEGS format - rich segmentation objects with crops, masks, and labels that have powered FaceDetailer-style workflows forever. The other is the BBOX format that SAM2-style inference expects: plain lists of [x1, y1, x2, y2] boxes. These two worlds don't talk to each other natively. SEGStoBBox is the translator.
If you live in Impact Pack territory - and a lot of ComfyUI's detection ecosystem does - but you want to hand detections off to a SAM2 node, this is the bridge. Impact Pack detects, you convert, SAM2 segments. The alternative is rebuilding detection from scratch in a second system, which is the kind of duplicated work nobody enjoys.
How it works
SEGS data is structured as a two-element thing: [batch_info, list_of_SEG_objects]. Each SEG object carries a .bbox attribute, which is the (x1, y1, x2, y2) tuple describing where that detection sits in the image. The node walks the list, pulls each .bbox, and wraps them into the batch-of-boxes format SAM2 expects - [ [ [x1,y1,x2,y2], ... ] ].
It's a thin adapter, which is exactly what you want from a glue node. If the SEGS input is empty or malformed it returns an empty box list rather than crashing, which is friendly behavior in a pipeline that sometimes has nothing to detect.
Inputs and outputs
segs(SEGS) - the output of any Impact Pack detection node (FaceDetector, BBOXDetector, SAMDetector, etc.). You need the ComfyUI Impact Pack installed to even produce this type.- Output
bboxes(BBOX) - the converted boxes in SAM2-friendly shape.
That BBOX output plugs straight into AnotherSAM2Inference's bboxes input, or into AnotherBBoxToPoints if you'd rather work from center points. The two packs compose without fuss.
Installing it
Two things to install here, and only one is this pack:
cd ComfyUI/custom_nodes
git clone https://github.com/marcoc2/ComfyUI-AnotherUtils.git
Restart ComfyUI. Install AnotherUtils via ComfyUI Manager (search "AnotherUtils"), and make sure ComfyUI Impact Pack is installed too - without it, there's no SEGS input to give this node. Both install cleanly via Manager.
Gotchas
The main thing to internalize: SEGS carries a lot more than boxes. Crops, masks, labels, confidence - all of it gets discarded here, because BBOX is a lossy format. If you only need the boxes, no problem. If you were hoping to keep the mask data flowing through, this node isn't that - look at the pack's other adapters or keep the SEGS path for the mask work.
Also, SAM2 works in full-image coordinates. Impact Pack SEGS boxes are also image coordinates, so that lines up - but if you ever find masks coming out shifted, check whether a crop upstream changed the coordinate space. Coordinate-space mismatches are the number one silent bug in detect-then-segment chains, and they're not this node's fault but they'll look like they are.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| segs | SEGS | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| BBOX | BBOX | — |