示例#1
0
def ddd_decode(heat, rot, dim, pc_range, ground, wh=None, reg=None, K=40):
    batch, cat, height, width = heat.size()
    # heat = torch.sigmoid(heat)
    # perform nms on heatmaps
    heat = _nms(heat)

    scores, inds, clses, ys, xs = _topk(heat, K=K)
    reg = _tranpose_and_gather_feat(reg, inds)
    reg = reg.view(batch, K, 2)
    xs = xs.view(batch, K, 1) + reg[:, :, 0:1]
    ys = ys.view(batch, K, 1) + reg[:, :, 1:2]

    rot = _tranpose_and_gather_feat(rot, inds)
    rot = rot.view(batch, K, 8)
    dim = _tranpose_and_gather_feat(dim, inds)
    dim = dim.view(batch, K, 3)
    clses = clses.view(batch, K, 1).float()
    scores = scores.view(batch, K, 1)
    xs = xs.view(batch, K, 1)
    ys = ys.view(batch, K, 1)

    # correct the x,y,z dimensions
    xmin, ymin, zmin, xmax, ymax, _ = pc_range
    xs = xs * (xmax - xmin) / (width - 1) + xmin
    ys = ys * (ymax - ymin) / (height - 1) + ymin
    lowest = torch.tensor(ground, device="cuda:0",
                          dtype=torch.float32)  #.unsqueeze(1).unsqueeze(1)
    zs = lowest[:, None, None] + dim[:, :, 2:3] / 2  # add gound plane here

    return torch.cat([xs, ys, zs, dim, rot, scores, clses], dim=2)
示例#2
0
 def forward(self, output, mask, ind, target):
   pred = _tranpose_and_gather_feat(output, ind)
   mask = mask.float()
   # loss = F.l1_loss(pred * mask, target * mask, reduction='elementwise_mean')
   loss = F.l1_loss(pred * mask, target * mask, size_average=False)
   loss = loss / (mask.sum() + 1e-4)
   return loss
示例#3
0
 def forward(self, output, mask, ind, target):
   pred = _tranpose_and_gather_feat(output, ind)
   mask = mask.unsqueeze(2).expand_as(pred).float()
   # loss = F.l1_loss(pred * mask, target * mask, reduction='elementwise_mean')
   pred = pred / (target + 1e-4)
   target = target * 0 + 1
   loss = F.l1_loss(pred * mask, target * mask, size_average=False)
   loss = loss / (mask.sum() + 1e-4)
   return loss
示例#4
0
 def forward(self, output, mask, ind, rotbin, rotres):
   pred = _tranpose_and_gather_feat(output, ind)
   loss = compute_rot_loss(pred, rotbin, rotres, mask)
   return loss
示例#5
0
 def forward(self, output, mask, ind, target):
   pred = _tranpose_and_gather_feat(output, ind)
   mask = mask.unsqueeze(2).expand_as(pred).float()
   loss = F.l1_loss(pred * mask, target * mask, reduction='elementwise_mean')
   return loss
示例#6
0
 def forward(self, output, mask, ind, target):
   pred = _tranpose_and_gather_feat(output, ind)
   loss = _reg_loss(pred, target, mask)
   return loss