Esempio n. 1
0
 def boxLossEstimator(self, box_feature, gt_box_feature):
     pred_box_pc = transform_pc_batch(self.unit_cube, box_feature)
     with torch.no_grad():
         pred_reweight = get_surface_reweighting_batch(box_feature[:, 3:6], self.unit_cube.size(0))
     gt_box_pc = transform_pc_batch(self.unit_cube, gt_box_feature)
     with torch.no_grad():
         gt_reweight = get_surface_reweighting_batch(gt_box_feature[:, 3:6], self.unit_cube.size(0))
     dist1, dist2 = self.chamferLoss(gt_box_pc, pred_box_pc)
     loss1 = (dist1 * gt_reweight).sum(dim=1) / (gt_reweight.sum(dim=1) + 1e-12)
     loss2 = (dist2 * pred_reweight).sum(dim=1) / (pred_reweight.sum(dim=1) + 1e-12)
     loss = (loss1 + loss2) / 2
     return loss
Esempio n. 2
0
    def get_box_loss(self, box_size, quat1, quat2, center1, center2):
        box1 = torch.cat([center1, box_size, quat1], dim=-1)
        box2 = torch.cat([center2, box_size, quat2], dim=-1)

        box1_pc = transform_pc_batch(self.unit_cube, box1)
        box2_pc = transform_pc_batch(self.unit_cube, box2)

        with torch.no_grad():
            box1_reweight = get_surface_reweighting_batch(
                box1[:, 3:6], self.unit_cube.size(0))
            box2_reweight = get_surface_reweighting_batch(
                box2[:, 3:6], self.unit_cube.size(0))

        d1, d2 = chamfer_distance(box1_pc, box2_pc, transpose=False)
        loss_per_data =  (d1 * box1_reweight).sum(dim=1) / (box1_reweight.sum(dim=1) + 1e-12) + \
                (d2 * box2_reweight).sum(dim=1) / (box2_reweight.sum(dim=1) + 1e-12)
        return loss_per_data