U2Seg<T>

Models & Types · AiDotNet.ComputerVision.Segmentation.Foundation

U2Seg: Unified Unsupervised Segmentation framework.

Inheritance: NeuralNetworkBase<T> → SegmentationModelBase<T> → PanopticSegmentationBase<T> → U2Seg<T>

For Beginners

U2Seg performs instance, semantic, and panoptic segmentation without requiring any human annotations. Instead of being trained on thousands of manually-labeled images, U2Seg discovers object boundaries and categories through unsupervised learning — making it ideal for domains where annotation is expensive or unavailable.

Common use cases:

  • Segmentation where manual annotation is too expensive or time-consuming
  • Domain adaptation (applying segmentation to new, unlabeled domains)
  • Research in self-supervised and unsupervised vision
  • Bootstrap labeling for subsequent supervised training

How It Works

Technical Details:

  • Unsupervised approach: discovers segments via self-supervised features (DINO/DINOv2)
  • Uses a Mask2Former-like architecture but trained with pseudo-labels
  • Handles instance, semantic, and panoptic segmentation without annotations
  • Fixed architecture based on Swin-T backbone

Reference: Niu et al., “Unsupervised Universal Image Segmentation”, CVPR 2024.

Example

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

Constructors

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

Methods

Method Summary
ModelMetadata<T> GetModelMetadata() Collects metadata describing this U2Seg model’s configuration.
PanopticSegmentationResult<T> SegmentPanoptic(Tensor<T> image)