> This is the documentation for LibreYOLO 1.6.0. Current version: https://www.libreyolo.com/docs/models/lama

# LaMa
LaMa fills masked regions of an image.
Tasks: Restoration. Install: pip install "libreyolo[onnx]".
Verified against LibreYOLO v1.6.0.

## Install

```bash
pip install "libreyolo[onnx]"
```

## Predict

**Python**

```python
from libreyolo import LibreYOLO, SAMPLE_IMAGE

model = LibreYOLO("LibreLaMab-restore.pt", device="cpu")
import numpy as np
from PIL import Image

image = Image.open(SAMPLE_IMAGE).convert("RGB")
mask = np.zeros((image.height, image.width), dtype=np.uint8)
mask[image.height//3:2*image.height//3, image.width//3:2*image.width//3] = 255
result = model(image, mask=mask)
result.restored.save("inpainted.png")
```

Pass `mask=` for single-image inference: nonzero pixels mark the region to fill. The checkpoint embeds an ONNX graph and requires ONNX Runtime 1.18 or later. Training and export are not supported.


## Validate

**Python**

```python
from libreyolo import LibreYOLO

model = LibreYOLO("LibreLaMab-restore.pt", device="cpu")
# Restore dataset YAML with paired inputs/targets folders plus a mask_dir key
metrics = model.val(data="path/to/your/restore.yaml", workers=0)
print(metrics)
```

Use the dataset format for this task. [Validation](/docs/v1.6.0/train/validation) explains the dataset requirements and returned metrics.

## Checkpoints

| File | Input (px) | Task | Weights license |
| --- | --- | --- | --- |
| `LibreLaMab-restore.pt` |  | Restoration | apache-2.0 |

## Licensing

Check the license on the Hugging Face repository of the specific weights you download. That repository is authoritative and licenses are not always uniform across a family. This is a description of the licenses involved, not legal advice.

- Original work: LaMa, Samsung Research
- Upstream license: Apache-2.0
- Upstream source: https://github.com/advimman/lama
- LibreYOLO code: MIT
- Weights: Apache-2.0, republished at https://huggingface.co/LibreYOLO
- Interpretation: The mirrored ONNX artifact carries the OpenCV publisher's Apache-2.0 declaration.

## Citation

```bibtex
@article{suvorov2021resolution,
  title={Resolution-robust Large Mask Inpainting with Fourier Convolutions},
  author={Suvorov, Roman and Logacheva, Elizaveta and Mashikhin, Anton and Remizova, Anastasia and Ashukha, Arsenii and Silvestrov, Aleksei and Kong, Naejin and Goka, Harshith and Park, Kiwoong and Lempitsky, Victor},
  journal={arXiv preprint arXiv:2109.07161},
  year={2021}
}
```

Copied from https://raw.githubusercontent.com/advimman/lama/main/README.md


## LaMa architecture

- Base pinned ONNX architecture: [SVG](/diagrams/models/lama/b-inpaint.svg), [interactive diagram](/diagrams/models/lama/b-inpaint.html)
