Skip to content

Commit

Permalink
Fix semantic errors in code for calculating IoU metrics in Segmentati…
Browse files Browse the repository at this point in the history
…on evaluator.

Summary: While reading code for adding B-IoU metric for existing evaluator, discovered some semantic errors in existing code (iou_valid flag usage) and I fixed it. It's interesting that the issue has never been found / caught / reported.

Reviewed By: rbgirshick

Differential Revision: D37471657

fbshipit-source-id: 43b83b668e1ef04dba6fec355f4b7704a1a6cbea
  • Loading branch information
PradeepKadubandi authored and facebook-github-bot committed Jul 7, 2022
1 parent abef4c0 commit f3c1bc1
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions detectron2/evaluation/sem_seg_evaluation.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,12 +191,12 @@ def evaluate(self):
pos_pred = np.sum(self._conf_matrix[:-1, :-1], axis=1).astype(np.float)
acc_valid = pos_gt > 0
acc[acc_valid] = tp[acc_valid] / pos_gt[acc_valid]
iou_valid = (pos_gt + pos_pred) > 0
union = pos_gt + pos_pred - tp
iou[acc_valid] = tp[acc_valid] / union[acc_valid]
iou_valid = np.logical_and(acc_valid, union > 0)
iou[iou_valid] = tp[iou_valid] / union[iou_valid]
macc = np.sum(acc[acc_valid]) / np.sum(acc_valid)
miou = np.sum(iou[acc_valid]) / np.sum(iou_valid)
fiou = np.sum(iou[acc_valid] * class_weights[acc_valid])
miou = np.sum(iou[iou_valid]) / np.sum(iou_valid)
fiou = np.sum(iou[iou_valid] * class_weights[iou_valid])
pacc = np.sum(tp) / np.sum(pos_gt)

if self._compute_boundary_iou:
Expand Down

0 comments on commit f3c1bc1

Please sign in to comment.