yolo_v1_pytorch
yolo_v1_pytorch copied to clipboard
the error of compute_iou in loss.py
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
这确实是错误了,好像很多人的代码也这么祖传的错下去