LaMa
LaMa fills masked regions of an image.
- Tasks
- restoration
- Install
pip install "libreyolo[onnx]"- Support tier
- Inference only, since v1.6.0. Predict, validate and export only. Training features do not apply.
- Licenses
- Code MIT, weights Apache-2.0. Commercial use
Install
pip install "libreyolo[onnx]"Predict
from libreyolo import LibreYOLO, SAMPLE_IMAGE model = LibreYOLO("LibreLaMab-restore.pt", device="cpu")import numpy as npfrom 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] = 255result = 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
from libreyolo import LibreYOLO model = LibreYOLO("LibreLaMab-restore.pt", device="cpu")# Restore dataset YAML with paired inputs/targets folders plus a mask_dir keymetrics = model.val(data="path/to/your/restore.yaml", workers=0)print(metrics)Use the dataset format for this task. Validation explains the dataset requirements and returned metrics.
Checkpoints
| File | Weights license |
|---|---|
| Restoration | |
| LibreLaMab-restore.pt | apache-2.0 |
Every file above exists in the LibreYOLO org today and downloads on first use.
Licensing
Check the license on the Hugging Face repository of the specific weights you download. Every checkpoint in the LibreYOLO org carries one, and they are not always the same across a family. That repository is the authoritative source; the summary below describes what applied when this page was last verified.
This is a description of the licenses involved, not legal advice. If the answer matters commercially, read the licenses yourself and take your own counsel.
- Original work
- LaMa, Samsung Research
- Upstream license
- Apache-2.0
- Upstream source
- github.com/advimman/lama
- LibreYOLO code
- MIT
- Weights
- Apache-2.0, republished at huggingface.co/LibreYOLO
- Interpretation
- The mirrored ONNX artifact carries the OpenCV publisher's Apache-2.0 declaration.
Citation
@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 the authors' citation block at raw.githubusercontent.com/advimman/lama/main/README.md.