Skip to content

youngx123/YOLOV1

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

学习yolov1标签分配的思想以及按照自己理解重写损失函数

w, h 是相对于训练图像的大小而cx,cy是相对于特征图的大小因此在计算iou 应将cx,cy也转
换为相对于图像大小最终标签和预测结果的iou计算都是使用相对于输入图像大小cxy = box / width ==> 坐标归一化
cxcy = cxy *gridSize ==>在特征图上的坐标大小

cxy = cxcy / gridSize ==> 特征图上坐标和训练图像坐标关系

cx, cy = grids * gtItem[0, :2]
w, h, class_Num = gtItem[0, 2:]
gx, gy = cx.long(), cy.long()
offx = cx - gx
offy = cy - gy
offw, offh = w, h
				
# convert cxcywh to x1y1x2y2 format
pred_box = predcxywh[bszie, :, gy, gx][..., 1:]  # [bi, 2, 4]
pred_xy = torch.FloatTensor(pred_box.size())
pred_xy[:, 0:2] = pred_box[:, :2] / float(grids) - 0.5 * pred_box[:, 2:4]
pred_xy[:, 2:4] = pred_box[:, :2] / float(grids) + 0.5 * pred_box[:, 2:4]

target_xy = torch.zeros(1, 4)
target_xy[:, 0] = offx / float(grids) - 0.5 * offw  # # 特征图上坐标偏移转为训练图像上的坐标偏移
target_xy[:, 1] = offy / float(grids) - 0.5 * offh
target_xy[:, 2] = offx / float(grids) + 0.5 * offw
target_xy[:, 3] = offy / float(grids) + 0.5 * offh

# # 真实标签和预测结果的最佳匹配
iou_score = self.Batch_Iou(pred_xy, target_xy)

https://github.com/abeardear/pytorch-YOLO-v1

About

yolov1 learning and note

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages