Skip to content

Commit 7b6a3ea

Browse files
fix _box_inter_union for "xywh" format
1 parent 55193f2 commit 7b6a3ea

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

torchvision/ops/boxes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ def _box_inter_union(boxes1: Tensor, boxes2: Tensor, fmt: str = "xyxy") -> tuple
351351
rb = torch.min(boxes1[:, None, 2:], boxes2[:, 2:]) # [N,M,2]
352352
elif fmt == "xywh":
353353
lt = torch.max(boxes1[:, None, :2], boxes2[:, :2]) # [N,M,2]
354-
rb = torch.min(boxes1[:, None, :2] + boxes1[:, None, 2:] / 2, boxes2[:, :2] + boxes2[:, 2:] / 2) # [N,M,2]
354+
rb = torch.min(boxes1[:, None, :2] + boxes1[:, None, 2:], boxes2[:, :2] + boxes2[:, 2:]) # [N,M,2]
355355
else: # fmt == "cxcywh":
356356
lt = torch.max(boxes1[:, None, :2] - boxes1[:, None, 2:] / 2, boxes2[:, :2] - boxes2[:, 2:] / 2) # [N,M,2]
357357
rb = torch.min(boxes1[:, None, :2] + boxes1[:, None, 2:] / 2, boxes2[:, :2] + boxes2[:, 2:] / 2) # [N,M,2]

0 commit comments

Comments
 (0)