def forward(self, pointcloud: torch.cuda.FloatTensor, return_all=False): pointcloud = pointcloud.transpose(1, 2).contiguous() li_xyz, li_features = self._break_up_pc(pointcloud) # B,C,N # l_xyz, l_features = [xyz], [li_features] l_xyz, l_features = [], [] for i in range(len(self.SA_modules)): # Pointnetmodule + MLP + maxpool li_xyz, li_features = self.SA_modules[i](li_xyz, li_features) li_features_post = self.postSA_mlp[i](li_features) l_xyz.append(li_xyz) l_features.append(li_features_post) # max pool (B,4*#SA,1) all SAmodules # exclude the first None features global_code = torch.cat( [torch.max(l_feat, dim=-1)[0] for l_feat in l_features], dim=1) l_features.append(global_code) l_xyz.append(None) if return_all: return l_features, l_xyz else: return global_code
def forward(self, pointcloud: torch.cuda.FloatTensor): r""" Forward pass of the network Parameters ---------- pointcloud: Variable(torch.cuda.FloatTensor) (B, N, 3 + input_channels) tensor Point cloud to run predicts on Each point in the point-cloud MUST be formated as (x, y, z, features...) """ pointcloud = pointcloud.transpose(1, 2) xyz, features = self._break_up_pc(pointcloud) cls = torch.zeros(pointcloud.size(0), 16).cuda() l_xyz, l_features = [xyz], [features] for i in range(len(self.SA_modules)): if i < 5: li_xyz, li_features = self.SA_modules[i](l_xyz[i], l_features[i]) if li_xyz is not None: random_index = np.arange(li_xyz.size()[1]) np.random.shuffle(random_index) li_xyz = li_xyz[:, random_index, :] li_features = li_features[:, :, random_index] l_xyz.append(li_xyz) l_features.append(li_features) _, global_out2_feat = self.SA_modules[5](l_xyz[3], l_features[3]) for i in range(-1, -(len(self.FP_modules) + 1), -1): l_features[i - 1 - 1] = self.FP_modules[i](l_xyz[i - 1 - 1], l_xyz[i - 1], l_features[i - 1 - 1], l_features[i - 1]) cls = cls.view(-1, 16, 1).repeat( 1, 1, l_features[0].size()[2]) # object class one-hot-vector l_features[0] = torch.cat( (l_features[0], l_features[-1].repeat(1, 1, l_features[0].size()[2]), global_out2_feat.repeat(1, 1, l_features[0].size()[2]), cls), 1) return self.FC_layer(l_features[0]).transpose(1, 2).contiguous()
def forward(self, pointcloud: torch.cuda.FloatTensor): r""" Forward pass of the network Parameters ---------- pointcloud: Variable(torch.cuda.FloatTensor) (B, N, 3 + input_channels) tensor Point cloud to run predicts on Each point in the point-cloud MUST be formated as (x, y, z, features...) """ pointcloud = pointcloud.transpose(1, 2) xyz, features = self._break_up_pc(pointcloud) for module in self.SA_modules: xyz, features = module(xyz, features) logits = self.FC_layer(features.squeeze(-1)) #print(logits) return logits, None