Giter VIP home page Giter VIP logo

yolov1's Introduction

学习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

yolov1's People

Contributors

youngx123 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.