Shape-Guided Diffusion with Inside-Outside Attention
Dong Huk Park, Grace Luo, Clayton Toste, Samaneh Azadi, Xihui Liu, Maka Karalashvili, Anna Rohrbach, Trevor Darrell
TL;DR
Shape-Guided Diffusion tackles the challenge of preserving precise object silhouettes during text-guided edits by introducing Inside-Outside Attention, a training-free mechanism that constrains cross- and self-attention maps to distinguish inside (object) from outside (background) regions during both inversion and generation. The approach builds on a frozen latent diffusion model and can use provided masks or inferred shapes from prompts, achieving state-of-the-art shape faithfulness on the MS-COCO ShapePrompts benchmark while maintaining text alignment and image realism. Quantitative metrics ($mIoU$, $KW\text{-}mIoU$, $FID$, $CLIP$) and annotator ratings confirm substantial improvements over prior methods, with the added ability to perform intra-/inter-class, inside/outside, and background edits via a training-free, inference-time procedure. The work also introduces a dedicated ShapePrompts benchmark, provides extensive ablations, and demonstrates robustness to inferred masks, offering a practical tool for shape-aware diffusion-based editing in real-world workflows.
Abstract
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.
