Skip to content

IoU Calculation Bug: IoU > 1 in Some Cases #5

Open
@npurson

Description

@npurson

When running calculate_iou with two depth maps, the computed IoU occasionally exceeds 1, which is mathematically incorrect. I suspect the issue originates from datasets_preprocess/scannetpp_preprocess.py#L200:

union = torch.sum(valid_mask) + torch.sum(depth2 > 0) - intersection

Here, torch.sum(depth2 > 0) counts all non-zero depth points in depth2, rather than only those corresponding to the projected depth1 pixels. As a result, this can underestimate union, leading to an IoU value greater than 1.

To correct this, I believe the calculation should be adjusted as follows:

valid_depth2_mask = depth2[pixels_img2[:, 1], pixels_img2[:, 0]] > 0
union = torch.sum(valid_mask) + torch.sum(valid_depth2_mask) - intersection

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