lama-cleaner / README.md
Nekochu's picture
Init
b4daad9 verified

A newer version of the Gradio SDK is available: 6.13.0

Upgrade
metadata
title: Lama-Cleaner
emoji: 🧹
colorFrom: green
colorTo: blue
sdk: gradio
sdk_version: 6.3.0
app_file: app.py
pinned: false
license: apache-2.0
tags:
  - image-inpainting
  - object-removal
  - lama
  - mcp-server
short_description: Remove unwanted objects from images with LaMa

Lama-Cleaner: Image Inpainting

Remove unwanted objects from your images using LaMa (Large Mask Inpainting).

Features

  • Object Removal - Remove any unwanted object, person, or defect from images
  • LaMa Model - Uses state-of-the-art LaMa inpainting model
  • CPU Inference - Runs on HuggingFace Spaces free tier
  • CLI Support - Command-line interface for batch processing

Usage

  1. Upload an image
  2. Draw over the area you want to remove (white brush = mask)
  3. Click "Remove Object"

Tips

  • Draw the mask slightly larger than the object for best results
  • LaMa works best for small to medium sized areas
  • For complex backgrounds, you may need to adjust the mask

API

Python Client

from gradio_client import Client, handle_file

client = Client("Luminia/lama-cleaner")

# Note: ImageEditor data format
result = client.predict(
    editor_data={
        "background": handle_file("image.png"),
        "layers": [handle_file("mask.png")],
        "composite": None
    },
    api_name="/inpaint"
)
print(result)  # (output_image, status)

REST API (curl)

# Step 1: Submit job
curl -X POST "https://luminia-lama-cleaner.hf.space/gradio_api/call/inpaint" \
  -H "Content-Type: application/json" \
  -d '{"data": [{"background": "...", "layers": [...]}]}'

# Step 2: Get result (SSE stream)
curl "https://luminia-lama-cleaner.hf.space/gradio_api/call/inpaint/{event_id}"

MCP (Model Context Protocol)

This Space supports MCP for AI assistants (Claude Desktop, Cursor, VS Code).

  1. Click MCP badge → Add to MCP tools
  2. The inpaint tool becomes available

Tool schema:

{
  "name": "inpaint",
  "parameters": {
    "editor_data": {"type": "object", "description": "ImageEditor data with background and mask layers"}
  },
  "returns": ["image", "string"]
}

MCP Config:

{
  "mcpServers": {
    "lama-cleaner": {"url": "https://luminia-lama-cleaner.hf.space/gradio_api/mcp/"}
  }
}

CLI Usage

# Inpaint with external mask
python app.py inpaint -i image.png -m mask.png -o output.png

Mask format: White (255) = area to inpaint, Black (0) = keep


Credits

Based on LaMa by SAIC-Moscow and lama-cleaner by Sanster.

Paper: Resolution-robust Large Mask Inpainting with Fourier Convolutions