Update IoU capitalization (#8604)
Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com> Co-authored-by: Dean Mark <2552482+deanmark@users.noreply.github.com>
This commit is contained in:
parent
e0b8b36967
commit
1146bb0582
8 changed files with 16 additions and 16 deletions
|
|
@ -24,7 +24,7 @@ def bbox_ioa(box1, box2, iou=False, eps=1e-7):
|
|||
Args:
|
||||
box1 (np.ndarray): A numpy array of shape (n, 4) representing n bounding boxes.
|
||||
box2 (np.ndarray): A numpy array of shape (m, 4) representing m bounding boxes.
|
||||
iou (bool): Calculate the standard iou if True else return inter_area/box2_area.
|
||||
iou (bool): Calculate the standard IoU if True else return inter_area/box2_area.
|
||||
eps (float, optional): A small value to avoid division by zero. Defaults to 1e-7.
|
||||
|
||||
Returns:
|
||||
|
|
@ -194,7 +194,7 @@ def _get_covariance_matrix(boxes):
|
|||
|
||||
def probiou(obb1, obb2, CIoU=False, eps=1e-7):
|
||||
"""
|
||||
Calculate the prob iou between oriented bounding boxes, https://arxiv.org/pdf/2106.06072v1.pdf.
|
||||
Calculate the prob IoU between oriented bounding boxes, https://arxiv.org/pdf/2106.06072v1.pdf.
|
||||
|
||||
Args:
|
||||
obb1 (torch.Tensor): A tensor of shape (N, 5) representing ground truth obbs, with xywhr format.
|
||||
|
|
@ -233,7 +233,7 @@ def probiou(obb1, obb2, CIoU=False, eps=1e-7):
|
|||
|
||||
def batch_probiou(obb1, obb2, eps=1e-7):
|
||||
"""
|
||||
Calculate the prob iou between oriented bounding boxes, https://arxiv.org/pdf/2106.06072v1.pdf.
|
||||
Calculate the prob IoU between oriented bounding boxes, https://arxiv.org/pdf/2106.06072v1.pdf.
|
||||
|
||||
Args:
|
||||
obb1 (torch.Tensor | np.ndarray): A tensor of shape (N, 5) representing ground truth obbs, with xywhr format.
|
||||
|
|
|
|||
|
|
@ -147,7 +147,7 @@ def nms_rotated(boxes, scores, threshold=0.45):
|
|||
Args:
|
||||
boxes (torch.Tensor): (N, 5), xywhr.
|
||||
scores (torch.Tensor): (N, ).
|
||||
threshold (float): Iou threshold.
|
||||
threshold (float): IoU threshold.
|
||||
|
||||
Returns:
|
||||
"""
|
||||
|
|
@ -287,7 +287,7 @@ def non_max_suppression(
|
|||
# if merge and (1 < n < 3E3): # Merge NMS (boxes merged using weighted mean)
|
||||
# # Update boxes as boxes(i,4) = weights(i,n) * boxes(n,4)
|
||||
# from .metrics import box_iou
|
||||
# iou = box_iou(boxes[i], boxes) > iou_thres # iou matrix
|
||||
# iou = box_iou(boxes[i], boxes) > iou_thres # IoU matrix
|
||||
# weights = iou * scores[None] # box weights
|
||||
# x[i, :4] = torch.mm(weights, x[:, :4]).float() / weights.sum(1, keepdim=True) # merged boxes
|
||||
# redundant = True # require redundant detections
|
||||
|
|
|
|||
|
|
@ -121,7 +121,7 @@ class TaskAlignedAssigner(nn.Module):
|
|||
return align_metric, overlaps
|
||||
|
||||
def iou_calculation(self, gt_bboxes, pd_bboxes):
|
||||
"""Iou calculation for horizontal bounding boxes."""
|
||||
"""IoU calculation for horizontal bounding boxes."""
|
||||
return bbox_iou(gt_bboxes, pd_bboxes, xywh=False, CIoU=True).squeeze(-1).clamp_(0)
|
||||
|
||||
def select_topk_candidates(self, metrics, largest=True, topk_mask=None):
|
||||
|
|
@ -231,7 +231,7 @@ class TaskAlignedAssigner(nn.Module):
|
|||
@staticmethod
|
||||
def select_highest_overlaps(mask_pos, overlaps, n_max_boxes):
|
||||
"""
|
||||
If an anchor box is assigned to multiple gts, the one with the highest IoI will be selected.
|
||||
If an anchor box is assigned to multiple gts, the one with the highest IoU will be selected.
|
||||
|
||||
Args:
|
||||
mask_pos (Tensor): shape(b, n_max_boxes, h*w)
|
||||
|
|
@ -260,7 +260,7 @@ class TaskAlignedAssigner(nn.Module):
|
|||
|
||||
class RotatedTaskAlignedAssigner(TaskAlignedAssigner):
|
||||
def iou_calculation(self, gt_bboxes, pd_bboxes):
|
||||
"""Iou calculation for rotated bounding boxes."""
|
||||
"""IoU calculation for rotated bounding boxes."""
|
||||
return probiou(gt_bboxes, pd_bboxes).squeeze(-1).clamp_(0)
|
||||
|
||||
@staticmethod
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue