Closed pkqbajng closed 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
Thank you for your quickly response, I understand it, best wishes to your following research
Thanks!
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.