Nodes/ComfyUI-DaSiWa-Nodes/DaSiWa Inpaint Composite
ComfyUI Node

DaSiWa Inpaint Composite

DaSiWa Inpaint Composite

By darksidewalker·Created 5 months ago·Updated 4 days ago· 109
DaSiWa Inpaint Composite
  • destination
  • source
  • mask
  • image
x0
y0
w512
h512
correction_methodMatch Channels

The oldest rule in inpainting: composite your result back, or the whole image goes through the VAE twice and slowly turns to garbage. There's a whole r/StableDiffusion thread (+356) complaining that post-Flux-Fill workflows skipped this step and turned images to trash in three to five passes. DaSiWa Inpaint Composite is the node that enforces the rule for you. It's the second half of the pack's crop-inpaint-composite pair, and its whole job is taking an inpainted patch and putting it back where it belongs without leaving a visible seam.

What it does

You hand it three things - the original destination image, the inpainted source patch, and the mask that says where the patch goes - plus the x, y, w, h box that says where in the destination that patch belongs. It then:

  1. Auto-rescales the patch (and the mask) to fit w × h, so the patch doesn't need to come out of your inpainter at the exact composite size.
  2. Optionally color-corrects the patch against the destination region.
  3. Alpha-blends the patch in through the mask, so edges feather instead of hard-clipping.

The important detail: only the masked region ever changes. Everything else is copied straight from the destination, untouched - no VAE round-trip for pixels that didn't change. That's the whole point of crop-and-stitch inpainting.

The inputs that matter

  • correction_method - the one you'll actually set, with three choices: None, Match Channels, and Histogram. The problem it solves is real: a crop inpainted at 1024px and pasted back onto a 512px source often has a subtly different brightness or color cast. Match Channels (default) is the safe first choice - it shifts the patch's per-channel mean and standard deviation to match the destination region. Histogram is in the same family (the enum is honest about it), and None is for when the inpainter already matched colors well and you don't want it touched.
  • x / y / w / h - the paste box. If you're using the pack's Inpaint Crop Prep, wire its bbox_x, bbox_y, bbox_w, bbox_h outputs straight in and you never think about these again. If you're not, you can hard-set them - the node happily composites from coordinates you type.

The mask input is the same mask you used to crop in the first place; the node rescales it to the box automatically.

Wiring it up

IMAGE ──► Inpaint Crop Prep ──► cropped_image ──► any inpainter ──► source ─┐
                                    │ bbox_x/y/w/h                          ▼
                                    └────────────────────────────► DaSiWa Inpaint Composite ──► IMAGE
IMAGE (original) ─────────────────────────────────────────────────► destination

The output is a single image - the composited result - ready for a save node or further post-processing.

Installing it

Same as the rest of the pack - ComfyUI Manager (search DaSiWa-Nodes) or:

cd ComfyUI/custom_nodes
git clone https://github.com/darksidewalker/ComfyUI-DaSiWa-Nodes
pip install -r requirements.txt

then restart. It's pure PyTorch - the color correction is channel statistics, no torchvision - so the pack's RTX-GPU requirement doesn't apply to this node specifically.

Where people get burned

  • Color cast after compositing. If the pasted patch is visibly lighter/darker or tinted against the surrounding pixels, you set correction_method to None. Set it to Match Channels and the patch gets rebalanced against the actual destination region - this is the fix for the classic "grey box around the inpaint" complaint, which usually comes from a VAE mismatch upstream.
  • Patch in the wrong place. The paste coordinates come from Crop Prep's bbox outputs. If you're hard-typing them, remember the box is in original image space, not crop space. A patch that lands in the corner instead of on the face means you mixed those up.
  • Forgetting the mask. Feed a full-white mask and you'll paste the patch over the whole box, edge and all. The mask is what feathers the boundary - it's required, not optional.

One honest caveat: the pair expects a feathered mask from Crop Prep's blur to do its best work. If you're bringing in a hard-edged mask from elsewhere, add a little blur before it hits the composite, or the seam shows.

CategoryDaSiWa/Inpaint

Inputs (8)

NameTypeDefaultDescription
destinationIMAGE
sourceIMAGE
maskMASK
xINT0
yINT0
wINT5121–8192
hINT5121–8192
correction_methodCOMBOMatch Channels3 options: None, Match Channels, Histogram

Outputs (1)

NameTypeDescription
imageIMAGE