Simple Lama Inpainting
raw JSON → 0.1.2 verified Sat May 09 auth: no python
A lightweight Python wrapper for LaMa image inpainting, supporting CPU and GPU inference. Current version 0.1.2, updated irregularly on PyPI.
pip install simple-lama-inpainting Common errors
error ModuleNotFoundError: No module named 'simple_lama_inpainting' ↓
cause Package not installed or misspelled (note hyphens vs underscores).
fix
Install with: pip install simple-lama-inpainting (with hyphens). Then import using underscores: from simple_lama_inpainting import SimpleLama
error RuntimeError: Input type (torch.FloatTensor) and weight type (torch.cuda.FloatTensor) should be the same ↓
cause Model loaded on CPU but input tensor on GPU (or vice versa).
fix
Ensure both model and input are on the same device. Use: simple_lama = SimpleLama(device='cuda') to force GPU inference.
error FileNotFoundError: [Errno 2] No such file or directory: 'big-lama.pt' ↓
cause Model file not found. The package tries to download it on first use but may fail due to network restrictions.
fix
Download the model manually from https://github.com/sanazelyari/simple-lama-inpainting/releases and set the path: LAMA_MODEL_PATH=/path/to/big-lama.pt python your_script.py
Warnings
breaking The package requires PyTorch (>=1.9) but does not install it automatically. You must install torch separately, with the appropriate CUDA version if using GPU. ↓
fix pip install torch torchvision --index-url https://download.pytorch.org/whl/cu118 (adjust CUDA version as needed)
gotcha The mask must be a binary image (black/white) where white indicates the area to inpaint. Using a non-binary mask may produce incorrect results. ↓
fix Ensure mask is converted to binary (0/255) before passing. Use: mask = mask.point(lambda x: 255 if x > 128 else 0)
gotcha The package downloads the model weights (~250MB) on first run. If your environment has no internet access, pre-download and set environment variable LAMA_MODEL_PATH. ↓
fix Set LAMA_MODEL_PATH=/path/to/big-lama.pt in your environment to use a local model file.
Imports
- SimpleLama wrong
from simple_lama_inpainting.simple_lama import SimpleLamacorrectfrom simple_lama_inpainting import SimpleLama
Quickstart
from simple_lama_inpainting import SimpleLama
from PIL import Image
simple_lama = SimpleLama()
image = Image.open('input.png')
mask = Image.open('mask.png')
result = simple_lama(image, mask)
result.save('output.png')