Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

the error of compute_iou in loss.py #8

Open
StephenZhao1 opened this issue Feb 24, 2021 · 1 comment
Open

the error of compute_iou in loss.py #8

StephenZhao1 opened this issue Feb 24, 2021 · 1 comment

Comments

@StephenZhao1
Copy link

def compute_iou(self,bbox1,bbox2):
# 获取box1的第一个维度
N = bbox1.size(0)
# 获取box2的第一个维度
M = bbox2.size(0)
# Compute left-top coordinate of the intersections
#
lt = torch.max(
# [N, 2] -> [N, 1, 2] -> [N, M, 2]
bbox1[:,:2].unsqueeze(1).expand(N,M,2),
# [M, 2] -> [1, M, 2] -> [N, M, 2]
bbox2[:,:2].unsqueeze(0).expand(N,M,2)
)
rb = torch.min(
# [N, 2] -> [N, 1, 2] -> [N, M, 2]
bbox1[:, 2:].unsqueeze(1).expand(N, M, 2),
# [M, 2] -> [1, M, 2] -> [N, M, 2]
bbox2[:, 2:].unsqueeze(0).expand(N, M, 2)
)
pass

after torch.max(bbox1,bbox2),the point may be right top instead of left top
after torch.min(bbox1,bbox2),the point may be left bottom instead of right bottom

@xibici
Copy link

xibici commented May 3, 2023

这确实是错误了,好像很多人的代码也这么祖传的错下去

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants