Unsupervised Segmentation by Diffusing, Walking and Cutting

Daniela Ivanova, Marco Aversa, Paul Henderson, John Williamson · DOI

Abstract

This paper introduces a novel zero-shot, unsupervised framework for semantic image segmentation. By repurposing the internal self-attention mechanisms of pre-trained diffusion models as transition probabilities in a Markov random walk, the proposed method—"Diffusing, Walking and Cutting"—extracts rich semantic hierarchies without any task-specific training. Combined with a hyperparameter-free adaptation of the Normalized Cuts algorithm, the approach achieves state-of-the-art performance on major benchmarks like COCO-Stuff and ADE20K, offering a mathematically grounded and fully automated solution for semantic segmentation.

Introduction

Semantic segmentation—the task of assigning a categorical label to every pixel in an image—is a fundamental challenge in computer vision. Traditionally, achieving high performance has required massive amounts of human-annotated data. While unsupervised methods aim to alleviate this bottleneck, they often necessitate domain-specific training. Recent "zero-shot" approaches have attempted to bypass training by utilizing features from large-scale generative models like Stable Diffusion. However, these methods frequently suffer from two primary issues: the "fiddle factor" (the need for manual hyperparameter tuning) and high computational complexity.

In this work, we propose a method that is both mathematically grounded and fully automated. Our approach is capable of producing high-quality segments across diverse datasets without human intervention or expensive iterative calculations.

Methodology

Our framework consists of several key technical innovations designed to extract and partition semantic information from diffusion models:

  • Feature Extraction via Inversion: We utilize DDIM inversion to extract self-attention maps from the U-Net decoder of Stable Diffusion 1.4.
  • The Random Walk Interpretation: A critical observation of this work is that self-attention matrices are naturally row-stochastic due to the softmax function. This allows us to treat the attention matrix as a transition kernel for a Markov random walk between image patches.
  • Power Walks for Granularity: By raising the transition matrix to a power ($P^k$), we simulate multi-hop "walks" across the image. This process effectively diffuses information: a small $k$ preserves local details, while a larger $k$ merges related parts into coarser semantic objects.
  • Efficient Adjacency: To build a symmetric adjacency matrix for clustering, we employ simple dot-product similarity between attention patterns. We found that dot-product similarity preserves sharp, localized boundaries better than cosine similarity, which tends to create "halo" effects.
  • Hyperparameter-free Normalised Cuts (NCut): We adapt the classic NCut algorithm with a dynamic stopping criterion. By modifying the Minimum Average Node Cut (MAN-C) algorithm for dense graphs, our system automatically decides when an image has been sufficiently segmented, eliminating the need for manual thresholding or predefined cluster counts.

Experimental Results

The proposed method was evaluated on standard benchmarks including COCO-Stuff-27, Cityscapes, and ADE20K. It sets a new state-of-the-art for zero-shot unsupervised segmentation, achieving 46.6% mIoU on COCO-Stuff-27, significantly outperforming previous leaders such as DiffSeg (43.6%) and DiffCut (31.3%).

Qualitative comparison of the proposed method against state-of-the-art unsupervised segmentation baselines and ground truth.

Qualitatively, as shown in Figure 1, our model is less prone to the "banding" artifacts common in other diffusion-based methods and demonstrates superior precision in capturing complex boundaries, such as the limbs of animals or intricate foreground objects. The entire process is highly efficient, taking only 2–4 seconds per image on a standard A5000 GPU.

Discussion and Conclusion

A key insight of this research is that self-attention in diffusion models represents the probability of moving from one part of an image to another, making spectral graph theory an ideal framework for interpretation. While the model occasionally produces segments finer than human-annotated ground truths (e.g., segmenting a glove separately from an arm), this "granularity gap" highlights the richness of the learned features.

In conclusion, "Diffusing, Walking and Cutting" provides a robust, training-free path to high-quality semantic segmentation. Future work will explore aligning these intrinsic groupings more closely with human perceptual judgments and investigating sensitivity across different foundation model architectures.

Summary updated

BibTeX
@inproceedings{ivanova2026unsupervised,
  author = {Daniela Ivanova and Marco Aversa and Paul Henderson and John Williamson},
  title = {{Unsupervised Segmentation by Diffusing, Walking and Cutting}},
  booktitle = {IEEE/CVF Winter Conference on Applications of Computer Vision},
  year = {2026},
  doi = {10.1109/wacv61042.2026.00496},
}
Figure