image-to-image (inpainting) Β· vision Β· WASM Β· ~208 MB
Brush over something you want gone β a passer-by, a power line, a blemish β and LaMa fills the region with plausible background, reconstructing texture and structure that were never there. LaMa (WACV 2022) is a large-mask inpainting network built on Fourier convolutions, so it can fill big holes coherently, not just tiny scratches. Runs entirely on your device via ONNX Runtime Web; the image and the mask never leave the tab.
| Model | Carve/LaMa-ONNX β big-lama (LaMa, Fourier-convolution inpainting) |
|---|---|
| Task | image-to-image (inpainting) β run via raw ONNX Runtime Web (see note below) |
| Runtime | onnxruntime-web 1.21 (transformers.js has no LaMa class / no inpainting task) |
| Inputs | image [1, 3, 512, 512] float32 0β1 Β· mask [1, 1, 512, 512] float32 (1 = fill, 0 = keep) |
| Output | [1, 3, 512, 512] float32 in 0β255 β we composite the filled region back over the untouched original |
| Quantization | fp32 ONNX β runs on the plain WASM execution provider, no WebGPU needed |
| Backend | WebAssembly (single-threaded on GitHub Pages) β a 512Γ512 pass is a handful of seconds |
| Download | ~208 MB, cached after first load (auto-inits on return). A one-time transfer β plan for it on mobile data. |
| License | Apache-2.0 (ONNX export) Β· LaMa (Apache-2.0) |
| Web APIs | WebAssembly, Web Workers, OffscreenCanvas, ImageBitmap, Pointer Events β all Baseline widely available |
Pick a photo, then brush over the thing you want removed (or use the rectangle preset). Hit Inpaint and LaMa fills the masked region.
LaMa reconstructs plausible content for the hole from the surrounding context β it invents coherent texture and structure, it doesn't recover what was truly there. The untouched pixels outside the mask are copied through exactly.
Everything runs on your device β the photo, the mask, and every filled pixel never leave the tab. Gallery images are rights-cleared samples (see each caption for the source).
This is the fill map: the exact region LaMa synthesised (indigo) over a dimmed copy of the original. Everything outside it is your untouched photo β the model only rewrites the masked pixels, and we composite them back so there's no seam or global colour shift. The size and shape of the indigo area is precisely the mask you painted, resampled to the network's 512Γ512 grid.
Indigo = pixels invented by LaMa; dimmed = your original, copied through untouched. A good inpaint has the indigo region blend seamlessly into the surrounding structure when you look at the result β LaMa's Fourier convolutions let it continue periodic texture (brick, foliage, water) across the hole rather than smudging it.
"Remove this thing from my photo" is one of the most-wanted edits there is. On-device inpainting means you can do it privately, with no upload and no per-image cloud cost:
LaMa fills big masks coherently, but it reconstructs plausible content, not the truth β it's an eraser-and-filler, not an undelete. Very large holes over complex subjects fill approximately.
Brush over an object, hit Inpaint, and watch LaMa fill the gap with plausible background.
Privacy redaction: paint out a face or plate, fill the hole, and download the cleaned image.
Push the mask: grow it bigger and bigger and find where coherent fill turns into invented blur.
Inpaint β super-res: erase an object, then upscale the cleaned photo β two models, all local.
transformers.js has no LaMa class and no inpainting task, so we run the ONNX graph directly with ONNX Runtime Web. In go the image and a binary mask, out comes the filled image:
import * as ort from "onnxruntime-web";
const session = await ort.InferenceSession.create(lamaBytes, { executionProviders: ["wasm"] });
// image β [1,3,512,512] in [0,1]; mask β [1,1,512,512] with 1 = fill, 0 = keep
const feeds = {
image: new ort.Tensor("float32", toNCHW(img, 512, 512), [1, 3, 512, 512]),
mask: new ort.Tensor("float32", toMask(userMask, 512, 512), [1, 1, 512, 512]),
};
const { output } = await session.run(feeds); // [1,3,512,512] in [0,255]
// composite the filled region back over the original: final = origΒ·(1βmask) + outputΒ·mask
const filled = composite(img, output.data, userMask);
Inference and the whole output composite run in a Web Worker so the UI never blocks, and the 208 MB model is fetched through Cache Storage, so a returning visit auto-initialises with no re-download.