Imgutils Bbox Mask
Turn Detected Regions Into Inpainting Masks, Without Drawing Them
- image
- masks
Hand-painting an inpainting mask over every bad region in a batch is exactly the kind of work automation exists to kill. Imgutils Bbox Mask does the automated half: it takes a bounding-box JSON string from Imgutils Detect or OCR, plus the source image (for dimensions), and emits one binary MASK per box - ready to feed an inpainting pipeline without you ever touching a brush.
Why you'd reach for it
The KB's inpainting doc frames the mask as what the automation loop uniquely gives you: bit-identical unmasked pixels, only-masked detail at native resolution, and the 0–1 denoise dial. Pair that with a detector and you get the "find the broken region and fix it unattended" pattern - detect the faces, mask each one, regenerate. This node is the mask factory for that loop. Typical chain: Imgutils Detect (faces) → Imgutils Bbox Mask → SetLatentNoiseMask or a masked inpaint setup → re-render.
How it works
Simple and honest: for each bbox it allocates a zero-filled float array the size of the source image and fills 1.0 inside the box, returning each as a MASK tensor. The image input is used only for its dimensions - the mask is full-canvas-sized per box, which is exactly what inpainting nodes expect. Output is a list (masks), one per detection.
The interface
image- used for dimensions, not content.bboxes(STRING) - the JSON array from Detect or OCR ({bbox: [x1,y1,x2,y2], ...}per box).- Output:
masks(MASK list).
Honest take
The limitation is right in the name: bbox masks are rectangles, and rectangles show their edges. Inpaint on a hard box mask and you can see the boundary, especially at low denoise. The fix is to soften the mask before it hits the sampler - blur it, or (better) combine it with a segmentation-derived mask so it hugs the subject. If you're after seamless detailing of a face, the Impact Pack's SEGS path with a segmentation detector is the smoother tool; this is the quick-and-dirty route that's still plenty good for "fix this region without hand-masking."
Also note the empty case: no valid boxes and it returns a single all-zero mask rather than failing. Same robustness-as-surprise behavior as the pack's other bbox utilities.
Install
cd ComfyUI/custom_nodes
git clone https://github.com/xiaden/comfyui-imgutils.git
cd comfyui-imgutils
pip install -r requirements.txt
Or via ComfyUI Manager (search "imgutils"). Needs ComfyUI >= 0.25.0 and Python >= 3.10; dependency is dghs-imgutils[gpu]. No model downloads for this node - the mask is numpy math.
Troubleshooting
If your inpaint output shows hard rectangular seams, that's the expected bbox-mask artifact - soften with a blur node before SetLatentNoiseMask. If you get an all-zero mask when you expected coverage, check that bboxes is the Detect node's json output; the detections string won't parse the same way. And remember the mask is sized to the source image: if you've already resized the image elsewhere, size-mismatch errors downstream are usually a wiring order problem.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | Source image (used for dimensions). | |
| bboxes | STRING | JSON bbox array from Detect or OCR node. Each entry: {bbox: [x1,y1,x2,y2], ...}. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| masks | MASK | — |