BBOX Padding
Give Your Bounding Boxes Room to Breathe
- bbox
- bbox
Detectors are tight. Whether it's a YOLO model or a vision-language model returning a grounding box, the box you get wraps the object almost exactly - and that's precisely what you don't want for a detail pass or an inpaint. BBOX Padding exists to fix that in one step: inflate a box by N pixels on every side so the model has context to work with.
This isn't a cosmetic nicety. The notes on the 2026 text-grounded masking pattern warn that grounding boxes wrap the cup and not the saucer - too tight to inpaint usefully - and the standard fix is padding before you build the mask. The same logic applies to FaceDetailer-style crops: a box with zero margin gives the sampler nothing to blend against, and the paste-back seam shows. Padding is often the difference between a region that regenerates cleanly and a region that looks cut and pasted.
The mechanism is exactly what the name says. x_min and y_min each move outward by padding (floored at 0 so you can't go off-canvas), and width/height each grow by padding, so the total box gains 2×padding on each axis. The default is 16px, a reasonable starting point for 512-scale work - you'll probably want more, and the node makes it trivial to tune.
Two optional inputs, max_width and max_height (both default 0, meaning no limit), are meant to clamp the grown box to a known canvas. Read the intent, then note the catch in the actual code: the clamp truncates the box's width rather than sliding the whole box over. If the padded box pokes past max_width, the width gets chopped from the right side instead of the box shifting to fit. Push x_min past max_width entirely and the arithmetic can even produce a negative width, which no downstream node wants. Keep them at 0 unless you're genuinely clipping to a fixed canvas, and if you are, leave a few pixels loose.
Inputs: bbox, padding (16), max_width (0), max_height (0). Output: a single padded bbox, ready to feed a mask-from-bbox step, a crop, or FaceDetailer. The BBOX type is Impact Pack's standard, so any Impact Pack consumer takes it directly - no conversion needed.
Install is the same as its siblings in comfyui_met_suite: ComfyUI Manager → search comfyui_met_suite → install → restart, or
cd ComfyUI/custom_nodes
git clone https://github.com/metncelik/comfyui_met_suite
then restart. One Pillow dependency you already have; zero models; zero keys.
The recipe people actually run: detect (or ground) → pad → mask → inpaint. This node is the middle step that keeps the whole thing from looking like you cut and pasted.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| bbox | BBOX | — | |
| padding | INT | 16 | — |
| max_width | INT | 0 | — |
| max_height | INT | 0 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| bbox | BBOX | — |