Diffree: Text-Guided Shape Free Object Inpainting with Diffusion Model

Lirui Zhao, Tianshuo Yang, Wenqi Shao, Yuxin Zhang, Ping Luo, Kaipeng Zhang, Rongrong Ji · Submission to ICLR 2025 · Rejected

TL;DR

Diffree introduces a text-guided diffusion framework capable of seamlessly adding new objects into images without requiring user-drawn masks or bounding boxes. By training on a newly curated dataset (OABench) and integrating an auxiliary Object Mask Predictor (OMP) module, Diffree predicts where and how to place objects while keeping the surrounding background perfectly intact—achieving a >98% success rate compared to InstructPix2Pix’s <19%.

What Problem Does This Paper Address?

Inserting a new object into an existing photo using only natural language is surprisingly difficult for current AI models:

  • Mask-guided inpainting tools (like PowerPaint or traditional inpainting) require humans to draw bounding boxes or scribble masks. Specifying the exact location, scale, and perspective by hand is tedious and demands artistic judgment.
  • Instruction-based editing models (like InstructPix2Pix) only require text, but they often alter background details, hallucinate unwanted changes, or simply replace existing foreground objects rather than adding new ones.

Diffree bridges this gap by enabling shape-free, text-only object addition that automatically determines the ideal location, shape, and lighting for the added object while strictly preserving background fidelity.

Methods

Diffree builds on Stable Diffusion 1.5 and incorporates a lightweight Object Mask Predictor (OMP):

  1. Diffusion Architecture: Diffree extends the first convolution layer of the diffusion U-Net to concatenate the latent representation of the input image $z$ with the noisy latent $\tilde{z}_t$, conditioned on CLIP text embeddings.
  2. Object Mask Predictor (OMP): Composed of convolutional layers, ResBlocks, and an attention block, OMP predicts the binary mask $m$ of the added object. It takes the concatenated input latent $z$ and the estimated noise-free latent $\tilde{o}_t$ at timestep $t$.
  3. Early Mask Extraction & Clean Compositing: Because $\tilde{o}_t$ can be estimated at early reverse diffusion steps (even step 1), OMP can output the object mask almost immediately. This predicted mask enables direct alpha-blending back onto the original image, ensuring untouched background pixels stay pristine.
  4. Joint Optimization: The diffusion model and OMP are trained end-to-end using a combined loss: $\mathcal{L} = \mathcal{L}_{\text{DM}} + \lambda \mathcal{L}_{\text{OMP}}$ (with $\lambda = 2$).

Datasets

The authors introduce OABench, a synthetic dataset of 74,774 high-quality tuples: (synthetic background image, object text description, ground-truth original image, object mask).

  • Data Curation via Inpainting: Rather than generating synthetic pairs using text-to-image prompts (which causes background drift), OABench takes real images from COCO/LVIS and removes objects using PowerPaint.
  • Strict Quality Filtering: To eliminate bad inpainting artifacts, instances are filtered based on size thresholds (1%–95%), non-edge contact, mask integrity/non-hollowness, aspect ratio (<10), non-occlusion constraints, and post-inpainting CLIP score thresholds (discarding images where residual object traces remain).
  • Evaluation Sets: 1,000 manually inspected pairs each from COCO and OpenImages.

Key Insights and Ideas

  • Addition as the Inverse of Removal: Real scenes possess natural spatial context (e.g., keyboards sit in front of monitors). Removing real objects from natural images creates clean "empty slots" that preserve authentic environmental interactions and lighting cues.
  • Self-Generated Masks Prevent Iterative Decay: Standard text-to-image editing degrades rapidly over consecutive edits because noise accumulates across the entire canvas. By predicting its own mask, Diffree composites only the newly added region, unlocking iterative, multi-step additions (e.g., decorating an empty room step-by-step).
  • Ecosystem Modularity: The predicted mask allows Diffree to act as a spatial planner for other tools—feeding masks directly into customized object inserters (like AnyDoor) or shadow generation pipelines (like SGDiffusion).

Key Results

Diffree was evaluated against InstructPix2Pix (text-guided) and PowerPaint (mask-guided, using Diffree's predicted masks as input):

  • Success Rate: Diffree achieves 98.5% on COCO and 98.0% on OpenImages, compared to InstructPix2Pix’s 17.4% and 18.9% (which mostly suffered from foreground replacement or background corruption).
  • Background Preservation (LPIPS $\downarrow$): Diffree achieves an LPIPS of 0.07 across COCO and OpenImages (matching mask-guided PowerPaint at 0.06), significantly outperforming InstructPix2Pix (0.11, evaluated only on its successful cases).
  • Location Plausibility (GPT-4V Score $\uparrow$, 1–5 scale): GPT-4V rated Diffree at 3.47 (COCO) and 3.50 (OpenImages), exceeding InstructPix2Pix's successful instances (3.13 and 3.36).
  • Unified Score $\uparrow$: Diffree scored 35.92 on COCO versus InstructPix2Pix’s 4.48.

Limitations and Future Work

  • Dependence on Inpainter Quality: Imperfections in OABench’s inpainting phase can occasionally teach the model to replace an existing instance rather than add a second one if an identical class already exists in the scene.
  • Lack of Coarse Spatial Control: By design, Diffree is shape-free. While the authors demonstrated prompt extensions (e.g., using GPT-4o-mini to append spatial descriptions like "on the wooden floor"), users cannot interactively steer placement without prompt engineering.
  • Future Directions: Blending text-only generation with optional coarse user guidance (hybrid mask/text control) and further expanding dataset diversity.

Summary updated

BibTeX
@misc{zhao2024diffree,
  author = {Lirui Zhao and Tianshuo Yang and Wenqi Shao and Yuxin Zhang and Ping Luo and Kaipeng Zhang and Rongrong Ji},
  title = {{Diffree: Text-Guided Shape Free Object Inpainting with Diffusion Model}},
  year = {2024},
  eprint = {2407.16982},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2407.16982},
}

Loading related content...

Figure