Bounding Boxes to SEGS
Boxes From Anywhere, Straight Into the Detailer
- bboxes
- image
- SEGS
The most useful thing about ComfyUI's newer native BOUNDING_BOX type is that boxes now come from all sorts of places that have nothing to do with Impact Pack - SAM3 Detect with a text prompt, Run Real-Time Detection (RT-DETR), Create Bounding Boxes after some maths, a node you wrote yourself. The problem is that everything downstream of a box in Impact Pack speaks SEGS: detailers, masks, paste nodes. This node is the door between them.
What it builds
Feed it boxes, an image, and a crop factor, and each box becomes a SEG the way BBOX Detector (SEGS) would have made it. Box coordinates are clamped into the image, and the mask for each SEG is literally the box filled in - no segmentation, no cleverness. The label and score on each box become the label and confidence of its SEG, and the image supplies both the SEGS' declared size and a cropped picture for each SEG's crop region, so downstream nodes don't need a fallback image.
Boxes smaller than a pixel in either dimension get skipped silently, which is usually what you want - degenerate detections are noise - but does mean "my box disappeared" has a boring explanation.
It handles the three shapes ComfyUI passes around: a single box dict, a list of boxes, or a list of boxes wrapped for one frame. Two things it refuses outright, with a clear error message rather than a crash: boxes for more than one frame, and image batches. One frame's boxes, one image. If you're pulling boxes out of a video pipeline per frame, run this per frame - the list-batching in ComfyUI makes that natural - rather than trying to shove a per-frame structure through.
Inputs and outputs
bboxes-BOUNDING_BOX, input-only. This socket is forced to be a connection; there's no widget to type coordinates into.image- the image the boxes belong to. It gives the SEGS their dimensions and each SEG the picture of its crop region.crop_factor- FLOAT, default 3.0, 1.0 to 100. How much wider than the box each SEG's crop region is. Same meaning as everywhere else in the pack: 3 means a region three times the box's width and height, centred.- Output:
SEGS.
From here it's the normal graph: Detailer (SEGS), SEGSPreview, SEGS Filter (label), Dilate Mask (SEGS), SEGSPaste. Because the crop regions are made properly, all the crop-region hooks work too - and CropRegionMultipleDetailerHookProvider via Apply Crop Region Hook (SEGS) is genuinely useful if your boxes came from a tiled or bucket-fixed pipeline.
The honest caveat
The mask is a rectangle. Detailers paste through masks, so a rectangular mask means the refined patch is composited as a rectangle, and the seams can be visible on skin or hair. Options, in increasing order of effort: SEGSRoundCornersDetailerHookProvider to soften the corners; dilation and a blur to feather the edge; or, better, use the box as a prompt for a real segmentation step - feed it to a SAM detector so the mask follows the subject instead of the box. That's the pipeline the pack is built for, and it's why Bounding Boxes to SEGS and SEGS to Bounding Boxes exist as a pair.
Install
Both nodes are in Impact Pack, ImpactPack/Util.
cd ComfyUI/custom_nodes
git clone https://github.com/ltdrdata/ComfyUI-Impact-Pack
cd ComfyUI-Impact-Pack
pip install -r requirements.txt
Windows portable: ..\..\..\python_embeded\python.exe -m pip install -r requirements.txt. Restart ComfyUI afterwards. Manager users search ComfyUI Impact Pack - the recommended path, and it's the one that handles dependencies for you. First run generates impact-pack.ini and downloads a default SAM checkpoint into models/sams unless an empty file named skip_download_model sits in custom_nodes.
One security note that belongs in any Impact Pack install: in December 2024 a compromised Ultralytics release shipped a cryptominer, and Impact Pack was how it reached a lot of ComfyUI users. Since v8.0 the Ultralytics detector provider lives in the separate Impact Subpack and the base pack no longer drags it in. So if you only need Bounding Boxes to SEGS with boxes from native nodes, you don't need the detector pack at all - and if you do install it, keep ultralytics at a version that isn't from that window.
Troubleshooting
Error mentioning image batches or more than one frame? You fed it a batch. Split it - Image Batch to Image List and per-image processing - or drive it from a per-frame box list on a single image.
Nothing comes out and no error? Every box was sub-pixel, or your boxes are in normalised 0–1 coordinates while the node expects pixels. Native ComfyUI boxes are pixels; VLM grounding outputs vary wildly, so check before you debug the detailer.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| bboxes | BOUNDING_BOX | A box, a list of boxes, or a list of boxes for a single frame. The label and the score of a box become the label and the confidence of its SEG. | |
| image | IMAGE | The image the boxes belong to. It gives the SEGS their size, and each SEG the picture of its crop region. | |
| crop_factor | FLOAT | 3.01–100 | How much wider than its box the crop region of each SEG is. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| SEGS | SEGS | — |