Nodes/ComfyUI_LayerStyle_Advance/LayerMask: Draw BBox Mask(Advance)
ComfyUI Node Runs on cloud

LayerMask: Draw BBox Mask(Advance)

Turn detector bounding boxes into an actual paintable mask

By chflame163·Created 2 years ago·Updated 4 months ago· 696
LayerMask: Draw BBox Mask(Advance)
  • image
  • bboxes
  • mask
grow_top0.00
grow_bottom0.00
grow_left0.00
grow_right0.00

Every object detector in LayerStyle Advance - ObjectDetectorGemini, ObjectDetectorMask, the YOLO variants, Florence2's detector - outputs its findings as BBOXES data, which is coordinates, not an image you can inpaint with. DrawBBoxMask is the node that closes that gap: feed it the boxes and the original image, and it rasterizes those boxes into a real MASK you can plug straight into an inpainting pass.

It's a simple node doing one necessary job, and the one setting worth understanding well is the per-edge growth control, because that's what turns "a rectangle around the detection" into "a mask shaped the way your actual edit needs."

The inputs and outputs that matter

  • image - required, and it has to be the same image the bboxes were detected on. The README is explicit about this: box coordinates only mean anything relative to the image they came from, so if you've resized or cropped in between, the boxes will land in the wrong place.
  • bboxes - required, from any detector node in the pack (or from BBoxJoin if you've merged several).
  • grow_top, grow_bottom, grow_left, grow_right (all default 0, range −10 to 10) - expand or contract each edge of every box independently, scaled to that box's own height or width. Positive grows outward on that edge, negative pulls inward. This per-edge control is the actual reason to reach for this node instead of a generic mask-grow step afterward - you can, for instance, pad generously above a detected face (room for hair, a hat) while leaving the sides tight.

Output is a single mask.

Where this fits in a workflow

Typical chain: an ObjectDetector node finds "the face" or "the sign" and returns bboxes → DrawBBoxMask turns that into a mask, padded as needed → an inpaint node uses that mask. If you need rounded corners instead of hard rectangles, the pack also has DrawBBoxMaskV2, which adds that plus anti-aliasing on top of everything here.

Installing it

ComfyUI Manager: search "ComfyUI Layer Style Advance". Manual:

cd ComfyUI/custom_nodes
git clone https://github.com/chflame163/ComfyUI_LayerStyle_Advance.git

Run install_requirements.bat (or the manual pip/whl steps for a portable install) and restart. No model to download, no API key - this node is pure geometry once you have real bbox data to feed it.

Common issues

Mask is in the wrong place entirely. Almost always the image mismatch problem described above - you're feeding it a resized, cropped, or otherwise different image than the one the boxes were detected against. Keep the original image flowing alongside the bboxes through your graph rather than re-fetching or resizing it before this node.

Box edges look identical no matter what you set grow_* to. Remember the growth is scaled to each box's own dimensions, not a fixed pixel amount - a small detection box will grow by fewer actual pixels than a large one for the same grow_top value. If you need a fixed pixel pad regardless of box size, this isn't quite that tool; you'd want a downstream grow step instead.

Multiple boxes overlapping in unexpected ways. If you fed in boxes from BBoxJoin or a detector with bbox_select: all, the mask includes every box - overlapping regions just union together. If you only wanted one specific detection, check the upstream detector's bbox_select setting (first or by_index) rather than trying to fix it here.

Hard, blocky edges on the mask. That's expected - this node draws rectangles (or rounded rectangles in V2), it doesn't do any edge refinement. If you need soft edges for a seamless composite, feed the output through a blur or one of the pack's detail-refinement passes afterward.

Category😺dzNodes/LayerMask

Inputs (6)

NameTypeDefaultDescription
imageIMAGE
bboxesBBOXES
grow_topFLOAT0.00-10–10
grow_bottomFLOAT0.00-10–10
grow_leftFLOAT0.00-10–10
grow_rightFLOAT0.00-10–10

Outputs (1)

NameTypeDescription
maskMASK