ComfyUI Node

lamaPreprocessor

Inpaint and outpaint with an empty prompt — the LaMa preprocessor that predates generative fill

By mlinmg·Created 3 years ago·Updated 2 years ago· 67
lamaPreprocessor
  • pixels
  • vae
  • mask
  • LaMa Preprocessed Image
  • LaMa Preprocessed Latent
horizontal_expansion0
vertical_expansion0

First, the naming trap: this LaMA has nothing to do with the LLaMA language model. It's LaMa - Large Mask Inpainting with Fourier Convolutions, a Samsung Research/EPFL model that fills holes in images without any prompt at all. This node wraps that model as a ControlNet preprocessor, so you can inpaint or outpaint in ComfyUI with a blank prompt and still get coherent results. It's the same trick Automatic1111's ControlNet shipped as inpaint_only+lama back in mid-2023, ported to ComfyUI.

It's a neat idea and it's mostly abandoned now, which you should know going in. The author archived the repo in early 2024 and points people to Acly's comfyui-inpaint-nodes instead. Treat this node as a historical curiosity that still works, not something to build your whole pipeline on.

Why you'd reach for it

Normal ControlNet inpainting needs a prompt that describes what belongs in the masked region. The LaMa preprocessor removes that dependency: LaMa drafts the fill itself, based only on the surrounding pixels, and Stable Diffusion just refines it. In lllyasviel's own words from the original release, results come out "cleaner" than plain inpaint - fewer random objects, more consistent, fewer of those junk mountains that pure masked diffusion loves to invent. It shines at outpainting (extending a landscape sideways or upward) and simple object removal. The author reports best results on landscapes; on drawings, drop your ControlNet end percentage to 0.7–0.8.

How it works

The node is a preprocessor in the ControlNet sense, but it's doing real work. It takes your image and mask, crops to the region you're keeping, runs that through LaMa (at 256px, its training resolution) to draft the fill, then hands you two things: a control image where the masked area is blacked out, and the LaMa fill VAE-encoded into a latent. The classic A1111 border-noise trick is baked in to stop the VAE from choking on hard mask edges - the code even checks for NaN outputs and upcasts to fp32 if it hits them. The latent output gets its noise mask set so the sampler starts from the fill rather than from scratch.

The pieces wire up like this: LaMa Preprocessed Image goes into your inpainting ControlNet (control_v11p_sd15_inpaint.pth is what the included workflow uses), the original mask goes to that same ControlNet, and LaMa Preprocessed Latent feeds the KSampler as latent_image. Empty prompt, positive and negative. That's the whole trick.

The inputs that matter

Only a few, and none of them are hidden:

  • pixels (IMAGE) and vae (VAE) - required. The VAE encodes the fill into the latent output.
  • mask (MASK, optional) - white where you want content regenerated, black where it stays. For pure outpainting you can skip it entirely.
  • horizontal_expansion / vertical_expansion (INT, default 0, step 8) - when set with no mask, the node builds the outpaint mask for you and pads the canvas by that many pixels in each direction. This is the friendliest path in; it's also the mode the author recommends even for inpaint tasks.

Installing it

Via ComfyUI Manager, search "lama preprocessor". Or manually:

cd ComfyUI/custom_nodes
git clone https://github.com/mlinmg/ComfyUI-LaMA-Preprocessor

Restart ComfyUI. The pack's requirements.txt pulls in pytorch_lightning, pandas, and kornia - kornia is the chunky one, so expect a real install. On first run it downloads the ControlNetLama.pth checkpoint from HuggingFace (lllyasviel/Annotators), so keep an internet connection handy. README says NVIDIA only, and the code hard-codes CUDA when available.

Where people get burned

  • No mask and no expansion → instant error. The node raises "You must provide a mask of the same size as the image or a horizontal/vertical expansion". Setting expansion to 8 in both directions is the documented quick start.
  • It's fp16-VAE unfriendly. If your VAE spits NaNs, the node catches it and falls back to fp32 - but that's slower and it's a sign you're fighting the GPU.
  • Old, archived, single-maintainer. It was built by a student ("my school/work schedule seriously limit the time") and the known issues - color shifting, darkening, inconsistent results versus the A1111 original - were never fully fixed. If this exact feature matters to you, Acly's actively maintained alternative does the same job better.
Categoryimage/preprocessors

Inputs (5)

NameTypeDefaultDescription
pixelsIMAGE
vaeVAE
horizontal_expansionINT00–4096
vertical_expansionINT00–4096
maskoptMASK

Outputs (2)

NameTypeDescription
LaMa Preprocessed ImageIMAGE
LaMa Preprocessed LatentLATENT