h4 - Forge_Mask
Feather, expand, and invert your painted mask without the edge artifact fight
- image
- IMAGE
- MASK
H4_ForgeMask is the "make my mask not look like a hard-edged sticker" node. You've painted a mask on an image, and raw masks have brutal edges - inpaint right at a mask boundary and you get a visible cut line where the re-rendered patch meets untouched pixels. This node takes your mask and gives it the standard three treatments that fix that: blur the edge, adjust the strength, and grow or shrink the mask area. It also handles inversion, and it manages the mask's "invisible code" for you behind the scenes.
It lives in the h4_Live/Masking category ("Surgical Suite" per the README), and it's fundamentally a quality-of-life node for the manual inpainting side of things - the part where you decide where the mask goes, rather than a detector finding it. Everything it does maps directly onto the inpainting rules the community has hammered out over years: a little blur so the AI blends instead of leaving a seam, a touch of expansion so the repair reaches clean pixels past the painted boundary, and careful denoise discipline so the patch doesn't drift.
The inputs that matter
- image - the source image you masked.
- mask_blur - edge smoothness, default 4. The tooltip nails it: a little blur (4–8) helps the AI blend your changes without hard lines. Too much blur and the mask bleeds into areas you didn't paint.
- mask_strength - how opaque the mask is. 1.0 is full strength; lower it for subtle, ghost-like changes.
- mask_expansion - grows (positive) or shrinks (negative) the masked region. The tooltip's tip is the one that matters: expanding outward is great for ensuring the background matches perfectly around your cutout.
- invert_mask - flips the selection, so you change everything except the painted area. For "keep this, redo the rest" workflows.
- mask_data - the serialized code for your hand-painted mask. The tooltip says the node manages it for you. Leave it alone.
The outputs
- IMAGE - the processed image.
- MASK - the finished mask, ready for an inpainting or conditioning node.
Installing
Standard h4_Live install: ComfyUI Manager → search "h4_Live", or:
cd ComfyUI/custom_nodes
git clone https://github.com/m3rr/h4_Live
restart. No extra dependencies - pure PyTorch masking math.
Where people get burned
The classic combo mistake is cranking mask_expansion way up and mask_blur way up at once - you end up with a repair that swallows half the image. Expand a little, blur a little, and check the MASK output before you run the inpaint. Second, remember this node shapes the mask; it doesn't decide the denoise. If your inpainted region comes back as a grey box or the wrong style, that's the inpainting pass's denoise and CFG at fault, not this node - lower denoise to 0.3–0.4 and match CFG. And a pack-level note: h4_Live is a one-person project still under development, so masking UI can shift between versions; when something looks off, the "?" button's in-app help ("The Book of H4") usually explains the current behavior better than the README.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | The source image to mask. | |
| mask_blur | INT | 40–128 | The smoothness of the edges. A tiny bit of blur (4-8) helps the AI blend your changes without leaving hard lines. |
| mask_strength | FLOAT | 1.000–1 | How 'opaque' the mask is. 1.0 means full strength; lower it if you want your changes to be more subtle or ghost-like. |
| mask_expansion | INT | 0-64–64 | Grows or shrinks the mask area. Positive values expand the mask outwards, which is great for ensuring the background matches perfectly around your cutout. |
| invert_mask | BOOLEAN | false | Swaps the selection. Use this if you want to change EVERYTHING EXCEPT the area you painted. |
| mask_data | STRING | The invisible code for your hand-painted mask. I manage this for you behind the scenes! |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |
| MASK | MASK | — |