MCG-NJU / CamLiFlow

[CVPR 2022 Oral & TPAMI 2023] Learning Optical Flow and Scene Flow with Bidirectional Camera-LiDAR Fusion
https://arxiv.org/abs/2303.12017
219 stars 21 forks source link

Question about the implementation of the ablation in the first row of table 8 in your pami version #13

Closed pkqbajng closed 1 year ago

pkqbajng commented 1 year ago

Hi, Thanks for your excellent work. In the table 8 of the pami version, you mentioned that the naive implementation is directly projecting 3D features on to image plane with empty locations filled by zeros. But I don't find the corresponding code in this project, could you please explain more about the details? For example, the coordinates will be decimal and is hard to process in the lower levels.

afterthat97 commented 1 year ago
@torch.no_grad()
def project_feat_plain(xy, feat_2d, feat3d):
    batch_size, n_channels_3d = feat3d.shape[:2]
    image_h, image_w = feat_2d.shape[2:]

    xy = xy.transpose(1, 2).clone().round().long()  # [bs, n_points, 2]
    xy[..., 0].clamp_(0, image_w - 1)
    xy[..., 1].clamp_(0, image_h - 1)

    indices_of_batch = torch.arange(batch_size, dtype=torch.long, device=xy.device)
    indices_of_batch = indices_of_batch.view([xy.shape[0], 1]).expand([xy.shape[0], xy.shape[1]])  # [bs, n_points]

    feat2d = torch.zeros([batch_size, n_channels_3d, image_h, image_w], device=xy.device)
    feat2d[indices_of_batch, :, xy[..., 1], xy[..., 0]] = feat3d.transpose(1, 2)

    return feat2d
pkqbajng commented 1 year ago

Thank you for your quickly response, I understand it, best wishes to your following research

afterthat97 commented 1 year ago

Thanks!