def build_pointnet(self, cfg): """Copy channel list because PointNet modifies it in-place.""" pnet = PointnetSAModuleMSG( npoint=-1, radii=cfg.GRIDPOOL.RADII_PN, nsamples=cfg.SAMPLES_PN, mlps=deepcopy(cfg.GRIDPOOL.MLPS_PN), use_xyz=True, ) return pnet
def build_pointnet(self, cfg): """Copy channel list because PointNet modifies it in-place.""" pnet = PointnetSAModuleMSG( npoint=-1, radii=cfg.gridpool_radii, nsamples=cfg.gridpool_samples, mlps=cfg.gridpool_mlps.copy(), use_xyz=True, ) return pnet
def build_pointnets(self, cfg): """Copy list because PointNet modifies it in-place.""" pnets = [] for i, mlps in enumerate(cfg.PSA.MLPS): pnets += [PointnetSAModuleMSG( npoint=-1, radii=cfg.PSA.RADII[i], nsamples=cfg.SAMPLES_PN, mlps=deepcopy(mlps), use_xyz=True, )] return nn.Sequential(*pnets)
def __init__(self, input_channels=6, do_interpolation=False): super().__init__() print('PNv2_ASAP-1') self.do_interpolation = do_interpolation self.SA_modules = nn.ModuleList() channel_in = input_channels skip_channel_list = [input_channels] for k in range(NPOINTS.__len__()): mlps = MLPS[k].copy() channel_out = 0 for idx in range(mlps.__len__()): mlps[idx] = [channel_in] + mlps[idx] channel_out += mlps[idx][-1] self.SA_modules.append( PointnetSAModuleMSG(npoint=NPOINTS[k], radii=RADIUS[k], nsamples=NSAMPLE[k], mlps=mlps, use_xyz=True, bn=True)) skip_channel_list.append(channel_out) channel_in = channel_out self.tem_sa1 = PointnetSAModule(mlp=MLP1, npoint=NPOINT1, nsample=NSAMPLE1, radius=RADIUS1) self.fuse_layer1_atten = nn.Conv1d(MLP1[-1] * 2, 2, kernel_size=1, stride=1) self.fuse_layer1 = nn.Conv1d(MLP1[-1], 384, kernel_size=1, stride=1) self.tem_fp1 = PointnetFPModule(mlp=FP_MLP1) self.tem_dropout = nn.Dropout(DP_RATIO) self.FP_modules = nn.ModuleList() for k in range(FP_MLPS.__len__()): pre_channel = FP_MLPS[ k + 1][-1] if k + 1 < len(FP_MLPS) else channel_out self.FP_modules.append( PointnetFPModule(mlp=[pre_channel + skip_channel_list[k]] + FP_MLPS[k])) cls_layers = [] pre_channel = FP_MLPS[0][-1] for k in range(0, CLS_FC.__len__()): cls_layers.append(pt_utils.Conv1d(pre_channel, CLS_FC[k], bn=True)) pre_channel = CLS_FC[k] cls_layers.append(pt_utils.Conv1d(pre_channel, 20, activation=None)) cls_layers.insert(1, nn.Dropout(0.5)) self.cls_layer = nn.Sequential(*cls_layers)
def build_pointnets(self, cfg): pnets = [] for i in range(len(cfg.strides)): pnets += [ PointnetSAModuleMSG( npoint=-1, radii=cfg.radii[i], nsamples=cfg.nsamples[i], mlps=cfg.mlps[i], use_xyz=True, ) ] return nn.Sequential(*pnets)
def build_pointnets(self, cfg): """Copy channel list because PointNet modifies it in-place.""" pnets = [] for i in range(len(cfg.mlps)): pnets += [ PointnetSAModuleMSG( npoint=-1, radii=cfg.radii[i], nsamples=cfg.nsamples[i], mlps=cfg.mlps[i].copy(), use_xyz=True, ) ] return nn.Sequential(*pnets)
def __init__(self, num_classes, input_channels=3, use_xyz=True): super(Pointnet2MSG, self).__init__() self.SA_modules = nn.ModuleList() self.SA_modules.append( PointnetSAModuleMSG( npoint=512, radii=[0.1, 0.2, 0.4], nsamples=[16, 32, 128], mlps=[ [input_channels, 32, 32, 64], [input_channels, 64, 64, 128], [input_channels, 64, 96, 128], ], use_xyz=use_xyz, )) input_channels = 64 + 128 + 128 self.SA_modules.append( PointnetSAModuleMSG( npoint=128, radii=[0.2, 0.4, 0.8], nsamples=[32, 64, 128], mlps=[ [input_channels, 64, 64, 128], [input_channels, 128, 128, 256], [input_channels, 128, 128, 256], ], use_xyz=use_xyz, )) self.SA_modules.append( PointnetSAModule(mlp=[128 + 256 + 256, 256, 512, 1024], use_xyz=use_xyz)) self.FC_layer = (pt_utils.Seq(1024).fc(512, bn=True).dropout(0.5).fc( 256, bn=True).dropout(0.5).fc(num_classes, activation=None))
def __init__(self, cfg): """ TODO: Read Pointnet params from config object. """ super(PV_RCNN, self).__init__() self.pnet = PointnetSAModuleMSG( npoint=-1, radii=[0.1, 0.5], nsamples=[16, 32], mlps=[[16, 32, 64], [16, 32, 128]], use_xyz=True, ) self.voxel_generator = spconv.utils.VoxelGenerator( voxel_size=cfg.voxel_size, point_cloud_range=cfg.grid_bounds, max_voxels=cfg.max_voxels, max_num_points=cfg.max_num_points, ) grid_shape = np.r_[self.voxel_generator.grid_size[::-1]] + [1, 0, 0] self.cnn = CNN_3D(C_in=cfg.C_in, grid_shape=grid_shape, cfg=cfg) self.cfg = cfg
def __init__(self, input_channels=6): super().__init__() self.SA_modules = nn.ModuleList() channel_in = input_channels skip_channel_list = [input_channels] for k in range(NPOINTS.__len__()): # k = 0,1,2,3 mlps = MLPS[k].copy() # mlps=MLPS[0], MLPS[1], MLPS[2], MLPS[3] channel_out = 0 for idx in range(mlps.__len__()): # idx = 0,1 mlps[idx] = [channel_in] + mlps[ idx] #mlps=[0] = [0, 16, 16, 32] mlps[1] = [0, 32, 32, 64] channel_out += mlps[idx][-1] # channel_out = 32+64 = 96 self.SA_modules.append( PointnetSAModuleMSG( npoint=NPOINTS[k], radii=RADIUS[k], nsamples=NSAMPLE[k], mlps=mlps, #[[0, 16, 16, 32], [0, 32, 32, 64]] use_xyz=True, bn=True)) skip_channel_list.append(channel_out) channel_in = channel_out self.FP_modules = nn.ModuleList() for k in range(FP_MLPS.__len__()): pre_channel = FP_MLPS[ k + 1][-1] if k + 1 < len(FP_MLPS) else channel_out self.FP_modules.append( PointnetFPModule(mlp=[pre_channel + skip_channel_list[k]] + FP_MLPS[k])) cls_layers = [] pre_channel = FP_MLPS[0][-1] for k in range(0, CLS_FC.__len__()): cls_layers.append(pt_utils.Conv1d(pre_channel, CLS_FC[k], bn=True)) pre_channel = CLS_FC[k] cls_layers.append(pt_utils.Conv1d(pre_channel, 1, activation=None)) cls_layers.insert(1, nn.Dropout(0.5)) self.cls_layer = nn.Sequential(*cls_layers)
def __init__(self, input_channels=6, out_dim=32, npoints=[4096, 1024, 256, 64], radius=[[0.1, 0.5], [0.5, 1.0], [1.0, 2.0], [2.0, 4.0]]): super().__init__() NPOINTS = npoints RADIUS = radius FP_MLPS[0] = [out_dim, out_dim] self.SA_modules = nn.ModuleList() channel_in = input_channels skip_channel_list = [input_channels] for k in range(NPOINTS.__len__()): mlps = MLPS[k].copy() channel_out = 0 for idx in range(mlps.__len__()): mlps[idx] = [channel_in] + mlps[idx] channel_out += mlps[idx][-1] self.SA_modules.append( PointnetSAModuleMSG(npoint=NPOINTS[k], radii=RADIUS[k], nsamples=NSAMPLE[k], mlps=mlps, use_xyz=True, bn=True)) skip_channel_list.append(channel_out) channel_in = channel_out self.FP_modules = nn.ModuleList() for k in range(FP_MLPS.__len__()): pre_channel = FP_MLPS[ k + 1][-1] if k + 1 < len(FP_MLPS) else channel_out self.FP_modules.append( PointnetFPModule(mlp=[pre_channel + skip_channel_list[k]] + FP_MLPS[k])) '''