Source-linked AI summary
Magicremover: Tuning-free Text-guided Image inpainting with Diffusion Models
Siyuan Yang, Lu Zhang, Liqian Ma, Yu Liu, JingJing Fu, You He
TL;DR
Image inpainting faces costly training and binary-mask difficulties around complex or transparent objects. MagicRemover uses pretrained diffusion attention and classifier optimization for text-guided object removal and restoration. The authors report superior performance over state-of-the-art methods in quantitative evaluation and a user study, while noting that small objects such as raindrops cannot be erased.
Problem
Inpainting faces costly realistic-data collection and training, while user-defined binary masks are difficult for unclear boundaries and unsuitable for semi-transparent regions.
Source: §1 · p. 2Method
MagicRemover uses pretrained diffusion attention to guide text-instructed object removal and occluded-region restoration, with classifier optimization to improve denoising stability in fewer sampling steps.
Source: §1 · p. 2Results
The authors report that MagicRemover outperforms state-of-the-art methods in quantitative evaluation and user study.
Source: §5 · p. 9Takeaways & Limitations
The method provides tuning-free text-guided object removal using pretrained diffusion, without auxiliary model finetuning or supervision.
Source: §1 · p. 2, §5 · p. 9Small objects such as raindrops cannot be erased because Stable Diffusion’s encoder reduces image resolution to one-eighth in the latent space used for guidance.
Source: §5 · p. 10
Abstract
from arXiv · showhide
Image inpainting aims to fill in the missing pixels with visually coherent and semantically plausible content. Despite the great progress brought from deep generative models, this task still suffers from i. the difficulties in large-scale realistic data collection and costly model training; and ii. the intrinsic limitations in the traditionally user-defined binary masks on objects with unclear boundaries or transparent texture. In this paper, we propose MagicRemover, a tuning-free method that leverages the powerful diffusion models for text-guided image inpainting. We introduce an attention guidance strategy to constrain the sampling process of diffusion models, enabling the erasing of instructed areas and the restoration of occluded content. We further propose a classifier optimization algorithm to facilitate the denoising stability within less sampling steps. Extensive comparisons are conducted among our MagicRemover and state-of-the-art methods including quantitative evaluation and user study, demonstrating the significant improvement of MagicRemover on high-quality image inpainting. We will release our code at https://github.com/exisas/Magicremover.
1 INTRODUCTION
Image inpainting must produce realistic content consistent with visible regions, but existing approaches face costly training and binary-mask limitations on complex or transparent objects. MagicRemover uses pretrained diffusion attention for text-guided removal and proposes classifier optimization, with experiments reporting superior performance on soft-boundary and semi-transparent cases.
1 INTRODUCTION
- Binary masks are difficult to draw around complex or unclear boundaries and treat transparent pixels like background, risking destruction of original background regions.Soft alpha mattes can separate semi-transparent layers, but users cannot feasibly label them on real images.Source: §1 · p. 2
- Training-based inpainting relies on synthesized masked image pairs, but data synthesis and training are costly and may generalize poorly across diverse distributions.The paper also notes that synthetic corrupted regions differ from real-world user needs.Source: §1 · p. 2
- MagicRemover is a tuning-free, text-guided inpainting framework that uses pretrained diffusion attention to remove instructed objects and restore occluded regions.It projects the input into latent space, uses cross-attention guidance for soft removal and background inpainting, and self-attention to preserve similarity with the original image.Source: §1 · p. 2
- The method combines attention-based guidance with classifier optimization to improve inpainting capability and stability using fewer diffusion sampling steps.The method is designed to avoid auxiliary model finetuning or supervision.Source: §1 · p. 2
- Quantitative evaluation and a user study report superior performance on object removal with soft boundaries or semi-transparent texture.The supplied passages do not provide specific metric values.Source: §1 · p. 2
2 RELATED WORK
The related work reviews diffusion generation and guidance, then situates MagicRemover among inpainting methods. It contrasts its attention-guided, tuning-free approach with methods that train on synthesized paired data.
2.1 DIFFUSION MODELS
- Diffusion models learn to reverse progressively added Gaussian noise, while DDIM modifies sampling to control randomness and latent diffusion performs denoising in encoded image space.Latent diffusion maps images to and from a latent space with an encoder and decoder.Source: §2.1 · p. 3
2.2 CLASSIFIER GUIDANCE
- Classifier guidance adjusts predicted noise using a classifier gradient, and self-guidance replaces that classifier signal with gradients from an editing signal.The paper frames its own goal as designing an effective energy function for training-free, text-guided inpainting.Source: §2.2 · p. 3
2.3 IMAGE INPAINTING
- Prior inpainting spans patch propagation, CNN/GAN methods, and diffusion attempts; Inst-Inpaint instead retrains diffusion on synthesized paired data, unlike MagicRemover’s pretrained-attention guidance.The paper describes its approach as tuning-free and requiring no extra model tuning or data.Source: §2.3 · p. 4
3 METHOD
MagicRemover uses pretrained diffusion models and textual instructions for tuning-free object removal, combining image-text alignment, attention guidance, and classifier optimization. Its guidance is designed to erase target objects while preserving surrounding content and to stabilize denoising with fewer sampling steps.
3.1 OVERVIEW
- MagicRemover uses pretrained Stable Diffusion without extra training or finetuning, combining attention guidance and classifier optimization for text-guided object removal and restoration.The framework projects the input image and instruction into latent space, then runs reconstruction and inpainting branches in parallel.Source: §3.1 · p. 4
3.2 TEXT-IMAGE ALIGNMENT
- Null-text inversion projects the image and text into latent space, optimizing null-text embeddings so the model can reconstruct the image and localize the target word.The prompt may range from an object label to a detailed scene description.Source: §3.2 · p. 5
3.3 ATTENTION GUIDANCE
- The method uses a target word’s cross-attention map as a spatial response and guides its reduction to erase the corresponding object.Rather than forcing a zero response, it targets the map’s top-20% values; λ controls erasure strength and defaults to 0.8.Source: §3.3 · p. 5
- Attention guidance reweights perturbations by cross-attention to suppress background changes, and supports multiword targets and an optional mask for hard-to-describe instances.Reconstruction-branch self-attention keys and values are reused in the inpainting branch to help preserve image similarity.Source: §3.3 · pp. 5–6
3.4 CLASSIFIER OPTIMIZATION
- Classifier optimization inserts updates to the noisy latent at a fixed timestep, allowing more optimization steps, fewer sampling steps, and reduced Null-text inversion time.It uses different noise sources for predicting x0 and the direction toward xt; the authors report improved editing results with noise before and after perturbation, respectively.Source: §3.4 · pp. 6–7
4 EXPERIMENTS
MagicRemover is evaluated against mask-guided and text-guided inpainting methods, with quantitative, user-study, and visual comparisons. Ablations examine the contributions of attention-guidance components and classifier optimization.
4.1 IMPLEMENTATION DETAILS
- Attention guidance starts at 100 < t < t2, with classifier optimization added for t1 < t < t2; default t1 and t2 are 500 and 800.Earlier guidance strengthens erasure but can alter image tone and background because its attention maps are less accurate.Source: §4.1 · p. 7, Figure 4 · p. 7
4.2 COMPARISON WITH STATE-OF-THE-ART METHODS
- MagicRemover has slightly lower FID than SD-Inpaint and LaMa, better FID than Inst-Inpaint, and receives the majority of user-study votes.The user study involved 30 volunteers evaluating 80 samples.Source: §4.2 · p. 8, Table 1 · p. 8
- Existing methods struggle to preserve backgrounds when removing semi-transparent objects, find suitable masks, and remove all objects from masked regions.Inst-Inpaint also fails to obtain appropriate masks for objects with soft boundaries.Source: §4.2 · pp. 8–9
4.3 ABLATION STUDY
- Self-attention guidance maintains similarity to the original image, while relaxing constraints and reweight perturbation further ensure background consistency.Figure 6 compares outputs with each component removed against the final output.Source: §4.3 · p. 9, Figure 6 · p. 9
- Classifier optimization enhances erasure in the 50-step comparison by adding an optimization step at every timestep within t1 < t < t2.The unoptimized comparisons use 50, 100, and 200 sampling steps.Source: §4.3 · p. 9, Figure 7 · p. 9
5 CONCLUSION
MagicRemover uses pretrained diffusion for text-instructed object removal, combining attention guidance with classifier optimization. The authors report superiority over state-of-the-art methods, while noting that small objects such as raindrops cannot be erased with their latent-space guidance.
5 CONCLUSION
- MagicRemover uses pretrained diffusion for flexible object removal from textual instructions.The method is described as tuning-free.Source: §5 · p. 9
- Attention guidance and classifier optimization constrain diffusion denoising to erase objects and restore occluded areas.Source: §5 · p. 9
- Small objects such as raindrops cannot be erased because Stable Diffusion’s encoder reduces image resolution to one-eighth in latent space.Combining encoder and decoder features for guidance is proposed as future work.Source: §5 · p. 10
A.1 DETAIL OF OUR SAMPLING ALGORITHM
The sampling algorithm takes an input image and caption, then runs diffusion steps with optimization scheduled at selected timesteps.
A.1 DETAIL OF OUR SAMPLING ALGORITHM
- The algorithm is parameterized by a denoising model, input image, caption, number of diffusion steps, optimization-time list, and iteration count.These are the parameters and inputs listed for Algorithm 1.Source: §A.1 · p. 13
- At each scheduler timestep, the algorithm combines caption-conditioned and unconditioned noise predictions for guidance.The listed prediction uses both the caption y and an unconditioned input.Source: §A.1 · p. 13
- At selected timesteps, the algorithm runs an inner optimization loop for N iterations before continuing.The listed steps end the loop and its timestep condition.Source: §A.1 · p. 13
A.2 COMPARISON WITH PROMPT-TO-PROMPT
The section tests whether Prompt-to-Prompt attention edits can remove objects during reconstruction and denoising. The tested combination with Null-text inversion does not remove the target cleanly.
A.2 COMPARISON WITH PROMPT-TO-PROMPT
- Prompt-to-Prompt combined with Null-text inversion is unable to remove the target object cleanly.The experiments tested both P2P refine and reweighting during denoising.Source: §A.2 · p. 13
- P2P refine removes the target object's word from the text condition, while P2P reweighting sets its cross-attention value to zero during denoising.Both variants are tested after text-image alignment.Source: §A.2 · p. 13
- The comparison asks whether removing the target word or zeroing its attention can achieve object removal.The study presents partial results in Figure 8.Source: §A.2 · p. 13
A.3 INVESTIGATE THE INFLUENCE OF LAMBDA
The section examines how λ affects object removal. Lower λ values make erasure cleaner but may alter image color tone or background.
A.3 INVESTIGATE THE INFLUENCE OF LAMBDA
- Lower λ values yield cleaner object erasure but may change the image's color tone or background.The passage relates cross-attention-map values to relevance to the text.Source: §A.3 · p. 13
- Users may need to adjust λ to achieve the best results.The passage presents this adjustment in the context of the erasure-quality and image-change trade-off.Source: §A.3 · p. 13
- Figure 9 shows the influence of different λ values.The passage does not report specific values or outcomes for individual settings.Source: §A.3 · p. 13
A.4 THE FUNCTION OF MASK
The section addresses removal when objects are difficult to describe or distinguish through text. It describes alternative equation choices and examples for these cases.
A.4 THE FUNCTION OF MASK
- For more precise results, the section offers an additional term as an alternative, and reports no significant differences between the two methods.The added term is applied outside the mask; the passage refers to Eq. 9.Source: §A.4 · p. 14
- For instances difficult to distinguish through text, the method replaces Eq. 9 with Eq. 13.Figure 10 presents examples for this case and for objects difficult to describe with text.Source: §A.4 · pp. 13–14
- The figure panels label the input image, manual mask, and result.These labels appear in both provided panel descriptions.Source: §A.4 · p. 14
- Figure 10's examples use the prompts “black stains on a photo of a man” and “a photo of two persons.”The figure presents the two special situations discussed in the section.Source: §A.4 · pp. 13–14, Figure 10 · p. 14
A.5 MORE RESULTS
Visual comparisons show MagicRemover performing consistently better than other methods on natural and COCO images. The section also presents method comparisons and a screenshot of the user study.
A.5 MORE RESULTS
- MagicRemover performs consistently better than other methods on natural and COCO images in the visual comparisons.The comparisons are shown in Figures 11 and 12.Source: §A.5 · p. 15
- Figure 11 contrasts manual-mask Stable inpainting and LaMa with text-only MagicRemover; Inst-Inpaint receives a “remove the...” prompt.Source: Figure 11 · p. 16
- Figure 12 presents COCO visual comparisons using text-based conditions, with Inst-Inpaint prompted by “remove...”.Source: Figure 12 · p. 17
- Figure 13 shows a screenshot of the user study.Source: Figure 13 · p. 18