MedSegDiffV2<T>
Models & Types · AiDotNet.ComputerVision.Segmentation.Medical
MedSegDiff-V2: Spectrum-space diffusion for medical segmentation.
Inheritance: NeuralNetworkBase<T> → SegmentationModelBase<T> → MedicalSegmentationBase<T> → MedSegDiffV2<T>
For Beginners
Medical image segmentation with diffusion models. High-quality boundary delineation.
Common use cases:
- Medical image segmentation with diffusion models
- High-quality boundary delineation
- Uncertain region handling in medical images
- Multi-scale medical feature extraction
How It Works
Technical Details:
- Conditional diffusion process for segmentation mask generation
- Spectrum-Space Transformer (SS-Former) for multi-scale features
- Anchor condition + step-uncertainty-aware attention
- Iterative denoising for progressively refined segmentation
Reference: Wu et al., “MedSegDiff-V2: Diffusion-based Medical Image Segmentation with Transformer”, AAAI 2024.
Example
// Create a MedSegDiffV2 model for diffusion-based medical segmentation
var architecture = new NeuralNetworkArchitecture<double>(
inputType: InputType.ThreeDimensional,
taskType: NeuralNetworkTaskType.BinaryClassification,
inputHeight: 256, inputWidth: 256, inputDepth: 1, outputSize: 1);
var model = new MedSegDiffV2<double>(architecture);
// Every tunable is now set through the options object; these are the defaults:
var custom = new MedSegDiffV2<double>(architecture,
options: new MedSegDiffV2Options { NumClasses = 1, DropRate = 0 });
// Or load a pre-trained ONNX model for iterative denoising segmentation
var onnxModel = new MedSegDiffV2<double>(architecture, "medsegdiffv2.onnx");
Constructors
| Constructor | Summary |
|---|---|
MedSegDiffV2(NeuralNetworkArchitecture<T> architecture, IGradientBasedOptimizer<T, Tensor<T>, Tensor<T>> optimizer, ILossFunction<T> lossFunction, MedSegDiffV2Options options) |
Initializes MedSegDiffV2 in native (trainable) mode. |
MedSegDiffV2(NeuralNetworkArchitecture<T> architecture, string onnxModelPath, MedSegDiffV2Options options) |
Initializes MedSegDiffV2 in ONNX (inference-only) mode. |
Properties
| Property | Summary |
|---|---|
bool Supports3D { get; } |
MedSegDiff-V2 operates on 2D slices only, so volumetric input is handled slice-wise. |
Methods
| Method | Summary |
|---|---|
MedicalSegmentationResult<T> SegmentFewShot(Tensor<T> queryImage, Tensor<T> supportImages, Tensor<T> supportMasks) |
|
MedicalSegmentationResult<T> SegmentSlice(Tensor<T> slice) |
Segments a single 2D medical slice. |
MedicalSegmentationResult<T> SegmentVolume(Tensor<T> volume) |
Segments a volume by treating it as a single slice (MedSegDiff-V2 is a 2D model). |
ModelMetadata<T> GetModelMetadata() |
Collects metadata describing this model’s configuration. |