Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
Updated soft nms so that area index is computed instead of hard coded
  • Loading branch information
kuba-conceptual committed Dec 3, 2024
1 parent 635c397 commit 15cdad2
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion net/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,8 @@ def get_detections_after_soft_non_maximum_suppression(detections, sigma, score_t
# x_min, y_min, x_max, y_max, score, area
detections = np.concatenate([detections, areas.reshape(-1, 1)], axis=1)

areas_index = detections.shape[1] - 1

retained_detections = []

while detections.size > 0:
Expand All @@ -544,7 +546,8 @@ def get_detections_after_soft_non_maximum_suppression(detections, sigma, score_t
overlap_height = np.maximum(max_y - min_y + 1, 0.0)

intersection_area = overlap_width * overlap_height
intersection_over_union = intersection_area / (detections[0, 5] + detections[1:, 5] - intersection_area)
intersection_over_union = \
intersection_area / (detections[0, areas_index] + detections[1:, areas_index] - intersection_area)

# Update detections scores for all detections other than max score - we don't want to affect its score.
# Scores are updated using an exponential function such that detections that have no intersection with top
Expand Down

0 comments on commit 15cdad2

Please sign in to comment.