← All models

image-to-image (inpainting) Β· vision Β· WASM Β· ~208 MB

LaMa β€” erase an object, fill the gap

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.

At a glance

ModelCarve/LaMa-ONNX β€” big-lama (LaMa, Fourier-convolution inpainting)
Taskimage-to-image (inpainting) β€” run via raw ONNX Runtime Web (see note below)
Runtimeonnxruntime-web 1.21 (transformers.js has no LaMa class / no inpainting task)
Inputsimage [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
Quantizationfp32 ONNX β€” runs on the plain WASM execution provider, no WebGPU needed
BackendWebAssembly (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.
LicenseApache-2.0 (ONNX export) Β· LaMa (Apache-2.0)
Web APIsWebAssembly, Web Workers, OffscreenCanvas, ImageBitmap, Pointer Events β€” all Baseline widely available

Run it

Pick a photo, then brush over the thing you want removed (or use the rectangle preset). Hit Inpaint and LaMa fills the masked region.

Drop / choose your own photo to edit

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).

See inside

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.

Inpaint a region to see exactly what the model filled.

Why it matters

"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.

Use cases

Basics

Brush over an object, hit Inpaint, and watch LaMa fill the gap with plausible background.

Practical

Privacy redaction: paint out a face or plate, fill the hole, and download the cleaned image.

Wild

Push the mask: grow it bigger and bigger and find where coherent fill turns into invented blur.

Multi-model

Inpaint β†’ super-res: erase an object, then upscale the cleaned photo β€” two models, all local.

How the API works

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.

References