TS Smart Inpaint
The one-node inpaint that does the crop, sample, and stitch itself
- model
- vae
- positive
- negative
- image
- mask
- reference
- image
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 optionalreferenceimage 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
denoisevalue, 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_pctis high, the context band gets regenerated too. Keep the mask tight. - "Result looks mushy." A small crop got upscaled toward
megapixelsand the model had to invent detail. Raisemegapixelsfor 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_pcta 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.
Inputs (18)
| Name | Type | Default | Description |
|---|---|---|---|
| model | MODEL | Diffusion model used to regenerate the masked region. | |
| vae | VAE | VAE used to encode the crop to latent and decode the result. | |
| positive | CONDITIONING | Positive conditioning describing what to generate inside the mask. | |
| negative | CONDITIONING | Negative conditioning describing what to avoid. | |
| image | IMAGE | Full source image to inpaint. | |
| mask | MASK | Mask marking the region to inpaint (white = regenerate). | |
| replace | BOOLEAN | true | Replace = 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). |
| denoise | FLOAT | 1.000–1 | Refine mode only: how much of the existing content is redrawn (1.0 = fully). Ignored in Replace mode (locked to 1.0). |
| megapixels | FLOAT | 1.50.1–8 | Processing 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_pct | FLOAT | 8.00–50 | Context 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_pct | FLOAT | 3.00–25 | Feather (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_method | COMBO | lanczos | Interpolation used to up/downscale the image crop. lanczos and bicubic keep the most detail. |
| seed | INT | 00–18446744073709550000 | Noise seed for the sampler. Change for a different variation of the inpainted region. |
| steps | INT | 41–100 | Number of sampling steps. More steps trade speed for quality. |
| cfg | FLOAT | 1.00–30 | Classifier-free guidance scale. Higher values follow the prompt more strongly. |
| sampler_name | COMBO | euler | Sampling algorithm used to denoise the region. |
| scheduler | COMBO | simple | Noise schedule that controls how sigma decreases across steps. |
| referenceopt | IMAGE | Optional 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)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |