DiffCutSegmentation<T>

Models & Types · AiDotNet.ComputerVision.Segmentation.Diffusion

DiffCut: Diffusion-based zero-shot segmentation via graph cuts.

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

For Beginners

Zero-shot segmentation from diffusion features. Unsupervised image segmentation.

Common use cases:

  • Zero-shot segmentation from diffusion features
  • Unsupervised image segmentation
  • Open-world object discovery
  • Training-free segmentation

How It Works

Technical Details:

  • Extracts features from pre-trained Stable Diffusion U-Net
  • Recursive Normalized Cut on diffusion feature affinity graph
  • No training or fine-tuning required
  • Uses diffusion model internal features as dense visual descriptors

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

Example

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

Constructors

Constructor Summary
DiffCutSegmentation(NeuralNetworkArchitecture<T> architecture, IGradientBasedOptimizer<T, Tensor<T>, Tensor<T>> optimizer, ILossFunction<T> lossFunction, DiffCutSegmentationOptions options) Initializes DiffCutSegmentation with the native inference pipeline.
DiffCutSegmentation(NeuralNetworkArchitecture<T> architecture, string onnxModelPath, DiffCutSegmentationOptions options) Initializes DiffCutSegmentation in ONNX (inference-only) mode.

Properties

Property Summary
bool SupportsTraining { get; } Gets whether supervised parameter training is supported.

Methods

Method Summary
ModelMetadata<T> GetModelMetadata() Collects metadata describing this model’s configuration.