Skip to content

Commit

Permalink
Add __repr__ for NMSAgent
Browse files Browse the repository at this point in the history
  • Loading branch information
AnirudhRahul committed Jun 13, 2024
1 parent f23ce88 commit b91950e
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions overeasy/models/detection/nms.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from overeasy.types import Detections, DetectionType, DetectionAgent
import cv2
import numpy as np

def do_nms(dets: Detections, nms_threshold: float, score_threshold : float = 0.0) -> Detections:
if dets.detection_type != DetectionType.BOUNDING_BOX:
Expand All @@ -16,11 +15,16 @@ def do_nms(dets: Detections, nms_threshold: float, score_threshold : float = 0.0
return dets[indices]

class NMSAgent(DetectionAgent):
def __init__(self, iou_threshold: float, score_threshold: float):
# IoU (Intersection over Union) Threshold: Determines the minimum overlap between two bounding boxes to consider them as the same object.
# Score Threshold: Filters out detections that have a confidence score below this value before applying NMS.
def __init__(self, iou_threshold: float, score_threshold: float = 0.0):
self.iou_threshold = iou_threshold
self.score_threshold = score_threshold

def execute(self, dets: Detections) -> Detections:
if dets.detection_type != DetectionType.BOUNDING_BOX:
raise ValueError("Only bounding box detections are supported for NMS.")
return do_nms(dets, self.iou_threshold, self.score_threshold)

def __repr__(self):
return f"NMSAgent(iou_threshold={self.iou_threshold}, score_threshold={self.score_threshold})"

0 comments on commit b91950e

Please sign in to comment.