Skip to content

Commit

Permalink
process_batch() as numpy arrays (ultralytics#8254)
Browse files Browse the repository at this point in the history
Avoid potential issues with deterministic ops. 

[ ] - verify for identical mAP to master
  • Loading branch information
glenn-jocher authored and Clay Januhowski committed Sep 8, 2022
1 parent 0c073a5 commit b6f9d9a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions val.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def process_batch(detections, labels, iouv):
Returns:
correct (Array[N, 10]), for 10 IoU levels
"""
correct = torch.zeros(detections.shape[0], iouv.shape[0], dtype=torch.bool, device=iouv.device)
correct = np.zeros((detections.shape[0], iouv.shape[0])).astype(bool)
iou = box_iou(labels[:, 1:], detections[:, :4])
correct_class = labels[:, 0:1] == detections[:, 5]
for i in range(len(iouv)):
Expand All @@ -90,7 +90,7 @@ def process_batch(detections, labels, iouv):
# matches = matches[matches[:, 2].argsort()[::-1]]
matches = matches[np.unique(matches[:, 0], return_index=True)[1]]
correct[matches[:, 1].astype(int), i] = True
return correct
return torch.tensor(correct, dtype=torch.bool, device=iouv.device)


@torch.no_grad()
Expand Down

0 comments on commit b6f9d9a

Please sign in to comment.