Ref-Diff: Zero-shot Referring Image Segmentation with Generative Models

Minheng Ni, Yabo Zhang, Kailai Feng, Xiaoming Li, Yiwen Guo, Wangmeng Zuo · DOI

Abstract

Referring Image Segmentation (RIS) aims to identify and mask specific objects in an image based on natural language descriptions. Traditional RIS methods rely on large-scale supervised datasets of image-text-mask triplets, which are costly to annotate. This paper presents Ref-Diff, a novel zero-shot framework that repurposes pre-trained generative models (e.g., Stable Diffusion) for precise object localization. By extracting fine-grained cross-attention maps from the diffusion process and integrating them with a discriminative CLIP-based module, Ref-Diff establishes a new state-of-the-art for zero-shot RIS, outperforming previous methods by significant margins.

Introduction

The core challenge in Referring Image Segmentation (RIS) is bridging the gap between high-level linguistic concepts and pixel-level spatial information. While discriminative models like CLIP excel at global semantic matching (e.g., "is there a horse in this image?"), they often struggle with precise localization. Conversely, generative models must inherently understand spatial relationships to synthesize accurate images from text prompts. Ref-Diff explores this untapped potential, demonstrating that the internal "knowledge" of diffusion models can be "reverse-engineered" to perform segmentation without any task-specific training.

Methodology: The Ref-Diff Framework

Ref-Diff operates through a dual-process architecture that combines the strengths of generative localization and discriminative categorization.

1. The Generative Process

The generative module leverages the cross-attention layers of a pre-trained Stable Diffusion model. Given an input image and a referring text, the system adds a small amount of Gaussian noise and performs an inverse diffusion step. During this step, the model generates cross-attention maps that correlate specific text tokens with spatial regions. To ensure precision, Ref-Diff uses syntax analysis to identify the ROOT token (the primary noun, e.g., "horse") and focuses on its corresponding attention map to create a weight-free object proposal.

2. The Discriminative Process

To refine the generative proposals, Ref-Diff incorporates a modified CLIP model. A key innovation here is the introduction of a positional bias matrix, which allows CLIP to better interpret directional and spatial cues (e.g., "left," "bottom") that are typically ignored by standard vision-language models.

The Ref-Diff architecture, illustrating the synergy between the Generative Process (Stable Diffusion) and the Discriminative Process (CLIP).

3. Integration and Scoring

The final segmentation mask is derived by combining scores from both modules. The generative module provides high-quality spatial candidates, while the discriminative module ensures semantic alignment with the referring expression.

Experimental Results

Ref-Diff was evaluated on four major RIS benchmarks: RefCOCO, RefCOCO+, RefCOCOg, and PhraseCut.

Quantitative Performance

Ref-Diff achieves a significant performance leap over existing zero-shot baselines. On the RefCOCO dataset, it reached a Mean Intersection over Union (mIoU) of 37.21, an 11-point improvement over the previous state-of-the-art (Global-Local CLIP). Notably, Ref-Diff also outperformed TSEG, a weakly-supervised model that requires training on image-text pairs, highlighting the efficacy of its zero-shot approach.

Qualitative Analysis

Qualitative results demonstrate Ref-Diff's ability to handle complex spatial queries. For instance, in scenarios with multiple similar objects (e.g., "the broccoli furthest to the left"), Ref-Diff successfully isolates the correct instance, whereas CLIP-only models often highlight all relevant objects in the scene.

A qualitative example of Ref-Diff's precise segmentation mask for a specific person in a complex scene.

Discussion and Limitations

The success of Ref-Diff underscores the value of implicit spatial knowledge within generative models. However, the approach faces two primary challenges:

  1. Computational Overhead: The iterative nature of diffusion models makes Ref-Diff slower than standard feed-forward architectures.
  2. Linguistic Ambiguity: While the ROOT token strategy is effective, highly complex or ambiguous descriptions can still lead to errors in spatial reasoning.

Conclusion

Ref-Diff represents a paradigm shift in zero-shot RIS by demonstrating that generative models can serve as powerful, training-free segmentors. By effectively combining generative localization with discriminative semantics, it sets a new benchmark for the field and opens new avenues for utilizing large-scale pre-trained models in downstream vision tasks.

Summary updated

BibTeX
@misc{ni2023ref,
  author = {Minheng Ni and Yabo Zhang and Kailai Feng and Xiaoming Li and Yiwen Guo and Wangmeng Zuo},
  title = {{Ref-Diff: Zero-shot Referring Image Segmentation with Generative Models}},
  year = {2023},
  eprint = {2308.16777},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2308.16777},
}
Figure