Abstract
MagicEraser is a specialized diffusion-based framework designed for the task of object erasure—removing specific objects and replacing them with seamless, harmonious backgrounds. By integrating a novel data construction strategy with semantics-aware attention control, the framework prevents the common issue of "hallucinating" new objects into the empty space. MagicEraser demonstrates superior performance over existing state-of-the-art academic models and commercial tools like Adobe’s Generative Fill.
Introduction
While image inpainting has been a long-standing research area, the specific sub-task of object erasure presents unique challenges. Traditional GAN-based methods, such as LaMa, are computationally efficient but often struggle with complex textures, leaving behind blurry artifacts. Conversely, modern Diffusion Models (e.g., Stable Diffusion) are frequently "too creative," hallucinating new foreground objects in the masked area instead of generating a clean background. This "foreground bias" often requires complex manual prompting to overcome.
Methodology
MagicEraser addresses these issues through a two-phase pipeline that balances structural guidance with high-quality generative refinement.
Stage 1: Content Initialization
To avoid the unpredictability of starting from pure Gaussian noise, MagicEraser utilizes a traditional GAN-based inpainter to generate a rough "draft" of the background. This draft is then partially noised (denoising strength $s=0.9$), providing the diffusion model with a structural prior that acts as a regularizer against unwanted creativity.
Stage 2: Controllable Generation
This stage introduces two key modules to ensure the generated content remains strictly background-oriented:
- Prompt Tuning: Using Textual Inversion and LoRA, the model is trained on a learnable embedding $R_*$ representing "background completion." This allows the system to generate contextually appropriate content (e.g., "A photo of $R_*$ sky") automatically.
- Semantics-Aware Attention Refocus: This training-free module leverages panoptic segmentation to identify "positive" (background) and "negative" (foreground object) regions. It modifies internal self-attention maps to force the in-mask pixels to attend to background information while ignoring remnants of the erased object.
Datasets and Evaluation
The authors introduced the Object-Level Removal Dataset (OLRD) to bridge the gap in realistic training data. By shifting segmented objects from the Places2 dataset to new background locations, they created training pairs with known ground truths.
Quantitative evaluations on the RealHM dataset show that MagicEraser achieves a PSNR of 23.620 dB, significantly outperforming Stable Diffusion Inpainting (21.758 dB) and LaMa (19.053 dB). Qualitative results confirm that MagicEraser is superior at maintaining texture consistency without leaving "ghost" remnants of the deleted object.
Conclusion
MagicEraser demonstrates that semantic guidance and structural priors are essential for professional-grade object erasure. While currently limited by the $512 \times 512$ resolution of its base model (Stable Diffusion v1.5), the approach provides a robust framework for suppressing generative hallucinations in image editing tasks.
Summary updated