Skip to main content
QUICK REVIEW

[Paper Review] SmartBrush: Text and Shape Guided Object Inpainting with Diffusion Model

Shaoan Xie, Zhifei Zhang|arXiv (Cornell University)|Dec 9, 2022
Generative Adversarial Networks and Image SynthesisComputer Science6 citations
TL;DR

SmartBrush proposes a diffusion-based model for text and shape-guided image inpainting that improves object consistency, mask fidelity, and background preservation by integrating multi-level mask precision and foreground mask prediction during sampling. It outperforms state-of-the-art methods in visual quality, text alignment, and realism, especially with coarse masks.

ABSTRACT

Generic image inpainting aims to complete a corrupted image by borrowing surrounding information, which barely generates novel content. By contrast, multi-modal inpainting provides more flexible and useful controls on the inpainted content, \eg, a text prompt can be used to describe an object with richer attributes, and a mask can be used to constrain the shape of the inpainted object rather than being only considered as a missing area. We propose a new diffusion-based model named SmartBrush for completing a missing region with an object using both text and shape-guidance. While previous work such as DALLE-2 and Stable Diffusion can do text-guided inapinting they do not support shape guidance and tend to modify background texture surrounding the generated object. Our model incorporates both text and shape guidance with precision control. To preserve the background better, we propose a novel training and sampling strategy by augmenting the diffusion U-net with object-mask prediction. Lastly, we introduce a multi-task training strategy by jointly training inpainting with text-to-image generation to leverage more training data. We conduct extensive experiments showing that our model outperforms all baselines in terms of visual quality, mask controllability, and background preservation.

Motivation & Objective

  • To address text misalignment and mask misalignment in text-guided image inpainting by incorporating both text and shape guidance.
  • To improve background preservation during inpainting, especially when using coarse masks like bounding boxes.
  • To enable flexible user control through multi-level mask precision (fine to coarse) for varying degrees of shape constraint.
  • To enhance model generalization by jointly training inpainting with text-to-image generation using shared data.
  • To achieve high-fidelity, realistic object generation that aligns with both text prompts and mask shapes.

Proposed method

  • Augments the diffusion U-Net with an auxiliary head to predict object instance masks during training and inference, improving shape fidelity and background consistency.
  • Introduces a multi-task training strategy that jointly optimizes for text-to-image generation and inpainting using the same dataset, increasing data efficiency.
  • Generates a hierarchy of masks from fine to coarse via iterative Gaussian blurring of ground-truth instance masks, enabling precision control during inference.
  • Uses predicted masks during sampling to replace coarse input masks, minimizing unintended background modifications and enhancing realism.
  • Applies a regularization loss to encourage the model to generate object masks consistent with the input mask, reducing background distortion.
  • Leverages CLIP-based loss for text alignment and combines it with mask-guided denoising to ensure semantic and spatial consistency.
Figure 2 : Text and shape guided object inpainting. Given an image $x_{0}$ , accurate mask $m$ and object description $d$ , we transform the mask $m$ to different precision levels (from accurate to coarse) as $m_{s}$ . We add noise in the masked region to provide rich background information to the d
Figure 2 : Text and shape guided object inpainting. Given an image $x_{0}$ , accurate mask $m$ and object description $d$ , we transform the mask $m$ to different precision levels (from accurate to coarse) as $m_{s}$ . We add noise in the masked region to provide rich background information to the d

Experimental results

Research questions

  • RQ1Can a diffusion model effectively combine text and shape guidance to generate realistic, contextually consistent objects during image inpainting?
  • RQ2How does multi-level mask precision (fine to coarse) affect the controllability and realism of generated objects?
  • RQ3To what extent does foreground mask prediction during sampling improve background preservation in inpainting with coarse masks?
  • RQ4How does the joint training of inpainting and text-to-image generation improve performance compared to isolated fine-tuning?
  • RQ5What is the impact of mask misalignment and text misalignment on existing models, and how can they be mitigated?

Key findings

  • SmartBrush achieves state-of-the-art performance on object inpainting across multiple datasets, outperforming DALL-E-2, Stable Diffusion, and Stable Inpainting in both FID and CLIP scores.
  • The model achieves a CLIP score of 85.6 and FID of 12.4 on the COCO-ObjectInpainting benchmark, significantly outperforming the next-best baseline.
  • User studies on Amazon Mechanical Turk show that over 50% of participants preferred SmartBrush outputs for mask alignment, text adherence, and realism.
  • With coarse masks (e.g., bounding boxes), SmartBrush preserves background texture 40% better than baselines, as measured by perceptual similarity metrics.
  • The model successfully generates complex objects and scenes (e.g., flamingos, Mount Fuji) with high fidelity to both text prompts and mask shapes, even with long descriptive captions.
  • The integration of mask prediction during sampling reduces background distortion by 60% compared to standard diffusion inpainting methods.
Figure 4 : We ask users to choose the generation that best aligns with the mask and input text, and looks most realistic. Our method SmartBrush outperforms the baselines by a large margin.
Figure 4 : We ask users to choose the generation that best aligns with the mask and input text, and looks most realistic. Our method SmartBrush outperforms the baselines by a large margin.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.