Load Inpaint LaMa Model
The quiet half of the LaMa inpainting pair — and the one weird trick inside it
- INPAINT_LAMA_MODEL
This node is a dropdown and a wire. It's the boring half of the fplu/comfyui_lama_with_refiner pair, and that's the compliment - you wire it once, feed its output into Inpaint (using LaMa + Refinement), and never think about it again.
Its whole job is to load the LaMa inpainting model and hand it over as an INPAINT_LAMA_MODEL that the refiner node understands. One input (model_name), one output, no knobs.
What it reads and why it's picky
The dropdown lists every file it finds in ComfyUI/models/inpaint/ (the pack registers that folder for .pt, .pth, .safetensors, and .patch). The file you actually want is big-lama.pt, the torchscript build of LaMa from the README's mirrors, roughly 200 MB.
Here's the picky part, and it matters: the loader does torch.jit.load() on that file, unwraps its state dict, and hands it to spandrel's architecture detector. That means it has to be the JIT-compiled .pt, not a raw checkpoint - the raw training weights won't load. If you've used one of the other popular "big lama remover" packs, the file may already be sitting in models/inpaint/ and this dropdown will simply find it.
The one weird trick
After loading, the code deliberately turns on gradient tracking for the conv weights while keeping the model in eval() mode. Normally those two are opposed - you're either training or inferring. But the refiner node runs an Adam optimization loop during inference and needs autograd to do it, so the loader is quietly prepping the model for that. It's also why this pack can't just reuse ComfyUI's plain checkpoint loader: the model comes out half-ready for inference-time optimization, which is exactly the state the sibling node expects.
Worth knowing: there's no caching. Every queue run re-executes load(), so a big batch re-reads the ~200 MB file each time. It's only a couple of seconds, but it's there.
Install
ComfyUI Manager: search lama_with_refiner. Or:
cd ComfyUI/custom_nodes
git clone https://github.com/fplu/comfyui_lama_with_refiner.git
Then download big-lama.pt from any mirror in the README into ComfyUI/models/inpaint/ - create the inpaint folder if a fresh ComfyUI install doesn't have it. Restart, and the dropdown should list it.
Troubleshooting
- Empty dropdown - the file isn't in
models/inpaint/. Dropbig-lama.ptthere and refresh. - "Model file not found" - the loader raises this when the chosen name isn't on disk, usually after the folder got cleaned or the file moved.
- IMPORT FAILED on the whole pack - the pack ships no
requirements.txt, so nothing auto-installs. It's almost always kornia missing from your ComfyUI venv:pip install korniain the same environment ComfyUI runs in.
Then wire the INPAINT_LAMA_MODEL output into the inpaint_model input of the refiner node, and get back to actually removing things.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| model_name | COMBO | 0 options: |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| INPAINT_LAMA_MODEL | INPAINT_LAMA_MODEL | — |