DiffCut<T>

Models & Types · AiDotNet.ComputerVision.Segmentation.Semantic

DiffCut: Catalyzing Zero-Shot Semantic Segmentation with Diffusion Features and Recursive Normalized Cut.

Inheritance: NeuralNetworkBase<T> → SegmentationModelBase<T> → SemanticSegmentationBase<T> → DiffCut<T>

For Beginners

DiffCut is a unique semantic segmentation model that requires no training labels at all. It extracts features from a diffusion model’s internal UNet representations and applies a graph-based algorithm called Normalized Cut to partition the image into semantically meaningful regions. This “zero-shot” approach means you can segment images without ever training on segmentation labels.

Common use cases:

  • Zero-shot segmentation when no labeled data is available
  • Exploring and annotating new datasets
  • Domain adaptation where labeled data doesn’t exist
  • Research into unsupervised visual understanding

How It Works

Technical Details:

  • Extracts intermediate features from a pre-trained Stable Diffusion UNet
  • Builds an affinity graph from diffusion feature similarities
  • Applies recursive Normalized Cut (NCut) for hierarchical segmentation
  • Achieves +7.3 mIoU over prior SOTA on unsupervised segmentation benchmarks
  • Training-free: no fine-tuning required

Reference: Couairon et al., “DiffCut: Catalyzing Zero-Shot Semantic Segmentation with Diffusion Features and Recursive Normalized Cut”, NeurIPS 2024.

Example

// Create a DiffCut model for zero-shot semantic segmentation
var architecture = new NeuralNetworkArchitecture<double>(
    inputType: InputType.ThreeDimensional,
    taskType: NeuralNetworkTaskType.MultiClassClassification,
    inputHeight: 512, inputWidth: 512, inputDepth: 3, outputSize: 150);
var model = new DiffCut<double>(architecture);
// Every tunable is now set through the options object; these are the defaults:
var custom = new DiffCut<double>(architecture,
    options: new DiffCutOptions { NumClasses = 150, DropRate = 0.1 });
            
// Or load a pre-trained ONNX model for unsupervised segmentation
var onnxModel = new DiffCut<double>(architecture, "diffcut.onnx");

Constructors

Constructor Summary
DiffCut(NeuralNetworkArchitecture<T> architecture, IGradientBasedOptimizer<T, Tensor<T>, Tensor<T>> optimizer, ILossFunction<T> lossFunction, DiffCutOptions options) Initializes DiffCut in native (trainable) mode.
DiffCut(NeuralNetworkArchitecture<T> architecture, string onnxModelPath, DiffCutOptions options) Initializes DiffCut in ONNX (inference-only) mode.

Methods

Method Summary
ModelMetadata<T> GetModelMetadata() Collects model metadata.