LayerMask: Draw BBox Mask V2(Advance)
Draw BBox Mask V2 — ComfyUI Node Guide
- image
- bboxes
- mask
Every object detector in this pack - YOLO8, YOLOWorld, Florence2, whichever one you used - hands you back BBOXES: coordinates, not a mask. This node is the bridge: it takes those boxes and rasterizes them into an actual mask you can feed to inpainting or compositing. DrawBBoxMask (the V1) does that with plain rectangles; V2 adds rounded corners and anti-aliasing on top, which matters more than it sounds like if you're masking something organic - a hard rectangular edge on an inpaint boundary is a very easy tell that the region was mechanically selected rather than naturally shaped.
The mechanism: take each box in your bboxes input, optionally expand or shrink each edge independently, then draw it as a mask shape - either a sharp rectangle or, with V2's added radius setting, a rounded rectangle with smoothed edges.
Inputs that matter:
image- needs to be the same image the detector ran on; this is purely for dimension matching, not re-detection.bboxes- the detection data from whichever detector node you used upstream.grow_top,grow_bottom,grow_left,grow_right- each box edge expands or contracts independently, as a percentage of that box's height (top/bottom) or width (left/right). Positive expands outward in the named direction; negative pulls inward. This per-edge control is genuinely useful - you might want a face box grown upward to catch hair but not sideways, for instance.rounded_rect_radius(0–100, default 50) - V2's headline addition. Higher values round the corners more aggressively.anti_aliasing(0–16, default 2) - smooths the mask edge. The README's own warning is worth repeating: pushing this high noticeably slows the node down, so don't max it out by default, only when a visibly jagged edge is actually a problem.
Output: mask, ready for inpainting, compositing, or any downstream node expecting a standard MASK.
Installing it: ComfyUI Manager, search "ComfyUI Layer Style Advance," or manually git clone https://github.com/chflame163/ComfyUI_LayerStyle_Advance into custom_nodes, then install_requirements.bat (or Aki variant) / pip install -r requirements.txt, then repair_dependency.bat, restart. No model downloads here - this node is pure geometry, drawing shapes from numbers rather than running any inference - so if the pack installed cleanly at all, this node comes for free.
Where people get this wrong: the grow values are percentages of the box's own dimensions, not fixed pixel amounts, so the same grow_top value expands a small face box by a lot fewer pixels than it does a large full-body box - if your padding looks inconsistent across a batch with wildly different box sizes, that's expected behavior, not a bug, and you may want different grow settings for different detection categories rather than one universal value. And remember this node only draws what's already in bboxes - if your mask is in the wrong place, the fix is almost always upstream in whatever detector produced the boxes, not in this node's own settings.
Inputs (8)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| bboxes | BBOXES | — | |
| grow_top | FLOAT | 0.00-10–10 | — |
| grow_bottom | FLOAT | 0.00-10–10 | — |
| grow_left | FLOAT | 0.00-10–10 | — |
| grow_right | FLOAT | 0.00-10–10 | — |
| rounded_rect_radius | INT | 500–100 | — |
| anti_aliasing | INT | 20–16 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| mask | MASK | — |