Table of Contents

Class SoftNMS<T>

Namespace
AiDotNet.ComputerVision.Detection.PostProcessing
Assembly
AiDotNet.dll

Implements Soft-NMS algorithm which reduces confidence of overlapping boxes instead of removing them.

public class SoftNMS<T>

Type Parameters

T

The numeric type used for calculations.

Inheritance
SoftNMS<T>
Inherited Members

Remarks

For Beginners: Standard NMS completely removes overlapping boxes, which can be problematic when objects are close together or occluded. Soft-NMS instead reduces the confidence score of overlapping boxes, allowing them to potentially survive if their confidence remains above the threshold.

Reference: Bodla et al., "Soft-NMS -- Improving Object Detection With One Line of Code", ICCV 2017

Constructors

SoftNMS()

Creates a new Soft-NMS instance.

public SoftNMS()

Methods

Apply(List<Detection<T>>, double, double, DecayMethod, double)

Applies Soft-NMS with configurable decay method.

public List<Detection<T>> Apply(List<Detection<T>> detections, double iouThreshold, double scoreThreshold, SoftNMS<T>.DecayMethod method, double sigma)

Parameters

detections List<Detection<T>>

List of detections to filter.

iouThreshold double

IoU threshold (for linear) or ignored (for Gaussian).

scoreThreshold double

Minimum score to keep a detection.

method SoftNMS<T>.DecayMethod

Decay method to use.

sigma double

Sigma parameter for Gaussian decay.

Returns

List<Detection<T>>

Filtered list of detections with adjusted confidences.

ApplyClassAware(List<Detection<T>>, double, double, DecayMethod, double)

Applies class-aware Soft-NMS.

public List<Detection<T>> ApplyClassAware(List<Detection<T>> detections, double iouThreshold = 0.5, double scoreThreshold = 0.001, SoftNMS<T>.DecayMethod method = DecayMethod.Gaussian, double sigma = 0.5)

Parameters

detections List<Detection<T>>

List of detections to filter.

iouThreshold double

IoU threshold for linear decay.

scoreThreshold double

Minimum score to keep.

method SoftNMS<T>.DecayMethod

Decay method.

sigma double

Sigma for Gaussian decay.

Returns

List<Detection<T>>

Filtered detections with per-class Soft-NMS applied.

ApplyGaussian(List<Detection<T>>, double, double)

Applies Soft-NMS with Gaussian decay.

public List<Detection<T>> ApplyGaussian(List<Detection<T>> detections, double sigma = 0.5, double scoreThreshold = 0.001)

Parameters

detections List<Detection<T>>

List of detections to filter.

sigma double

Gaussian decay parameter (higher = slower decay).

scoreThreshold double

Minimum score to keep a detection.

Returns

List<Detection<T>>

Filtered list of detections with adjusted confidences.

ApplyLinear(List<Detection<T>>, double, double)

Applies Soft-NMS with linear decay.

public List<Detection<T>> ApplyLinear(List<Detection<T>> detections, double iouThreshold, double scoreThreshold = 0.001)

Parameters

detections List<Detection<T>>

List of detections to filter.

iouThreshold double

IoU threshold for applying decay.

scoreThreshold double

Minimum score to keep a detection.

Returns

List<Detection<T>>

Filtered list of detections with adjusted confidences.