Nodes/ComfyUI_EmAySee_CustomNodes/EmAySee Repaint KSampler
ComfyUI Node

EmAySee Repaint KSampler

A KSampler that repaints only what your mask says — no extra nodes

By EmAySee·Created about a year ago·Updated 4 months ago· 2
EmAySee Repaint KSampler
  • model
  • positive
  • negative
  • latent_image
  • mask
  • latent
sampler_nameeuler_ancestral
schedulernormal
steps20
cfg8.00
denoise1.00

Masked inpainting without bolting on a separate inpaint workflow. This node is a KSampler variant that takes a mask alongside your latent and only samples inside it: the masked (white) regions get regenerated from noise while the black regions keep their original pixels. Same inputs as a normal KSampler plus a mask - one node, no conditioning gymnastics.

How it works

Wire in the usual KSampler suspects - model, positive, negative, latent_image - plus a mask (the standard ComfyUI MASK type, e.g. from an auto-masking or segment node). Then sampler_name, scheduler, steps, cfg, and denoise behave exactly like the built-in sampler.

Under the hood it does the classic masked img2img trick by hand: it keeps the original latent where the mask is black, replaces the masked area with noise scaled by denoise, and runs the sampler on that blend. Read the polarity carefully - this node follows white = repaint, black = keep. If your mask came from a pipeline that uses the opposite convention (white = keep, which some inpainting tools do), flip it with an Invert Mask node or the whole output will look like a hallucination.

What to know before trusting it

This is a hand-rolled KSampler, not ComfyUI's full inpaint machinery. A couple of real caveats:

  • No seam blending. It samples the masked region against the unmasked context and hands back the raw result. Expect the occasional seam or color mismatch at the mask boundary - the KB's inpainting writeup calls exactly this out: standard masked img2img works, but it "can produce seam artifacts and color mismatches."
  • denoise does double duty. It scales the noise in the masked area and passes to the sampler, so at denoise 1.0 the masked area is fully regenerated and at lower values it partially re-samples the original. For a subtle fix, drop it; for a full repaint, leave it at 1.
  • The mask must match your latent resolution. If your mask is a different size than the latent, the 1.0 - mask.unsqueeze(1) math will complain or silently misalign. Upscale/downscale the mask to the latent's dimensions first.

Where it fits

Any classic masked-inpaint job - fixing a face region, swapping an object, removing a flaw - where you want one self-contained node instead of assembling the standard masked-encode/denoise dance from core nodes. It's also fine for partial repaint chains on SDXL-era models, which still hold up for mask-based work (per the KB, the "traditional mask inpainting" crowd keeps SDXL around for exactly this).

Installing it

Part of ComfyUI_EmAySee_CustomNodes. ComfyUI Manager → search the pack title → Install, or:

cd ComfyUI/custom_nodes
git clone https://github.com/EmAySee/ComfyUI_EmAySee_CustomNodes
# restart ComfyUI

Under EmAySee_Utils. It uses ComfyUI's own sampler internals, so no extra dependencies.

Bottom line

A decent masked-repaint sampler in one node. Read the white-repaints/black-keeps polarity, match the mask size to the latent, and it'll save you a stack of wiring. If you need production-grade inpainting with seam handling, the big inpaint packs do more - this one wins on simplicity, not polish.

CategoryEmAySee_Utils

Inputs (10)

NameTypeDefaultDescription
modelMODEL
positiveCONDITIONING
negativeCONDITIONING
latent_imageLATENT
maskMASK
sampler_nameCOMBOeuler_ancestral44 options: euler, euler_cfg_pp, euler_ancestral, euler_ancestral_cfg_pp, heun, heunpp2, +38
schedulerCOMBOnormal9 options: simple, sgm_uniform, karras, exponential, ddim_uniform, beta, +3
stepsINT201–10000
cfgFLOAT8.000–1000
denoiseFLOAT1.000–1

Outputs (1)

NameTypeDescription
latentLATENT