MCPcopy Create free account
hub / github.com/openai/point-e / forward

Method forward

point_e/evals/pointnet2_utils.py:263–301  ·  view source on GitHub ↗

Input: xyz: input points position data, [B, C, N] points: input points data, [B, D, N] Return: new_xyz: sampled points position data, [B, C, S] new_points_concat: sample points feature data, [B, D', S]

(self, xyz, points)

Source from the content-addressed store, hash-verified

261 self.bn_blocks.append(bns)
262
263 def forward(self, xyz, points):
264 """
265 Input:
266 xyz: input points position data, [B, C, N]
267 points: input points data, [B, D, N]
268 Return:
269 new_xyz: sampled points position data, [B, C, S]
270 new_points_concat: sample points feature data, [B, D', S]
271 """
272 xyz = xyz.permute(0, 2, 1)
273 if points is not None:
274 points = points.permute(0, 2, 1)
275
276 B, N, C = xyz.shape
277 S = self.npoint
278 new_xyz = index_points(xyz, farthest_point_sample(xyz, S, deterministic=not self.training))
279 new_points_list = []
280 for i, radius in enumerate(self.radius_list):
281 K = self.nsample_list[i]
282 group_idx = query_ball_point(radius, K, xyz, new_xyz)
283 grouped_xyz = index_points(xyz, group_idx)
284 grouped_xyz -= new_xyz.view(B, S, 1, C)
285 if points is not None:
286 grouped_points = index_points(points, group_idx)
287 grouped_points = torch.cat([grouped_points, grouped_xyz], dim=-1)
288 else:
289 grouped_points = grouped_xyz
290
291 grouped_points = grouped_points.permute(0, 3, 2, 1) # [B, D, K, S]
292 for j in range(len(self.conv_blocks[i])):
293 conv = self.conv_blocks[i][j]
294 bn = self.bn_blocks[i][j]
295 grouped_points = F.relu(bn(conv(grouped_points)))
296 new_points = torch.max(grouped_points, 2)[0] # [B, D', S]
297 new_points_list.append(new_points)
298
299 new_xyz = new_xyz.permute(0, 2, 1)
300 new_points_concat = torch.cat(new_points_list, dim=1)
301 return new_xyz, new_points_concat
302
303
304class PointNetFeaturePropagation(nn.Module):

Callers

nothing calls this directly

Calls 3

index_pointsFunction · 0.85
farthest_point_sampleFunction · 0.85
query_ball_pointFunction · 0.85

Tested by

no test coverage detected