Teaching Diffusion Models to Ground Alpha Matte

Tianyi Xiang, Weiying Zheng, Yutao Jiang, Tingrui Shen, Hewei Yu, Yangyang Xu, Shengfeng HeTMLR 2025

Abstract

Image matting, the precise extraction of foreground objects with pixel-level transparency, has traditionally relied on labor-intensive manual inputs like trimaps. This paper presents a novel framework that leverages the generative priors of Stable Diffusion to perform text-guided image matting. By disentangling the task into semantic localization and transparency estimation through a teacher-student distillation process, the proposed method achieves state-of-the-art accuracy and high computational efficiency. Experimental results demonstrate significant improvements over existing text-guided baselines, with the model generalizing across diverse categories including portraits, animals, and complex transparent objects.

Introduction

Image matting is the process of precisely separating a foreground object from its background by estimating an "alpha matte" ($\alpha$), where each pixel value represents transparency. Traditionally, this is an "ill-posed" problem requiring heavy manual intervention, such as trimaps—hand-drawn maps marking foreground, background, and unknown regions. While recent visual-language models like CLIP have attempted to use text prompts for matting, they often lack the pixel-level spatial awareness needed for fine details like hair or smoke.

The proposed framework handles a wide variety of matting tasks, including portraits, animals, natural images, and video instances, using only natural language prompts.

Conversely, while Diffusion Models possess incredible internal priors about object shapes and textures, directly fine-tuning them for matting is difficult. Matting requires two competing skills: high-level semantic understanding to locate the object and low-level detail extraction to estimate transparency. This paper introduces a framework that "teaches" Stable Diffusion to perform image matting using only natural language prompts by resolving this conflict.

Methodology

The authors propose a multi-stage "teaching" pipeline to disentangle localization from transparency estimation:

  1. Soft Semantic Grounding (The Teacher): A "Teacher" U-Net is trained to identify three semantic zones: foreground, background, and transparent regions. This establishes a robust spatial foundation based on the text prompt.
  2. Asymmetric Distillation (The Student): A more efficient "Student" model learns from the Teacher’s semantic knowledge via a Semantic Guidance Loss ($L_{SG}$). Crucially, the Student is encouraged to "mine" transparency details from the model's internal cross-attention maps, which inherently contain information about object boundaries.
  3. Structural Optimization: To ensure real-world utility, the authors apply block pruning and Self-Attention Optimization. The latter replaces dense attention with asymmetric sparse correspondences, significantly reducing computational complexity from $O(n^2)$.
  4. Matting Decoder: Finally, the soft grounding results are processed by a detail encoder-decoder to produce high-resolution ($2K+$) alpha mattes.

Key Results and Insights

The model was evaluated using a diverse mix of datasets, including RefMatte, P3M10K (portraits), AM2K (animals), and RM1K (natural images). To handle datasets lacking text, the authors utilized BLIP-2 to generate descriptive captions.

  • Performance: The model significantly outperformed existing text-guided baselines. On the RefMatte-Testset, it achieved a Sum of Absolute Differences (SAD) of 3.19, a dramatic improvement over CLIPMat’s 26.56.
  • Efficiency: Thanks to structural optimization, the model achieves an average inference time of 95.14ms per sample on an RTX 3090—roughly 2-10x faster than many cascaded grounding and matting baselines.
  • Generalization: The model demonstrates robust performance across diverse categories, including transparent glassware and fine nets, and even generalizes to non-photographic data like animations and oil paintings.

Conclusion

This research demonstrates that disentangling localization and transparency estimation is key to effective text-guided matting. By leveraging the internal attention maps of diffusion models as transparency cues and optimizing for sparsity, the authors have created a tool that is both highly accurate and computationally efficient. Future work will focus on reducing sensitivity to ambiguous prompts and mitigating artifacts introduced by the latent space of Variational Autoencoders.

Summary updated

BibTeX
@article{xiang2025teaching,
  author = {Tianyi Xiang and Weiying Zheng and Yutao Jiang and Tingrui Shen and Hewei Yu and Yangyang Xu and Shengfeng He},
  title = {{Teaching Diffusion Models to Ground Alpha Matte}},
  journal = {Accepted by TMLR},
  year = {2025},
  url = {https://openreview.net/forum?id=2gNy9Yeg8J},
}
Figure