🍇 [Official Project Page] 🍎[LaMa Cleaner]
We use the highly organized code lama-cleaner to simplify the demo code for users.
Modern image inpainting systems, despite the significant progress, often struggle with large missing areas, complex geometric structures, and high-resolution images. We find that one of the main reasons for that is the lack of an ef-fective receptive field in both the inpainting network andthe loss function. To alleviate this issue, we propose anew method called large mask inpainting (LaMa). LaM ais based on: a new inpainting network architecture that uses fast Fourier convolutions, which have the image-widereceptive field a high receptive field perceptual loss; large training masks, which unlocks the potential ofthe first two components. Our inpainting network improves the state-of-the-art across a range of datasets and achieves excellent performance even in challenging scenarios, e.g.completion of periodic structures. Our model generalizes surprisingly well to resolutions that are higher than thoseseen at train time, and achieves this at lower parameter & compute costs than the competitive baselines.
- LaMa Demo with lama-cleaner
- LaMa with SAM
- LaMa with GroundingDINO
- LaMa with Grounded-SAM
We're using lama-cleaner for this demo, install it as follows:
pip install lama-cleaner
Please refer to lama-cleaner for more details.
Then install Grounded-SAM follows Grounded-SAM Installation for some extension demos.
Here we provide the demos for LaMa
cd playground/LaMa
python lama_inpaint_demo.py
with the highly organized code lama-cleaner, this demo can be done in about 20 lines of code. The result will be saved as lama_inpaint_demo.jpg
:
cd playground/LaMa
python sam_lama.py
Tips To make it better for inpaint, we should dilate the mask first to make it a bit larger to cover the whole region (Thanks a lot for Inpaint-Anything and Tao Yu for this)
The original mask
and dilated mask
are shown as follows:
And the inpaint result will be saved as sam_lama_demo.jpg
:
Input Image | SAM Output | Dilated Mask | LaMa Inpaint |
---|---|---|---|