MedSegDiffV2Segmentation<T>

Models & Types · AiDotNet.ComputerVision.Segmentation.Diffusion

MedSegDiff-V2 Segmentation: Diffusion-based medical image segmentation pipeline.

Inheritance: NeuralNetworkBase<T> → SegmentationModelBase<T> → MedicalSegmentationBase<T> → MedSegDiffV2Segmentation<T>

For Beginners

Diffusion-based medical segmentation. High-precision medical boundary delineation.

Common use cases:

  • Diffusion-based medical segmentation
  • High-precision medical boundary delineation
  • Stochastic segmentation for uncertainty estimation
  • Multi-modal medical image segmentation

How It Works

Technical Details:

  • Conditional diffusion model for segmentation mask denoising
  • Spectrum-Space Former for frequency and spatial features
  • Iterative refinement via reverse diffusion process
  • Handles ambiguous medical image boundaries

Reference: Wu et al., “MedSegDiff-V2: Diffusion-based Medical Image Segmentation with Transformer”, AAAI 2024.

Example

var trainingMasks = Tensor<double>.CreateRandom(1, 3, 32, 32);
var medicalImage = Tensor<double>.CreateRandom(1, 3, 32, 32);
var trainingImages = Tensor<double>.CreateRandom(4, 3, 32, 32);
// Use AiModelBuilder facade for medical image segmentation
var architecture = new NeuralNetworkArchitecture<double>(
    inputType: InputType.ThreeDimensional,
    taskType: NeuralNetworkTaskType.BinaryClassification,
    inputHeight: 256, inputWidth: 256, inputDepth: 3, outputSize: 1);
            
var builder = new AiModelBuilder<double, Tensor<double>, Tensor<double>>()
    .ConfigureModel(new MedSegDiffV2Segmentation<double>(architecture));
            
var result = builder.Build(trainingImages, trainingMasks);
var segmentation = result.Predict(medicalImage);

Constructors

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

Properties

Property Summary
bool Supports3D { get; }

Methods

Method Summary
MedicalSegmentationResult<T> SegmentFewShot(Tensor<T> queryImage, Tensor<T> supportImages, Tensor<T> supportMasks)
MedicalSegmentationResult<T> SegmentSlice(Tensor<T> slice)
MedicalSegmentationResult<T> SegmentVolume(Tensor<T> volume)
ModelMetadata<T> GetModelMetadata() Collects metadata describing this model’s configuration.