[Paper Review] Shape-Guided Diffusion with Inside-Outside Attention
This paper proposes Shape-Guided Diffusion, a training-free method that enhances text-to-image diffusion models for shape-aware image editing by introducing an Inside-Outside Attention mechanism during inversion and generation. The method improves shape faithfulness in object editing without sacrificing text alignment or image realism, achieving state-of-the-art performance on a new MS-COCO-based benchmark with 2.7x higher annotator preference than the next best baseline.
We introduce precise object silhouette as a new form of user control in text-to-image diffusion models, which we dub Shape-Guided Diffusion. Our training-free method uses an Inside-Outside Attention mechanism during the inversion and generation process to apply a shape constraint to the cross- and self-attention maps. Our mechanism designates which spatial region is the object (inside) vs. background (outside) then associates edits to the correct region. We demonstrate the efficacy of our method on the shape-guided editing task, where the model must replace an object according to a text prompt and object mask. We curate a new ShapePrompts benchmark derived from MS-COCO and achieve SOTA results in shape faithfulness without a degradation in text alignment or image realism according to both automatic metrics and annotator ratings. Our data and code will be made available at https://shape-guided-diffusion.github.io.
Motivation & Objective
- To address the limitation in existing text-to-image diffusion models that fail to preserve object shape during editing, especially when replacing or modifying objects.
- To develop a training-free method that enforces shape constraints during both inversion and generation using attention mechanisms.
- To evaluate shape faithfulness in editing tasks where the object's silhouette and spatial structure must be preserved.
- To demonstrate effectiveness on both manually provided and automatically inferred object masks, including complex cases like reflections and overlapping instances.
- To establish a new benchmark, ShapePrompts, for evaluating shape-guided editing on MS-COCO.
Proposed method
- Introduces an Inside-Outside Attention mechanism that modifies cross- and self-attention maps to restrict object tokens to attend only to pixels within the object mask (inside) and background tokens to the outside.
- Applies the attention constraint during both DDIM inversion and image generation, enabling better preservation of shape information in the latent noise.
- Uses a frozen pretrained text-to-image diffusion model, avoiding fine-tuning or retraining.
- Employs a soft shape constraint on attention maps, with ablations showing improved performance over hard constraints.
- Leverages DDIM inversion to recover noise that better preserves the source image’s shape, which is then refined using the attention constraint.
- Supports both object-level and background-level edits, including simultaneous inside-outside edits with separate text prompts.
Experimental results
Research questions
- RQ1Why do existing text-to-image diffusion models fail to preserve object shape during editing, especially when replacing or modifying objects?
- RQ2Can a training-free method improve shape faithfulness in image editing by constraining attention maps during inversion and generation?
- RQ3How does Inside-Outside Attention compare to baseline methods like 'copy background' or finetuning in preserving object shape and realism?
- RQ4To what extent can the method generalize to automatically inferred masks, such as those from text prompts or complex scene structures?
- RQ5Can the method support simultaneous inside and outside edits while maintaining spatial coherence and object-background relationships?
Key findings
- Our method achieves state-of-the-art shape faithfulness on the MS-COCO ShapePrompts benchmark, with a 9.5-point increase in KW-mIoU over the ablated version without Inside-Outside Attention.
- Annotators selected our method as the best edit 43% of the time, 2.7x more frequently than the next best baseline, P2P + Shape.
- The method maintains high image realism and text alignment, with 48% of annotators rating it superior in these aspects—1.3x and 1.9x better than the most competitive baselines.
- Even with only shape guidance applied in the first half of generation, Inside-Outside Attention provides a stronger shape signal than 'copy background' methods, which rely on weak shape signals in early timesteps.
- The ablation without Inside-Outside Attention still outperforms all baselines except P2P + Shape, confirming the critical role of both DDIM inversion and the attention mechanism.
- The method successfully performs diverse edits, including intra- and inter-class object transformations, background edits, and simultaneous inside-outside edits, preserving spatial and structural relationships from the source image.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.