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

In essence, Machine Learning is the practice of using algorithms to parse data, learn insights from that data, and then make a determination or prediction. The machine is ‘trained’ using huge amounts of data.

Lama Cleaner is a fully self-hostable inpainting tool powered by state-of-the-art AI models. This software lets you remove unwanted objects, defects, people from your pictures or erase and replace anything from your pictures. There’s also support for erase and replace courtesy of Stable Diffusion and Paint by Example.

The software is free and open source written mostly in Python.


To avoid polluting your system, we recommend installing Lama Cleaner with Anaconda, a distribution of the Python and R programming languages for scientific computing, that aims to simplify package management and deployment. Alternatively, use Miniconda (a minimal installer for conda).

$ wget

Run the shell script:

$ bash

You’ll be asked to accept Anaconda’s license and whether to initialize Anaconda3 by running conda init. For changes to take effect, close and re-open your current shell.

Create a conda environment, and activate it.

$ conda create --name lama-cleaner
$ conda activate lama-cleaner

Now we’re ready to install Lama Cleaner using pip.

$ pip install lama-cleaner

We also recommend installing plugins for post-processing as they offer awesome functionality. We’ve previously written reviews for the first three plugins.

  • Rembg: background segmentation tool using machine learning that removes the backgrounds from images;
  • RealESRGAN – creates practical algorithms for general image/video restoration;
  • GFPGAN – impressive software for restoring poor quality images of faces;
  • RestoreFormer: Face Restoration with cross-attention layer to learn fully-spatial interactions between corrupted queries and high-quality key-value pairs.

The plugins are also installed with pip: For example, if you want to install the first three plugins, issue the commands:

$ pip install rembg
$ pip install realesrgan
$ pip install gfpgan

The models used by Lama Cleaner and its plugins are downloaded automatically on their first invocation.

This is cross-platform software.

Next page: Page 2 – In Operation and Summary

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
6 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!

6 months ago
Reply to  Don

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

29 days 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