ComfyUI Node

MaskByBboxes

Turn detection boxes into a paintable mask

By lldacing·Created 3 years ago·Updated 8 months ago· 96
MaskByBboxes
  • image
  • bboxes
  • mask

Detect, box, mask, inpaint - that's the standard modern pattern for fixing one region of an image without touching the rest of it, and MaskByBboxes is the step that turns "here are some boxes" into "here's a mask you can actually feed a sampler." Give it an image and a list of bounding boxes and it paints white rectangles over those regions on a canvas the size of the image; everything else stays black.

How it works

The coordinate format is fixed, and the pack's own description is explicit about it: bboxes here means (x, y, w, h) - top-left corner plus width and height - not the (x1, y1, x2, y2) corner-to-corner format some detectors return. If your boxes came from something using the corner format, run them through this pack's BboxToBbox (single box) or BboxesToBboxes (a whole list) first. Wiring corner-format boxes straight into this node will paint the wrong region without any error telling you why.

The inputs and outputs that matter

  • image (IMAGE) - sets the canvas size for the output mask.
  • bboxes (BBOX) - the boxes to paint, in (x, y, w, h) format.
  • One output: mask (MASK).

Where the boxes actually come from is up to your graph - an object or face detector elsewhere, or this pack's own SelectBbox pulling one entry out of a bigger detected list. This node's job is strictly the last mile: boxes in, a compositable mask out, ready to hand to an inpainting sampler or a detect-crop-refine pass in the style Impact Pack's Detailer nodes use.

How to install it

Via ComfyUI Manager: search comfyui-easyapi-nodes, install, restart. Manually:

cd ComfyUI/custom_nodes
git clone https://github.com/lldacing/comfyui-easyapi-nodes.git
cd comfyui-easyapi-nodes
pip install -r requirements.txt

Restart ComfyUI. No models needed for this node specifically.

Common issues & troubleshooting

A mask that paints in the wrong spot, or absurdly large, is almost always a coordinate-format mismatch. Since the format isn't auto-detected, that's the first thing to check before assuming the detector or the image is wrong - confirm you're actually holding (x, y, w, h) and not corner coordinates.

Boxes that fall partly or fully outside the image bounds are the other common cause of a mask that looks wrong. Clamp or sanity-check whatever produced your bounding boxes before they reach this node, especially if they came from a detector running at a different resolution than the image you're passing in here.

CategoryEasyApi/Bbox

Inputs (2)

NameTypeDefaultDescription
imageIMAGE
bboxesBBOX

Outputs (1)

NameTypeDescription
maskMASK