traveller59 / second.pytorch

SECOND for KITTI/NuScenes object detection
MIT License
1.72k stars 722 forks source link

How does direction classification work #165

Open lih627 opened 5 years ago

lih627 commented 5 years ago

In the code in voxelnet.py for inference:

                if self._use_direction_classifier:
                    dir_labels = selected_dir_labels
                    opp_labels = (box_preds[..., -1] > 0) ^ dir_labels.byte()
                    box_preds[..., -1] += torch.where(
                        opp_labels,
                        torch.tensor(np.pi).type_as(box_preds),
                        torch.tensor(0.0).type_as(box_preds))

I am not sure how the direction classification works.

  1. Kitti rotation_y is between [-pi, pi]. If rotation_y = pi/2, does it means the car facing z-axis ( positive direction ) in camera coordinate system?

  2. Does direction classification classify that the car is face to me or away from me? For example, if the dir_reg is 1.0 (or -1.0 ) . what the difference in final direction between dir_cls =0 and dir_cls =1. Should I use function map the final direction in [-pi, pi]

Thanks a lot.

traveller59 commented 5 years ago

the dir classifier only determine if rotation_z > 0 in ground-truth in lidar coordinate system. the box_preds[..., -1] is prediction of rotation_z, if dir label of predicted rotation_z (box_preds[..., -1] > 0) is different from dir classifier, this means we need to add pi to predicted rotation_z.

it should only be used when using sin rotation loss because e and e + pi generate same rot loss.

mtshikomba commented 4 years ago

How can I fix this #350 ?

I am using the nuscenes dataset.