Nodes/comfyui-art-venture/Overlay Inpainted Latent
ComfyUI Node Runs on cloud

Overlay Inpainted Latent

Composite an inpaint in latent space

By sipherxyz·Created 3 years ago·Updated 4 months ago· 352
Overlay Inpainted Latent
  • original
  • inpainted
  • mask
  • LATENT

Same job as OverlayInpaintedImage - paste an inpainted result back so only the masked region actually changed - but done in latent space instead of on decoded pixels. Where OverlayInpaintedImage works after your sampler and VAE decode, taking a cropped image and pasting it into a full-size one, this node blends the latents directly, before anything gets decoded to pixels at all.

Reach for this one when your pipeline keeps going after the inpaint: another sampling pass, an upscale that expects a latent, or any further latent-space step. Compositing here and decoding once at the very end avoids decode → composite → re-encode round-trips, which is exactly the kind of unnecessary VAE cycling the "composite after inpainting" best practice warns against in the first place - this node just applies that principle one stage earlier, in latent space rather than pixel space.

How it works

Given the original latent, the inpainted latent, and a mask, it blends the two latents together using the mask as the blend weight: masked regions take the inpainted latent's values, unmasked regions keep the original's. The result is a single latent, ready for further sampling or a single VAE decode at the end of the chain.

The inputs and outputs that matter

Three required inputs:

  • original - the LATENT before inpainting - your starting point, unmodified.
  • inpainted - the LATENT after your inpainting sampler pass ran.
  • mask - the MASK marking which region should come from inpainted versus original.

One output: LATENT - the composited result, decode it whenever you're actually ready for pixels.

How to install it

Ships with the Art Venture pack. ComfyUI Manager: search comfyui-art-venture, install, restart. Manually:

cd ComfyUI/custom_nodes
git clone https://github.com/sipherxyz/comfyui-art-venture

then pip install -r comfyui-art-venture/requirements.txt and restart. No model download.

Common issues & troubleshooting

Composited region doesn't line up with where I painted the mask. mask needs to match the latent's spatial dimensions - remember latents are downsampled relative to the pixel image (typically 8x for SD/SDXL), so a mask built at pixel resolution may need resizing to match the latent before this node can use it correctly.

Unmasked areas changed slightly anyway. That shouldn't happen if the mask is clean - a soft, blurred mask edge will blend proportionally in that boundary region by design, which is usually what you want for a seamless transition. A hard, binary mask should leave the rest of original untouched exactly.

Not sure whether to use this or OverlayInpaintedImage. Use this one if more latent-space work follows the inpaint - another sampler pass, a latent upscale - so you decode only once at the end. Use OverlayInpaintedImage if the inpaint is the last step and you're already working with decoded pixels, or if you cropped with PrepareImageAndMaskForInpaint and need to paste back into full-image coordinates rather than blend two same-sized latents.

Result looks blurry or low-detail in the inpainted region. That's more likely an upstream sampling issue than this node - check your inpaint pass actually ran at adequate resolution and step count before assuming the compositing step introduced the softness.

CategoryArtVenture/Inpainting

Inputs (3)

NameTypeDefaultDescription
originalLATENT
inpaintedLATENT
maskMASK

Outputs (1)

NameTypeDescription
LATENTLATENT