Skip to content

compute_iou crashes with ZeroDivisionError on zero-area boxes #521

@Armaan-Raisinghani

Description

@Armaan-Raisinghani

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions