KMaXDeepLab<T>
Models & Types · AiDotNet.ComputerVision.Segmentation.Panoptic
kMaX-DeepLab: k-means Mask Transformer for panoptic segmentation.
Inheritance: NeuralNetworkBase<T> → SegmentationModelBase<T> → PanopticSegmentationBase<T> → KMaXDeepLab<T>
For Beginners
Panoptic segmentation (stuff + things). Scene understanding for autonomous driving.
Common use cases:
- Panoptic segmentation (stuff + things)
- Scene understanding for autonomous driving
- Robotics environment parsing
- Dense scene labeling
How It Works
Technical Details:
- k-means cross-attention replacing standard cross-attention: every pixel is assigned to its argmax cluster and
the assigned pixel values update the cluster centers
- Each decoder stage: k-means cross-attention, self-attention among the centers and an FFN, each with learnable
projections, residual connections and BatchNorm (deeplab2’s kMaXTransformerLayer)
- Trained with the PQ-style loss, the mask-ID cross-entropy, the pixel-wise instance discrimination loss and an
auxiliary semantic loss, every decoder stage supervised (weights in KMaXDeepLabOptions)
Reference: Yu et al., “k-means Mask Transformer”, ECCV 2022.
Example
// Create a kMaX-DeepLab model for panoptic segmentation
var architecture = new NeuralNetworkArchitecture<double>(
inputType: InputType.ThreeDimensional,
taskType: NeuralNetworkTaskType.MultiClassClassification,
inputHeight: 512, inputWidth: 512, inputDepth: 3, outputSize: 133);
var model = new KMaXDeepLab<double>(architecture);
// Every tunable is now set through the options object; these are the defaults:
var custom = new KMaXDeepLab<double>(architecture,
options: new KMaXDeepLabOptions { NumClasses = 133, DropRate = 0.1, ModelSize = KMaXDeepLabModelSize.R50 });
// Or load a pre-trained ONNX model for autonomous driving scene parsing
var onnxModel = new KMaXDeepLab<double>(architecture, "kmaxdeeplab.onnx");
Constructors
| Constructor | Summary |
|---|---|
KMaXDeepLab(NeuralNetworkArchitecture<T> architecture, IGradientBasedOptimizer<T, Tensor<T>, Tensor<T>> optimizer, ILossFunction<T> lossFunction, KMaXDeepLabOptions options) |
Initializes KMaXDeepLab in native (trainable) mode. |
KMaXDeepLab(NeuralNetworkArchitecture<T> architecture, string onnxModelPath, KMaXDeepLabOptions options) |
Initializes KMaXDeepLab in ONNX (inference-only) mode. |
Methods
| Method | Summary |
|---|---|
IReadOnlyList<OutputAxisContract> OutputAxesFor(int inputRank) |
|
ModelMetadata<T> GetModelMetadata() |
Collects metadata describing this model’s configuration. |
PanopticSegmentationResult<T> SegmentPanoptic(Tensor<T> image) |
|
Tensor<T> ForwardForTraining(Tensor<T> input) |
The training forward for a caller-supplied loss: the same semantic scores Forward returns (the layers are not a sequential chain, so the base layer walk would train a different tensor). |