finish partial_global inference
This commit is contained in:
@@ -88,26 +88,49 @@ class NBVReconstructionPipeline(nn.Module):
|
||||
scanned_n_to_world_pose_9d_batch = data[
|
||||
"scanned_n_to_world_pose_9d"
|
||||
] # List(B): Tensor(S x 9)
|
||||
scanned_pts_mask_batch = data["scanned_pts_mask"] # List(B): Tensor(S x N)
|
||||
|
||||
device = next(self.parameters()).device
|
||||
|
||||
embedding_list_batch = []
|
||||
|
||||
combined_scanned_pts_batch = data["combined_scanned_pts"] # Tensor(B x N x 3)
|
||||
global_scanned_feat = self.pts_encoder.encode_points(
|
||||
combined_scanned_pts_batch, require_per_point_feat=False
|
||||
global_scanned_feat, per_point_feat_batch = self.pts_encoder.encode_points(
|
||||
combined_scanned_pts_batch, require_per_point_feat=True
|
||||
) # global_scanned_feat: Tensor(B x Dg)
|
||||
|
||||
for scanned_n_to_world_pose_9d in scanned_n_to_world_pose_9d_batch:
|
||||
scanned_n_to_world_pose_9d = scanned_n_to_world_pose_9d.to(device) # Tensor(S x 9)
|
||||
batch_size = len(scanned_n_to_world_pose_9d_batch)
|
||||
for i in range(batch_size):
|
||||
seq_len = len(scanned_n_to_world_pose_9d_batch[i])
|
||||
scanned_n_to_world_pose_9d = scanned_n_to_world_pose_9d_batch[i].to(device) # Tensor(S x 9)
|
||||
scanned_pts_mask = scanned_pts_mask_batch[i] # Tensor(S x N)
|
||||
per_point_feat = per_point_feat_batch[i] # Tensor(N x Dp)
|
||||
partial_point_feat_seq = []
|
||||
for j in range(seq_len):
|
||||
partial_per_point_feat = per_point_feat[scanned_pts_mask[j]]
|
||||
if partial_per_point_feat.shape[0] == 0:
|
||||
partial_point_feat = torch.zeros(per_point_feat.shape[1], device=device)
|
||||
else:
|
||||
partial_point_feat = torch.mean(partial_per_point_feat, dim=0) # Tensor(Dp)
|
||||
partial_point_feat_seq.append(partial_point_feat)
|
||||
partial_point_feat_seq = torch.stack(partial_point_feat_seq, dim=0) # Tensor(S x Dp)
|
||||
|
||||
pose_feat_seq = self.pose_encoder.encode_pose(scanned_n_to_world_pose_9d) # Tensor(S x Dp)
|
||||
seq_embedding = pose_feat_seq
|
||||
|
||||
seq_embedding = torch.cat([partial_point_feat_seq, pose_feat_seq], dim=-1)
|
||||
|
||||
embedding_list_batch.append(seq_embedding) # List(B): Tensor(S x (Dp))
|
||||
|
||||
seq_feat = self.seq_encoder.encode_sequence(embedding_list_batch) # Tensor(B x Ds)
|
||||
main_feat = torch.cat([seq_feat, global_scanned_feat], dim=-1) # Tensor(B x (Ds+Dg))
|
||||
|
||||
if torch.isnan(main_feat).any():
|
||||
for i in range(len(main_feat)):
|
||||
if torch.isnan(main_feat[i]).any():
|
||||
scanned_pts_mask = scanned_pts_mask_batch[i]
|
||||
Log.info(f"scanned_pts_mask shape: {scanned_pts_mask.shape}")
|
||||
Log.info(f"scanned_pts_mask sum: {scanned_pts_mask.sum()}")
|
||||
import ipdb
|
||||
ipdb.set_trace()
|
||||
Log.error("nan in main_feat", True)
|
||||
|
||||
return main_feat
|
||||
return main_feat
|
Reference in New Issue
Block a user