What Is LaMa Inpainting and How Does It Remove Watermarks?
LaMa (Large Mask Inpainting) is a state-of-the-art neural network designed to fill in missing or removed parts of images. It's the technology behind the "Best Quality" mode in Gemini Watermark Remover.
How traditional inpainting works
Older inpainting methods like Navier-Stokes or Telea (used in OpenCV) work by propagating nearby pixel colors into the missing region. They work well for small, simple areas but struggle with larger regions or complex textures — often producing blurry or smeared results.
What makes LaMa different
LaMa was developed by Samsung AI and published in 2021. Its key innovation is using Fast Fourier Convolutions (FFC) that give the network a global receptive field — meaning it can "see" the entire image at once, not just local patches.
This matters for inpainting because:
- Large areas can be filled coherently, maintaining textures and patterns across the entire mask
- Repeating patterns (like textures, tiles, or gradients) are continued naturally
- Edges and structures that pass through the masked region are reconstructed correctly
How we use LaMa for watermark removal
When you select "Best Quality" mode:
- The Gemini watermark region is automatically detected (it's always in the same position)
- A feathered mask is generated around that region
- The image and mask are resized to 512x512 (LaMa's native resolution)
- The LaMa model runs inference entirely in your browser using ONNX Runtime WebAssembly
- The inpainted result is scaled back to original resolution and blended with the original image
The entire process happens on your device — the 199MB model is downloaded once and cached by your browser.
LaMa vs. other inpainting models
| Model | Quality | Speed | Size |
|---|---|---|---|
| LaMa | Excellent | ~5-30s | 199 MB |
| OpenCV Telea | Good for simple areas | Instant | 11 MB |
| Stable Diffusion Inpainting | Best for creative fills | Very slow | 2+ GB |
| MAT | Very good | Slow | 500+ MB |
LaMa hits the sweet spot of quality and practicality for watermark removal — it's small enough to run in a browser, fast enough to be usable, and produces results that are visually indistinguishable from the original for most watermark removal tasks.
Can LaMa remove any watermark?
LaMa works best when the watermark region is well-defined and the surrounding content has enough context for reconstruction. Gemini's bottom-right watermark is an ideal case because:
- The position is predictable and consistent
- The watermark area is relatively small (about 2% of total image area)
- Background content in the bottom-right is usually less complex
For watermarks that cover large portions of an image or are scattered across it, LaMa would need a much larger mask and results would be less reliable.