The compute_iou() function in perceptionmetrics/utils/detection_metrics.py divides by (boxAArea + boxBArea - interArea) without checking for zero. When both boxes have zero area (e.g. degenerate/point boxes like [5, 5, 5, 5]), this causes a ZeroDivisionError.
Reproducing -
from perceptionmetrics.utils.detection_metrics import compute_iou
compute_iou([5, 5, 5, 5], [5, 5, 5, 5]) # ZeroDivisionError
Should return 0.0 for zero-area boxes, consistent with the vectorized compute_iou_matrix() which already has a np.maximum(union_area, 1e-8) guard.
Working on a PR to fix this.
The
compute_iou()function inperceptionmetrics/utils/detection_metrics.pydivides by(boxAArea + boxBArea - interArea)without checking for zero. When both boxes have zero area (e.g. degenerate/point boxes like[5, 5, 5, 5]), this causes aZeroDivisionError.Reproducing -
Should return 0.0 for zero-area boxes, consistent with the vectorized compute_iou_matrix() which already has a np.maximum(union_area, 1e-8) guard.
Working on a PR to fix this.