Nodes/comfyui-timesaver/TS Smart Inpaint
ComfyUI Node

TS Smart Inpaint

The one-node inpaint that does the crop, sample, and stitch itself

By AlexYez·Created 2 years ago·Updated a day ago· 12
TS Smart Inpaint
  • model
  • vae
  • positive
  • negative
  • image
  • mask
  • reference
  • image
replacetrue
denoise1.00
megapixels1.5
context_pct8.0
feather_pct3.0
resize_methodlanczos
seed0
steps4
cfg1.0
sampler_nameeuler
schedulersimple

Mask-based inpainting has quietly become the reliable old tool of the editing stack - while the new instruction-edit models (Qwen-Edit, Kontext) happily redraw the whole frame and drift every pixel you didn't ask about, a masked inpaint keeps the untouched areas bit-exact. The catch has always been the plumbing: crop the masked region, upscale it so the model has resolution to spend, encode, sample, and feather the result back. TSSmartInpaint is that whole pipeline in a single node - you feed the full image, the mask, and a checkpoint, and it returns the finished edit.

How it works

It runs the classic crop-and-composite loop internally, which the README spells out: it crops the masked region plus a context band, upscales the crop toward a megapixel budget so a small selection gets full-res detail, VAE-encodes, samples, then feather-composites and latent-blends the result back so untouched pixels stay bit-exact. You never build the crop → sampler → stitch chain yourself.

The replace toggle picks which of two very different jobs it does:

  • Replace (default) - full regeneration of the masked area, "Kontext-style": the crop becomes the reference_latents, and denoise is locked to 1.0. There's even an optional reference image input - wire one in and the hole is filled toward that picture's content ("fill with THIS").
  • Refine - an ADetailer-style partial-denoise pass at the denoise value, no reference. This is the "polish the existing content" mode, like a face-repair pass.

The defaults are tuned for transformer-era models: steps 4, cfg 1.0, scheduler "simple" - which is a very Flux-flavoured starting point, so if you're on SDXL you'll likely want more steps and a real CFG. megapixels (1.5 default) is the processing budget: small crops upscale toward it, oversized crops downscale to it so a huge mask in an 8K frame can't hang the machine.

Two settings are proportional rather than fixed pixels, which is the right call: context_pct (8) is the surrounding context as a percent of the mask's own size, and feather_pct (3) is the edge blend, also relative - so a thin stroke doesn't get an over-soft ghost.

Wiring it

Inputs you'll definitely connect: model, vae, positive, negative, image, mask. The positive/negative conditioning describes what to generate inside the mask. The one output is the composite image.

Install

No extra dependencies - it's pure comfyui-timesaver.

cd ComfyUI/custom_nodes
git clone https://github.com/AlexYez/comfyui-timesaver
cd comfyui-timesaver
python -m pip install -r requirements.txt

Restart, then search "TS Smart Inpaint".

Common issues

  • "The whole image changed." You probably expected Replace to leave everything else alone. It does - but if your mask is large and context_pct is high, the context band gets regenerated too. Keep the mask tight.
  • "Result looks mushy." A small crop got upscaled toward megapixels and the model had to invent detail. Raise megapixels for sharper detail, or lower it if it's hallucinating.
  • "Denoise doesn't do anything." That's Replace mode - it's deliberately locked to 1.0. Switch to Refine for a partial pass.
  • Visible seam. Raise feather_pct a little; 0 is a hard edge and that's almost never what you want on a real edit.

The honest trade: a one-node inpaint can't match a hand-built chain where you tune the sampler for the specific model - but it removes about nine nodes of scaffolding, and for 95% of "remove this, fix that" mask work it's the faster road. The KB's verdict on masks still applies: bit-identical pixels outside the mask are the one thing no instruction-editor gives you.

CategoryTS/Image/Retouch

Inputs (18)

NameTypeDefaultDescription
modelMODELDiffusion model used to regenerate the masked region.
vaeVAEVAE used to encode the crop to latent and decode the result.
positiveCONDITIONINGPositive conditioning describing what to generate inside the mask.
negativeCONDITIONINGNegative conditioning describing what to avoid.
imageIMAGEFull source image to inpaint.
maskMASKMask marking the region to inpaint (white = regenerate).
replaceBOOLEANtrueReplace = Smart Inpaint: regenerates the masked region from scratch (reference_latents = the crop; an optional `reference` image is chained as a 2nd reference — 'fill with THIS'). Denoise is IGNORED and locked to 1.0. Refine = partial denoise of the existing content at the Denoise value (no reference).
denoiseFLOAT1.000–1Refine mode only: how much of the existing content is redrawn (1.0 = fully). Ignored in Replace mode (locked to 1.0).
megapixelsFLOAT1.50.1–8Processing budget for the masked crop. Small crops upscale toward it; oversized crops downscale to it to bound VAE/sampler cost. Raise for more detail.
context_pctFLOAT8.00–50Context band around the mask the model sees during refine, as a PERCENT of the mask's own size (not fixed pixels) — so it scales with the selection. Also hosts the colour-correction ring. ~8% is a sensible default; raise for more surrounding context.
feather_pctFLOAT3.00–25Feather (edge blend) width as a PERCENT of the mask's own size rather than fixed pixels — a small mask gets a proportionally small feather (no over-soft ghosting on thin strokes), a big mask a wider blend. Clamped to a small px floor. ~3% is a sensible default; 0 = hard edge.
resize_methodCOMBOlanczosInterpolation used to up/downscale the image crop. lanczos and bicubic keep the most detail.
seedINT00–18446744073709550000Noise seed for the sampler. Change for a different variation of the inpainted region.
stepsINT41–100Number of sampling steps. More steps trade speed for quality.
cfgFLOAT1.00–30Classifier-free guidance scale. Higher values follow the prompt more strongly.
sampler_nameCOMBOeulerSampling algorithm used to denoise the region.
schedulerCOMBOsimpleNoise schedule that controls how sigma decreases across steps.
referenceoptIMAGEOptional reference image (Replace only). VAE-encoded and chained as a 2nd reference_latents after the crop, so the masked region is filled toward THIS picture's content. Leave unconnected for plain Smart Inpaint.

Outputs (1)

NameTypeDescription
imageIMAGE