Nodes/ComfyUI_Lam/图片局部重绘lama
ComfyUI Node

图片局部重绘lama

ImageLama's prompt-free inpainting

By yanlang0123·Created 2 years ago·Updated 11 days ago· 77
图片局部重绘lama
  • images
  • mask
  • 图片

ImageLama (图片局部重绘lama, "local repaint with LaMa") is the star of this pack, and it earns it. Give it an image and a mask, and it removes whatever's under the mask and fills the hole with plausible content - no diffusion model, no prompt, no denoise slider, no sampler. It's the ComfyUI version of Photoshop's Content-Aware Fill, and it's genuinely good at it.

What it's for: erasing people, objects, text, watermarks, power lines - anything where you want the scene reconstructed, not regenerated. Because it's not a diffusion pass, it doesn't touch the rest of the image at all: pixels outside the mask are bit-identical before and after. That's the property the KB's inpainting essay calls out as the remaining unique strength of mask-based inpainting over whole-frame edit models - LaMa owns it completely. It also runs in a second or two per frame, which makes it the obvious first step before a diffusion inpaint in a "remove the thing, then repaint details" pipeline.

How it works

The node loads a real LaMa model - the ControlNetLama.pth checkpoint from the lllyasviel Annotators repo, placed in ComfyUI/models/lama/. (The code auto-downloads it on first run if it's missing, so you may just see a progress bar.) LaMa is a conv-net trained for high-resolution image inpainting: it analyzes the unmasked surroundings and synthesizes the masked region from context, no text conditioning involved. The node resizes to LaMa's native 256px operating resolution, runs the model, upsamples the result back, and composites it back into the original using the mask as the blend weight.

Inputs and output

  • images - the IMAGE to repair.
  • mask - the MASK; white (1.0) marks what gets erased and regenerated.
  • Output: 图片 (image), the repaired IMAGE. Batch-aware - it processes every frame.

Install

The pack: Manager search "ComfyUI_Lam", or:

cd ComfyUI/custom_nodes
git clone https://github.com/yanlang0123/ComfyUI_Lam

restart. Then make sure the model exists - either let it auto-download on first run, or grab it yourself:

# from ComfyUI root
curl -L -o models/lama/ControlNetLama.pth \
  https://huggingface.co/lllyasviel/Annotators/resolve/main/ControlNetLama.pth

That's the only setup it needs; the pack's install.bat requirements (tensorflow, etc.) aren't required for this node, though the pack will pull them in anyway.

Where people get burned

The model is trained at 256px, and the node downsizes before inpainting. That means large masked areas come back soft and blurry - LaMa is fantastic at removing a person or a text box, but a mask covering a quarter of the image will yield a mushy, low-detail fill. The fix is to mask tightly and let a diffusion inpaint handle the detail pass on top. Related gotcha: the mask and image must share the same height/width or the composite lands wrong. And on first run it downloads a ~200MB checkpoint, so the "why is it hanging?" moment is usually just the download. It's not the node for adding content - it's for removing it cleanly, and for that it's hard to beat in a graph.

Categorylam

Inputs (2)

NameTypeDefaultDescription
imagesIMAGE
maskMASK

Outputs (1)

NameTypeDescription
图片IMAGE