Lightning-AI / Lightning-AI/torchmetrics

One-sided empty inputs are weighted inconsistently in intersection metrics

Open
#3,493 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
2.5k
Forks
526
Avg merge
6d 11h
Merged PRs (30d)
5

Description

I ran into two related one-sided empty cases in the class-based IoU, GIoU, DIoU, and CIoU metrics.

With `respect_labels=False`, one perfect match plus two unmatched boxes returns `0.2` instead of `1/3`. With `class_metrics=True`, predictions against an empty target also raise.

I checked #2805 and #2806. Those fixed the original empty-input behavior, but these cases remain. I have a small fix and regression tests ready across all four metrics, both empty directions, both label modes, and class metrics on/off :)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the class-based IoU, GIoU, DIoU, and CIoU metric implementations and their existing tests. Reproduce both one-sided empty-input cases with respect_labels and class_metrics enabled and disabled, then add regression coverage for both empty directions; done means all four metrics return the intended values without raising.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, pytorch
Domain
machine-learning, testing-qa
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.