Skip to content

Commit

Permalink
iou compute in cuda fix (#1982)
Browse files Browse the repository at this point in the history
* iou compute in cuda fix

* chlog

---------

Co-authored-by: Jirka Borovec <6035284+Borda@users.noreply.github.com>
  • Loading branch information
Vivswan and Borda authored Aug 7, 2023
1 parent f3caa76 commit cd7ef55
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed

-
- Fixed IOU compute in cuda ([#1982](https://github.com/Lightning-AI/torchmetrics/pull/1982))


## [1.0.2] - 2023-08-02
Expand Down
2 changes: 1 addition & 1 deletion src/torchmetrics/functional/detection/iou.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def _iou_update(
def _iou_compute(iou: torch.Tensor, labels_eq: bool = True) -> torch.Tensor:
if labels_eq:
return iou.diag().mean()
return iou.mean() if iou.numel() > 0 else torch.tensor(0.0)
return iou.mean() if iou.numel() > 0 else torch.tensor(0.0).to(iou.device)


def intersection_over_union(
Expand Down

0 comments on commit cd7ef55

Please sign in to comment.