Skip to content

Fix #521: Handle zero-area boxes in compute_iou to prevent ZeroDivisionError#522

Open
Armaan-Raisinghani wants to merge 1 commit intoJdeRobot:masterfrom
Armaan-Raisinghani:fix/compute-iou-zero-area-division
Open

Fix #521: Handle zero-area boxes in compute_iou to prevent ZeroDivisionError#522
Armaan-Raisinghani wants to merge 1 commit intoJdeRobot:masterfrom
Armaan-Raisinghani:fix/compute-iou-zero-area-division

Conversation

@Armaan-Raisinghani
Copy link
Copy Markdown
Contributor

Fixes: #521

Changes:

  • Added zero-union guard in compute_iou() to return 0.0 instead of crashing
  • Added test_compute_iou_zero_area_boxes test covering point boxes, mixed zero/normal boxes, non-overlapping boxes, and perfect overlap

Before:

iou = interArea / float(boxAArea + boxBArea - interArea)  # ZeroDivisionError on point boxes

After:

iou = interArea / union if union > 0 else 0.0

This is consistent with the existing guard in compute_iou_matrix()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

compute_iou crashes with ZeroDivisionError on zero-area boxes

1 participant