Nodes/image_control/abyz22_lamaInpaint
ComfyUI Node

abyz22_lamaInpaint

LaMa fills the hole before the sampler does

By abyz22·Created 3 years ago·Updated 2 years ago· 17
abyz22_lamaInpaint
  • pixels
  • vae
  • mask
  • mask_(img)
  • LaMa Preprocessed Image
  • LaMa Preprocessed Latent
  • LaMa Image

Plain ComfyUI inpainting starts the masked area from noise and hopes the sampler hallucinates something plausible. LaMa doesn't hope - it's a dedicated inpainting network that literally draws the missing pixels first, then your sampler refines them. abyz22_lamaInpaint runs that LaMa pass and hands you a ready-to-sample image, latent, and the LaMa-filled result. The payoff is that masked areas come out coherent with their surroundings instead of looking like a paste job.

It's the inpainting half of the LaMa pair in abyz22/image_control (with abyz22_lamaPreprocessor doing the outpainting/padding flavor). The pack bundles a real LaMa implementation - the code is shipped in annotator/lama/, and it downloads the ControlNetLama.pth weights (~200 MB) from lllyasviel's Annotators repo on Hugging Face the first time it runs. No separate model folder management needed, just a wait on first use.

Inputs and outputs

  • pixels - the image to inpaint (IMAGE).
  • vae - your checkpoint's VAE, needed to encode the LaMa result into latent space.
  • mask (optional) - a MASK of the region to fill.
  • mask_(img) (optional) - the same thing as an IMAGE; the red channel is used as the mask. If neither is connected, the mask is all zeros and the node still runs (pointless, but harmless).

Outputs are the three you'd expect from a preprocessor:

  • LaMa Preprocessed Image - the original image with the mask baked into the alpha channel (pixels become ±1). This is what you composite the sampler's output back against.
  • LaMa Preprocessed Latent - the LaMa-filled image encoded to latent, noise-masked, ready for a KSampler.
  • LaMa Image - the LaMa result itself as a normal image.

How it works

The node packs pixels + mask into a 4-channel image where the mask is alpha, feeds it through the bundled LaMa model (which outputs a fill for the masked area), then encodes the filled result and applies SetLatentNoiseMask so the sampler only denoises the hole. The "preprocessed latent" is the trick that makes this a one-pass pipeline: sample it, decode, and composite back over the original using the alpha mask.

Install and the two things that bite

cd ComfyUI/custom_nodes
git clone https://github.com/abyz22/image_control

or ComfyUI Manager → "image_control", restart. First run of the LaMa nodes downloads the weights from Hugging Face, so do it on a decent connection. The pack's requirements (openpyxl, pytorch-lightning, kornia) plus the annotator's imports mean a full environment - if import fails on startup, check that omegaconf/einops/yaml are present, as the pack doesn't list them.

Two practical notes: LaMa expects the mask to mark what to erase, matching how the alpha channel works here, so double-check polarity if your fill appears where it shouldn't. And the whole point of the node is feeding the latent to a sampler - if you just want the LaMa fill with no refinement, you'd want the LaMa Image output used directly, which for many cases (like object removal) is honestly good enough to skip sampling entirely.

Categoryabyz22

Inputs (4)

NameTypeDefaultDescription
pixelsIMAGE
vaeVAE
maskoptMASK
mask_(img)optIMAGE

Outputs (3)

NameTypeDescription
LaMa Preprocessed ImageIMAGE
LaMa Preprocessed LatentLATENT
LaMa ImageIMAGE