Table of Contents

Class DIoUNMS<T>

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

Implements Distance-IoU based Non-Maximum Suppression for improved localization.

public class DIoUNMS<T>

Type Parameters

T

The numeric type used for calculations.

Inheritance
DIoUNMS<T>
Inherited Members

Remarks

For Beginners: DIoU-NMS is an improved version of standard NMS that considers the distance between box centers, not just their overlap. This helps preserve nearby objects that might be suppressed by standard NMS.

Reference: Zheng et al., "Distance-IoU Loss: Faster and Better Learning for Bounding Box Regression", AAAI 2020

Constructors

DIoUNMS()

Creates a new DIoU-NMS instance.

public DIoUNMS()

Methods

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

Applies DIoU-NMS to a list of detections.

public List<Detection<T>> Apply(List<Detection<T>> detections, double diouThreshold)

Parameters

detections List<Detection<T>>

List of detections to filter.

diouThreshold double

DIoU threshold for suppression (typically higher than IoU threshold).

Returns

List<Detection<T>>

Filtered list of detections.

Remarks

For Beginners: DIoU-NMS uses the distance between box centers as an additional criterion. Two boxes might have high IoU but if their centers are far apart, they might represent different objects and should both be kept.

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

Applies DIoU-NMS with adaptive threshold based on box density.

public List<Detection<T>> ApplyAdaptive(List<Detection<T>> detections, double baseDiouThreshold, double densityFactor = 0.5)

Parameters

detections List<Detection<T>>

List of detections to filter.

baseDiouThreshold double

Base DIoU threshold.

densityFactor double

How much to adjust threshold based on density (0.0 to 1.0).

Returns

List<Detection<T>>

Filtered list of detections.

Remarks

For Beginners: In crowded scenes with many overlapping objects, using a fixed threshold might suppress too many valid detections. Adaptive DIoU-NMS adjusts the threshold based on the local density of detections.

ApplyBatched(List<List<Detection<T>>>, double, bool)

Applies batched DIoU-NMS for multiple images.

public List<List<Detection<T>>> ApplyBatched(List<List<Detection<T>>> batchDetections, double diouThreshold, bool classAware = true)

Parameters

batchDetections List<List<Detection<T>>>

Detections for each image in the batch.

diouThreshold double

DIoU threshold for suppression.

classAware bool

Whether to apply class-aware NMS.

Returns

List<List<Detection<T>>>

Filtered detections for each image.

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

Applies class-aware DIoU-NMS.

public List<Detection<T>> ApplyClassAware(List<Detection<T>> detections, double diouThreshold)

Parameters

detections List<Detection<T>>

List of detections to filter.

diouThreshold double

DIoU threshold for suppression.

Returns

List<Detection<T>>

Filtered list of detections with per-class DIoU-NMS applied.