remove unused nms() function in sahi code

This commit is contained in:
swdee
2025-06-21 16:30:37 +12:00
parent 9086df4326
commit ec2cb35463

View File

@@ -248,45 +248,6 @@ func min(a, b int) int {
return b return b
} }
// NMS runs non-maximum suppression on a sorted slice of detections
// Assumes detections are sorted descending by Probability.
func (s *SAHI) nms(detections []result.DetectResult,
iouThreshold, smallBoxOverlapThresh float32) []result.DetectResult {
keep := make([]result.DetectResult, 0, len(detections))
// track by class, so we dont suppress across different classes
for _, det := range detections {
skip := false
for _, kept := range keep {
if det.Class != kept.Class {
continue
}
// do IoU check
if s.iou(det.Box, kept.Box) > iouThreshold {
skip = true
break
}
// do partial box check, if the intersection covers most of the small box
inter := s.intersectionArea(det.Box, kept.Box)
areaDet := s.boxArea(det.Box)
if areaDet > 0 && float32(inter)/float32(areaDet) > smallBoxOverlapThresh {
skip = true
break
}
}
if !skip {
keep = append(keep, det)
}
}
return keep
}
// nmsCluster picks one box per overlapping cluster (classagnostic), // nmsCluster picks one box per overlapping cluster (classagnostic),
// choosing the larghest area (tiebreak on confidence), and uses both IoU // choosing the larghest area (tiebreak on confidence), and uses both IoU
// and smallbox overlap tests to form clusters. // and smallbox overlap tests to form clusters.