abeardear / pytorch-YOLO-v1

an experiment for yolo-v1, including training and testing.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

这里操作是不是有问题?

pkuyilong opened this issue · comments

box1_xyxy[:, :2] = box1[:, :2] / 14. - 0.5 * box1[:, 2:4]
box1_xyxy[:, 2:4] = box1[:, :2] / 14. + 0.5 * box1[:, 2:4]
box2 = box_target[i].view(-1, 5)
box2_xyxy = Variable(torch.FloatTensor(box2.size()))
box2_xyxy[:, :2] = box2[:, :2] / 14. - 0.5 * box2[:, 2:4]
box2_xyxy[:, 2:4] = box2[:, :2] / 14. + 0.5 * box2[:, 2:4]

这里预测出来的xywh应该都是[0-1],这里除以14没有意义吧

@xiongzihua 如果有空恳请交流一下。

commented

@pkuyilong
box1[:, :2]是在0-1之间,预测的是相对该网格左上角的x1,y1,是相对于网格的0-1。
box1[:, 2:4]也在0-1,预测的是wh,是相对全图的0-1。
计算IOU时,除以14将x1,y1的坐标从网格视角转换到全图视角,不知道这样能不能理解,代码的意图就是这样的,不知道是否合理,你可以继续思考一下,希望对你有所帮助

@pkuyilong do you understand the idea of the author?

@xiongzihua 能举个例子说明这种计算的正确性吗?

@pkuyilong do you understand the idea of the author?

Training phrase:
the prediction generated from model is 14 x 14,
the ground truth is scaled by origin image size(maybe 480 x 480),
so when calculating the loss, we need to divide the prediction data by 14, which is equal to scale the prediction data by origin image size.

@pkuyilong
box1[:, :2]是在0-1之间,预测的是相对该网格左上角的x1,y1,是相对于网格的0-1。
box1[:, 2:4]也在0-1,预测的是wh,是相对全图的0-1。
计算IOU时,除以14将x1,y1的坐标从网格视角转换到全图视角,不知道这样能不能理解,代码的意图就是这样的,不知道是否合理,你可以继续思考一下,希望对你有所帮助

又看了一会代码,差不多可以理解了,谢谢🙏