Diffusion models like Stable Diffusion (SD) are world-class image generators. Their ability to synthesize complex scenes implies a sophisticated internal understanding of objects and their spatial relationships. However, tapping into this latent "knowledge" for downstream computer vision tasks—like semantic segmentation—has traditionally been difficult without additional training.
EmerDiff introduces an unsupervised framework that extracts high-resolution, fine-grained semantic segmentation masks directly from pre-trained diffusion models. By "modulating" internal low-resolution feature maps and observing the resulting changes in output pixels, EmerDiff uncovers a deep, pixel-level semantic understanding hidden within Stable Diffusion, requiring absolutely no human annotations or extra training steps.
The Challenge: Resolution Mismatch
The core obstacle in extracting segmentation maps from diffusion models is a resolution mismatch. The most semantically rich feature maps inside the model’s U-Net architecture typically exist at very low spatial resolutions (e.g., $16 \times 16$).
While applying simple clustering algorithms like k-means to these features can provide a rough estimate of object locations, the resulting masks are inherently "blobby" and lack the sharp, pixel-perfect boundaries required for real-world applications. Previous attempts to resolve this issue usually relied on training additional "segmentor" networks on labeled datasets, effectively defeating the purpose of using a self-supervised generative model. EmerDiff bypasses this by asking: Can we achieve high-resolution masks using only the pre-trained model itself?
The Solution: Modulated Denoising
To bridge the gap between low-resolution features and high-resolution pixels, the authors propose a novel technique called Modulated Denoising. The process unfolds in five key steps:
- Inversion: To segment a real image, the framework first uses DDPM inversion to find the initial noise latent that would generate that specific image.
- Low-Res Clustering: Feature vectors (specifically query vectors from the cross-attention layers) are extracted at a $16 \times 16$ resolution. K-means clustering is applied to create a set of "base" low-resolution masks.
- The "Poke" (Modulation): To determine which high-resolution pixels ($512 \times 512$) belong to a specific low-resolution mask, the framework perturbs (modulates) the feature values in that specific $16 \times 16$ region by adding a small constant offset.
- Correspondence Mapping: The denoising process is run again with this perturbation. By measuring the Euclidean distance between the original image and the perturbed image, EmerDiff creates a "difference map." The authors discovered a causal link: only pixels semantically related to the perturbed region change significantly.
- Refinement: By repeating this modulation for every low-resolution mask, every pixel in the full-resolution image is assigned to its most "responsive" semantic cluster. "Attention injection" (fixing the attention maps to their original state) is used to ensure the overall image structure remains intact during the process.
Key Insights
- Causal Semantic Links: The relationship between low-res features and high-res pixels is semantically causal. Perturbing the features of a "car" doesn't just alter a localized $16 \times 16$ block; it specifically alters the pixels of the car across the high-resolution image while leaving the background untouched.
- The Power of Appearance Layers: The third cross-attention layer in the $16 \times 16$ upward blocks of the U-Net is particularly sensitive to appearance. Modulating this specific layer yields the sharpest segmentation results.
- Over-segmentation as a Feature: Traditional benchmarks often group a "person" as a single class. EmerDiff naturally segments a person into finer components like "head," "arms," and "torso." While this can penalize scores on traditional mIoU (Mean Intersection over Union) metrics, it demonstrates a more granular semantic understanding than standard ground truth labels provide.
Performance and Results
EmerDiff was evaluated on standard scene-centric benchmarks, including COCO-Stuff, PASCAL-Context, ADE20K, and Cityscapes.
- Unsupervised Performance: On COCO-Stuff-27, EmerDiff achieved a 26.6 mIoU, performing on par with STEGO (26.8 mIoU), a state-of-the-art model explicitly trained for unsupervised segmentation.
- Modified Evaluation Protocol: When evaluated under a modified protocol that allows the model to map its fine-grained clusters to ground truth classes more flexibly, EmerDiff significantly outperformed DINO and CLIP-based baselines across all datasets (e.g., achieving 33.1 mIoU on ADE150 compared to DINO's 19.1).
- Open-Vocabulary Boost: When combined with text-aligned encoders like CLIP, EmerDiff acts as a powerful "refiner." It takes the coarse masks produced by CLIP and snaps them to the precise pixel boundaries discovered by the diffusion model.
Limitations and Future Directions
While groundbreaking, EmerDiff has a few limitations. The model struggles with extremely fine details (like animal legs or small desk parts), likely because these details are lost at the $16 \times 16$ bottleneck where modulation begins. Additionally, because the method requires running the denoising process multiple times (once for each mask cluster), it is computationally heavier than a single-pass feed-forward segmentor. Finally, the model occasionally exhibits attribute confusion, grouping regions based on color or texture rather than object identity (e.g., grouping a blue sky with a blue pool).
Looking forward, the high-quality masks produced by EmerDiff could serve as "pseudo-labels" to train faster, supervised segmentation models. Furthermore, the modulated denoising technique opens exciting avenues for probing the internal representations of other generative models beyond Stable Diffusion.
Summary updated