Machine Learning in Linux: Lama Cleaner – self-hostable inpainting tool

In Operation

To start Lama Cleaner without any plugins, issue the command:

$ lama-cleaner --model=lama --device=cpu --port=8080

Point your web browser at You’ll see something like this (we’re using the light theme).

Lama Cleaner

Either click into the box to upload an image, or drag and drop an image. Select the area to inpaint, and see the results. By default, Lama Cleaner runs inpainting after drawing a stroke, but it’s also possible to use a manual mode from Settings (that’s the cog icon in the top right hand corner). Settings also lets you download masks, choose the model, and define the crop masking area.

With the default lama model, we’ll drag an image into the web browser.

Brush the area of the image you wish to remove. Here, we have brushed out the young woman on the scooter.

Lama Cleaner - plugins

There’s no functionality within the web interface to activate the plugins. Instead, they must be explicitly activated from the command-line. For example, to run Lama Cleaner with the Rembg, RealESRGAN, and GFPGAN plugins, issue the command:

$ lama-cleaner --model=lama --device=cpu --port=8080 --enable-remove-bg --enable-realesrgan --realesrgan-model RealESRGAN_x4plus --realesrgan-device cuda --enable-gfpgan --gfpgan-device cuda

There are keyboard shortcuts and a choice of theme (dark or light).

It’s also possible to run Lama Cleaner as a desktop application by appending the flag (--gui) e.g.

$ lama-cleaner --model=lama --device=cpu --port=8080 --enable-remove-bg --enable-realesrgan --realesrgan-model RealESRGAN_x4plus --realesrgan-device cuda --enable-gfpgan --gfpgan-device cuda --gui


Lama Cleaner modelsLama Cleaner gets our seal of approval. It’s really simple to install and use. You’ll be up and running in just a few minutes.

The interface is implemented well. We can set the brush size, there’s undo and redo functionality, together with the option to download the image results.

The results are impressive with the lama model. The image to the right shows all the models that are available (accessed from Settings). There are lots of nice touches such as its file manager, and painting by example using exemplar-based image editing.

There are three different ways to run the inpainting model on an image. By default, the crop strategy is used which crops the masking area from the original image. This offers good speed and uses little VRAM. For higher quality you can use the resize or original strategy at the expense of using more VRAM and slower results.

The plugins make it easy to upscale images (2x and 4x are available), apply face correction, and remove backgrounds although it’s a shame there’s no control over the strength applied when using GFPGAN face correction.

Support: GitHub Code Repository
Developer: Sanster
License: Apache License 2.0

Lama Cleaner is written in Python and TypeScript. Learn Python with our recommended free books and free tutorials. Learn TypeScript with our recommended free books and free tutorials.

Artificial intelligence icon For other useful open source apps that use machine learning/deep learning, we’ve compiled this roundup.

Pages in this article:
Page 1 – Introduction and Installation
Page 2 – In Operation and Summary

Notify of

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Newest Most Voted
Inline Feedbacks
View all comments
7 months ago


Thank you so much for this wonderful explanation on how to install Lama Cleaner in Linux!

I was wondering after installing Lama if there is any option or way on using Lama completely from the command line ONLY to process the images, etc? Not using the GUI like the web interface or desktop, etc.

Look forward, thank you!

7 months ago
Reply to  Don

I use G’MIC for inpainting from the command-line.

2 months ago

How would I create a menu shortcut to launch this? I can get lama cleaner to launch in a venv fine, but then how do I get it to open firefox into the appropriate link? I am running arch with plasma 6