VAE Encode Inpaint
VAE encode for inpainting, without the padding headache
- pixels
- vae
- mask
- LATENT
"VAE Encode Inpaint" is this pack's version of the inpainting-specific VAE encode, and it exists to fix a real, annoying problem: ComfyUI's normal VAEEncode expects input dimensions that are multiples of the VAE's downscale ratio (8 for SD 1.5), and your image almost certainly isn't. If you've ever hit "latent size mismatch" or watched a sampler silently produce garbage because your width was 513 instead of 512, you know the pain this node removes.
The bigger reason it's here, though, is the mask. The whole trick of latent-space inpainting is that you don't just encode the image and run a normal sampler - you attach a noise_mask to the latent so the sampler knows which pixels to denoise and which to leave frozen. VAEEncode alone doesn't do that. This node does.
How it works
It pads your pixels up to the next multiple of the VAE's downscale ratio (centered, filling with a neutral gray), encodes, and embeds a noise_mask in the returned LATENT along with the samples. When you feed that latent to a KSampler, the sampler only regenerates the masked region - the unmasked pixels stay exactly as they were, which is the whole reason masked inpainting exists. The input mask marks the region to regenerate.
The one knob you'll actually touch: grow_mask_by (default 6). This grows the mask outward in latent space before it becomes the noise mask, and it's the classic inpainting edge hack - a hair more masked area means the sampler blends across the seam instead of leaving a hard boundary. Bump it up (the bundled workflow uses 20) when you see visible edges on the inpainted patch. The max is 64, so you've got room.
Inputs: pixels (your image), vae, mask, grow_mask_by. Output: one LATENT that already carries the noise mask - you don't wire the mask to the sampler separately, it travels inside the latent. That's a quiet detail that confuses people coming from A1111 habits.
Install
The pack-wide story applies:
cd ComfyUI/custom_nodes
git clone https://github.com/SherryXieYuchen/ComfyUI-Image-Inpainting
# restart ComfyUI
(Manager → search "ComfyUI-Image-Inpainting".) Needs a VAE wired in - the README suggests vae-ft-mse-840000-ema-pruned.safetensors for the SD 1.5 workflow - and nothing else. In the bundled graph, note that the mask goes through the pack's ImagePreprocess first so image and mask are the same resolution before they meet here. If you skip that and your mask is a different size than your image, you'll get a resize error or silently misaligned masking.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| pixels | IMAGE | — | |
| vae | VAE | — | |
| mask | MASK | — | |
| grow_mask_by | INT | 60–64 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| LATENT | LATENT | — |