Class InstanceSegmenterBase<T>
- Assembly
- AiDotNet.dll
Base class for instance segmentation models.
public abstract class InstanceSegmenterBase<T>
Type Parameters
TThe 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
optionsInstanceSegmentationOptions<T>
Fields
NumOps
protected readonly INumericOperations<T> NumOps
Field Value
- INumericOperations<T>
Options
protected readonly InstanceSegmentationOptions<T> Options
Field Value
Properties
Name
Name of this segmentation model.
public abstract string Name { get; }
Property Value
Methods
ApplyMaskNMS(List<InstanceMask<T>>, double)
Applies NMS to filter overlapping instances.
protected List<InstanceMask<T>> ApplyMaskNMS(List<InstanceMask<T>> instances, double iouThreshold)
Parameters
instancesList<InstanceMask<T>>iouThresholddouble
Returns
- List<InstanceMask<T>>
ApplySigmoid(Tensor<T>)
Applies sigmoid activation to tensor.
protected void ApplySigmoid(Tensor<T> tensor)
Parameters
tensorTensor<T>
BinarizeMask(Tensor<T>, T)
Binarizes a mask using threshold.
protected Tensor<T> BinarizeMask(Tensor<T> mask, T threshold)
Parameters
maskTensor<T>thresholdT
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
maskTensor<T>boxBoundingBox<T>imageHeightintimageWidthint
Returns
- Tensor<T>
GetParameterCount()
Gets the total parameter count.
public abstract long GetParameterCount()
Returns
LoadWeightsAsync(string, CancellationToken)
Loads pretrained weights.
public abstract Task LoadWeightsAsync(string pathOrUrl, CancellationToken cancellationToken = default)
Parameters
pathOrUrlstringcancellationTokenCancellationToken
Returns
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
Returns
- Tensor<T>
SaveWeights(string)
Saves model weights.
public abstract void SaveWeights(string path)
Parameters
pathstring
Segment(Tensor<T>)
Performs instance segmentation on an image.
public abstract InstanceSegmentationResult<T> Segment(Tensor<T> image)
Parameters
imageTensor<T>Input image tensor [batch, channels, height, width].
Returns
- InstanceSegmentationResult<T>
Instance segmentation result with masks.