Nodes/HFDownLoad Node for ComfyUI/LayerUtility: LaMa V2
ComfyUI Node

LayerUtility: LaMa V2

LaMa V2 — erase something and have the background actually fill in, no prompt needed

By icesun963·Created 2 years ago·Updated 2 years ago· 0
LayerUtility: LaMa V2
  • image
  • mask
  • image
lama_model
device
invert_maskfalse
mask_grow25
mask_blur8

LaMa (Large Mask Inpainting) is old enough that it actually predates Stable Diffusion - a lama-cleaner fork on GitHub shows a commit history stretching back five months before SD 1.0 shipped. It's not a diffusion model and it doesn't take a text prompt. You give it an image and a mask, and it reconstructs whatever's under the mask by extending the surrounding structure - no hallucinated new subject matter, just a plausible fill. That makes it the right tool for a very specific job: genuinely erasing something, not editing it into something else.

That distinction matters more now than it used to. Instruction-editing models (Kontext, Qwen-Image-Edit and friends) have taken over most of what people used to reach for masked inpainting for - but the one thing a mask still guarantees that an instruction model doesn't is that the unmasked pixels are bit-identical to what you started with. LaMa is the purest version of that guarantee: point it at a logo, a watermark, a photobombing stranger, and it removes exactly that region and nothing else, deterministically, without a diffusion model's tendency to also subtly repaint the rest of the frame.

This particular node is ported from chflame163's ComfyUI_LayerStyle into this pack, kept around "for batch acceleration" per the author's own notes - useful if you're running LaMa over a folder of images rather than one at a time.

The inputs and outputs that matter

  • image and mask - the mask defines what gets erased. It's typically the output of something like SegmentAnythingUltra (also in this pack) or a hand-painted region.
  • lama_model - seven backend choices, but lama itself is the one to start with; it's the name-brand, best-tested option. The other six (ldm, zits, mat, fcf, manga, spread) are alternate inpainting architectures the same underlying toolkit bundles - only worth reaching for if lama is visibly struggling on your specific image.
  • invert_mask - flips which side of the mask gets erased. If the wrong thing disappears (background gone, subject left behind), this is backwards.
  • mask_grow (default 25) and mask_blur (default 8) - the two knobs that actually matter for output quality. A mask that fits too tightly to the object leaves a visible ring or ghost outline after the fill; growing the mask and feathering the edge is what makes the result blend instead of looking like a sticker was peeled off.
  • device (cuda / cpu).

Output is a single image - the result, ready to save or feed into further compositing.

How to install it

ComfyUI Manager: search HFDownLoad Node for ComfyUI, install, restart. Manual: cd ComfyUI/custom_nodes && git clone https://github.com/icesun963/ComfyUI_HFDownLoad, then restart.

Unlike the SAM dropdown in this same pack, the lama_model list doesn't show file sizes, so there's no obvious size hint about how heavy the checkpoint is. If a model isn't already present and the dropdown or the node errors out looking for it, that's exactly the gap this pack's own HFDownLoad_Tool node exists to close - find the right HuggingFace repo for the LaMa/IOPaint weights and pull it in with that node rather than hunting for a manual download link.

Common issues & troubleshooting

Visible outline or ghosting after the fill. This is a mask-fit problem almost every time, not a model problem. Increase mask_grow so the erased region fully covers the object with margin, and bump mask_blur so the edge blends instead of forming a hard seam.

It erased the wrong part of the image. Check invert_mask first - a flipped mask is the classic cause of "I asked it to remove the logo and it kept the logo and blurred everything else."

Fill looks smeared or repeats a pattern oddly. LaMa reconstructs from surrounding structure, so it does best on relatively simple, textured, or patterned backgrounds (walls, skin, grass, fabric) and worst on complex scenes with sharp unique detail right up against the mask edge - there, expect to touch up by hand or fall back to a diffusion-based inpaint instead.

Don't reach for the exotic backends by default. ldm, zits, mat, fcf, manga, and spread exist because the underlying toolkit bundles them, not because they beat plain lama for general use. Start with lama, and only swap if you have a concrete reason.

Category😺dzNodes/LayerUtility

Inputs (7)

NameTypeDefaultDescription
imageIMAGE
maskMASK
lama_modelCOMBO7 options: lama, ldm, zits, mat, fcf, manga, +1
deviceCOMBO2 options: cuda, cpu
invert_maskBOOLEANfalse
mask_growINT25-255–255
mask_blurINT8-255–255

Outputs (1)

NameTypeDescription
imageIMAGE