Table of Contents

Class InstanceSegmenterBase<T>

Base class for instance segmentation models.

public abstract class InstanceSegmenterBase<T>

Type Parameters

T

The numeric type used for calculations.

Inheritance
InstanceSegmenterBase<T>
Derived
Inherited Members

Constructors

InstanceSegmenterBase(InstanceSegmentationOptions<T>)

Creates a new instance segmenter.

protected InstanceSegmenterBase(InstanceSegmentationOptions<T> options)

Parameters

options InstanceSegmentationOptions<T>

Fields

NumOps

protected readonly INumericOperations<T> NumOps

Field Value

INumericOperations<T>

Options

protected readonly InstanceSegmentationOptions<T> Options

Field Value

InstanceSegmentationOptions<T>

Properties

Name

Name of this segmentation model.

public abstract string Name { get; }

Property Value

string

Methods

ApplyMaskNMS(List<InstanceMask<T>>, double)

Applies NMS to filter overlapping instances.

protected List<InstanceMask<T>> ApplyMaskNMS(List<InstanceMask<T>> instances, double iouThreshold)

Parameters

instances List<InstanceMask<T>>
iouThreshold double

Returns

List<InstanceMask<T>>

ApplySigmoid(Tensor<T>)

Applies sigmoid activation to tensor.

protected void ApplySigmoid(Tensor<T> tensor)

Parameters

tensor Tensor<T>

BinarizeMask(Tensor<T>, T)

Binarizes a mask using threshold.

protected Tensor<T> BinarizeMask(Tensor<T> mask, T threshold)

Parameters

mask Tensor<T>
threshold T

Returns

Tensor<T>

CropMaskToBox(Tensor<T>, BoundingBox<T>, int, int)

Crops a mask to bounding box region.

protected Tensor<T> CropMaskToBox(Tensor<T> mask, BoundingBox<T> box, int imageHeight, int imageWidth)

Parameters

mask Tensor<T>
box BoundingBox<T>
imageHeight int
imageWidth int

Returns

Tensor<T>

GetParameterCount()

Gets the total parameter count.

public abstract long GetParameterCount()

Returns

long

LoadWeightsAsync(string, CancellationToken)

Loads pretrained weights.

public abstract Task LoadWeightsAsync(string pathOrUrl, CancellationToken cancellationToken = default)

Parameters

pathOrUrl string
cancellationToken CancellationToken

Returns

Task

ResizeMask(Tensor<T>, int, int)

Resizes a mask to target size using bilinear interpolation.

protected Tensor<T> ResizeMask(Tensor<T> mask, int targetHeight, int targetWidth)

Parameters

mask Tensor<T>
targetHeight int
targetWidth int

Returns

Tensor<T>

SaveWeights(string)

Saves model weights.

public abstract void SaveWeights(string path)

Parameters

path string

Segment(Tensor<T>)

Performs instance segmentation on an image.

public abstract InstanceSegmentationResult<T> Segment(Tensor<T> image)

Parameters

image Tensor<T>

Input image tensor [batch, channels, height, width].

Returns

InstanceSegmentationResult<T>

Instance segmentation result with masks.