From ec2cb35463d963a2ca4894e26ac33105a4dd6b91 Mon Sep 17 00:00:00 2001 From: swdee Date: Sat, 21 Jun 2025 16:30:37 +1200 Subject: [PATCH] remove unused nms() function in sahi code --- preprocess/sahi.go | 39 --------------------------------------- 1 file changed, 39 deletions(-) diff --git a/preprocess/sahi.go b/preprocess/sahi.go index 82e460c..e7bd231 100644 --- a/preprocess/sahi.go +++ b/preprocess/sahi.go @@ -248,45 +248,6 @@ func min(a, b int) int { 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 don’t 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 (class‐agnostic), // choosing the larghest area (tie‐break on confidence), and uses both IoU // and small‐box overlap tests to form clusters.