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
TThe 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
detectionsList<Detection<T>>List of detections to filter.
diouThresholddoubleDIoU threshold for suppression (typically higher than IoU threshold).
Returns
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
detectionsList<Detection<T>>List of detections to filter.
baseDiouThresholddoubleBase DIoU threshold.
densityFactordoubleHow much to adjust threshold based on density (0.0 to 1.0).
Returns
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
batchDetectionsList<List<Detection<T>>>Detections for each image in the batch.
diouThresholddoubleDIoU threshold for suppression.
classAwareboolWhether to apply class-aware NMS.
Returns
ApplyClassAware(List<Detection<T>>, double)
Applies class-aware DIoU-NMS.
public List<Detection<T>> ApplyClassAware(List<Detection<T>> detections, double diouThreshold)
Parameters
detectionsList<Detection<T>>List of detections to filter.
diouThresholddoubleDIoU threshold for suppression.