NnUNet<T>

Models & Types · AiDotNet.ComputerVision.Segmentation.Medical

nnU-Net: Self-configuring framework for medical image segmentation.

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

For Beginners

Medical image segmentation across organs and modalities. CT/MRI organ segmentation.

Common use cases:

  • Medical image segmentation across organs and modalities
  • CT/MRI organ segmentation
  • Pathology image analysis
  • Any biomedical segmentation task (self-configuring)

How It Works

Technical Details:

  • Self-configuring: automatically selects architecture, preprocessing, and training
  • Supports 2D, 3D full-resolution, and 3D cascade configurations
  • Rule-based pipeline configuration from dataset fingerprint
  • Consistently top-ranked on medical segmentation benchmarks

Reference: Isensee et al., “nnU-Net: a self-configuring method for deep learning-based biomedical image segmentation”, Nature Methods 2021.

Example

// Create an nnU-Net model for self-configuring medical segmentation
var architecture = new NeuralNetworkArchitecture<double>(
    inputType: InputType.ThreeDimensional,
    taskType: NeuralNetworkTaskType.MultiClassClassification,
    inputHeight: 256, inputWidth: 256, inputDepth: 1, outputSize: 14);
var model = new NnUNet<double>(architecture);
// Every tunable is now set through the options object; these are the defaults:
var custom = new NnUNet<double>(architecture,
    options: new NnUNetOptions { NumClasses = 14, DropRate = 0, ModelSize = NnUNetModelSize.UNet2D });
            
// Or load a pre-trained ONNX model for organ segmentation
var onnxModel = new NnUNet<double>(architecture, "nnunet.onnx");

Constructors

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

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 3D volume slice-by-slice and aggregates the per-structure statistics.
ModelMetadata<T> GetModelMetadata() Collects metadata describing this model’s configuration.