NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Inpaint Anything: Segment Anything Meets Image Inpainting

Tao Yu, Runseng Feng, Ruoyu Feng, Jinming Liu, Xin Jin, Wenjun Zeng, Zhibo ChenarXiv 2023 · DOI

Abstract

"Inpaint Anything" (IA) introduces a novel "click and fill" paradigm for image editing by orchestrating the Segment Anything Model (SAM) with advanced inpainting and generative AI models. This pipeline enables users to remove, fill, or replace any object within an image through simple point-and-click interactions and text prompts, bypassing the traditional requirement for manual mask creation.

Introduction

Image inpainting—the process of reconstructing missing or removed portions of an image—has historically been hindered by two primary challenges. First, users must provide precise masks for the target areas, a task that is often labor-intensive and time-consuming. Second, conventional inpainting models are typically restricted to "filling with context," relying on surrounding pixels to infer missing content rather than generating novel objects.

While recent advancements in Generative AI (AIGC), such as Stable Diffusion, have enabled the creation of diverse content, integrating these models into a precise, user-friendly editing workflow remains difficult. Inpaint Anything addresses these challenges by proposing a mask-free approach where a single click defines the object for manipulation.

Methodology

The Inpaint Anything framework adopts a "composable AI" strategy, building a powerful pipeline by integrating three specialized foundation models rather than training a new end-to-end architecture.

The Inpaint Anything pipeline leverages SAM for segmentation and LaMa/SD for inpainting.
  1. Segment Anything Model (SAM): SAM serves as the initial stage, generating high-quality segmentation masks from user clicks. This eliminates the need for manual mask painting.
  2. LaMa (Large Mask Inpainting): For the "Remove Anything" task, the system employs LaMa to fill the void left by the segmented object. LaMa excels at utilizing global context to produce visually coherent backgrounds.
  3. Stable Diffusion (SD): For "Fill Anything" and "Replace Anything," the pipeline leverages Stable Diffusion. In the "Fill" task, SD generates new content within the SAM-generated mask based on text prompts. In the "Replace" task, the foreground object is preserved while SD generates an entirely new background.

The authors emphasize the importance of mask dilation to ensure smooth boundaries and proper blending between the generated content and the original image.

Experiments and Results

The system was evaluated using standard benchmarks such as the COCO dataset and the LaMa test set, as well as real-world mobile photography. Since the approach relies on pre-trained foundation models, the evaluation focuses on qualitative performance across various editing tasks.

Qualitative results for various tasks including Fill Anything and Replace Anything.

Key results include:

  • Remove Anything: Successful erasure of diverse objects (e.g., animals, people) from complex backgrounds with high fidelity.
  • Fill Anything: Realistic object replacement, such as substituting a bus with a sports car or a donut with a camera lens, while maintaining consistent lighting and perspective.
  • Replace Anything: Seamless background swapping while preserving the integrity of the central subject.
  • Technical Robustness: The pipeline demonstrates the ability to handle high-resolution images (up to 2K) and varying aspect ratios.

Discussion and Conclusion

Inpaint Anything demonstrates the power of "Composable AI," showing how specialized expert models can be combined to solve complex tasks without the overhead of training multi-modal giants. Key insights include the necessity of mask dilation for seamless blending and the effectiveness of simple text prompts for generative inpainting.

Future work may address limitations such as image matting for semi-transparent objects, more nuanced object manipulation, and optimization for real-time performance on mobile devices. The project is open-source, providing a foundation for further community-driven innovation in AI-assisted image editing.

Summary updated

BibTeX
@misc{yu2023inpaint,
  author = {Tao Yu and Runseng Feng and Ruoyu Feng and Jinming Liu and Xin Jin and Wenjun Zeng and Zhibo Chen},
  title = {{Inpaint Anything: Segment Anything Meets Image Inpainting}},
  year = {2023},
  eprint = {2304.06790},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2304.06790},
}
Figure