def __init__(self, input_feature_dim=0, scale=1, use_mlp=False, mlp_dim=None): super().__init__() self.use_mlp = use_mlp self.sa1 = PointnetSAModuleVotes( npoint=2048, radius=0.2, nsample=64, mlp=[input_feature_dim, 64 * scale, 64 * scale, 128 * scale], use_xyz=True, normalize_xyz=True) self.sa2 = PointnetSAModuleVotes( npoint=1024, radius=0.4, nsample=32, mlp=[128 * scale, 128 * scale, 128 * scale, 256 * scale], use_xyz=True, normalize_xyz=True) self.sa3 = PointnetSAModuleVotes( npoint=512, radius=0.8, nsample=16, mlp=[256 * scale, 128 * scale, 128 * scale, 256 * scale], use_xyz=True, normalize_xyz=True) self.sa4 = PointnetSAModuleVotes( npoint=256, radius=1.2, nsample=16, mlp=[256 * scale, 128 * scale, 128 * scale, 256 * scale], use_xyz=True, normalize_xyz=True) if scale == 1: self.fp1 = PointnetFPModule(mlp=[256 + 256, 512, 512]) self.fp2 = PointnetFPModule(mlp=[512 + 256, 512, 512]) else: self.fp1 = PointnetFPModule( mlp=[256 * scale + 256 * scale, 256 * scale, 256 * scale]) self.fp2 = PointnetFPModule( mlp=[256 * scale + 256 * scale, 256 * scale, 256 * scale]) if use_mlp: self.head = MLP(mlp_dim) self.all_feat_names = [ "sa1", "sa2", "sa3", "sa4", "fp1", "fp2", ]
def __init__(self, input_feature_dim=0): super().__init__() self.sa1 = PointnetSAModuleVotes(npoint=2048, radius=0.2, nsample=64, mlp=[input_feature_dim, 64, 64, 128], use_xyz=True, normalize_xyz=True) self.sa2 = PointnetSAModuleVotes(npoint=1024, radius=0.4, nsample=32, mlp=[128, 128, 128, 256], use_xyz=True, normalize_xyz=True) self.sa3 = PointnetSAModuleVotes(npoint=512, radius=0.8, nsample=16, mlp=[256, 128, 128, 256], use_xyz=True, normalize_xyz=True) self.sa4 = PointnetSAModuleVotes(npoint=256, radius=1.2, nsample=16, mlp=[256, 128, 128, 256], use_xyz=True, normalize_xyz=True) self.fp1 = PointnetFPModule(mlp=[256 + 256, 256, 256]) self.fp2 = PointnetFPModule(mlp=[256 + 256, 256, 256])
def __init__(self, num_classes, input_channels=3): super().__init__() self.SA_modules = nn.ModuleList() self.SA_modules.append( PointnetSAModule(npoint=1024, radius=0.1, nsample=32, mlp=[input_channels, 32, 32, 64])) self.SA_modules.append( PointnetSAModule(npoint=256, radius=0.2, nsample=32, mlp=[64, 64, 64, 128])) self.SA_modules.append( PointnetSAModule(npoint=64, radius=0.4, nsample=32, mlp=[128, 128, 128, 256])) self.SA_modules.append( PointnetSAModule(npoint=16, radius=0.8, nsample=32, mlp=[256, 256, 256, 512])) self.FP_modules = nn.ModuleList() self.FP_modules.append( PointnetFPModule(mlp=[128 + input_channels, 128, 128, 128])) self.FP_modules.append(PointnetFPModule(mlp=[256 + 64, 256, 128])) self.FP_modules.append(PointnetFPModule(mlp=[256 + 128, 256, 256])) self.FP_modules.append(PointnetFPModule(mlp=[512 + 256, 256, 256])) self.FC_layer = nn.Sequential( pt_utils.Conv1d(128, 128, bn=True), nn.Dropout(), pt_utils.Conv1d(128, num_classes, activation=None))
def __init__(self, num_classes, input_channels=9, use_xyz=True): super().__init__() self.SA_modules = nn.ModuleList() c_in = input_channels self.SA_modules.append( PointnetSAModuleMSG(npoint=1024, radii=[0.05, 0.1], nsamples=[16, 32], mlps=[[c_in, 16, 16, 32], [c_in, 32, 32, 64]], use_xyz=use_xyz)) c_out_0 = 32 + 64 c_in = c_out_0 self.SA_modules.append( PointnetSAModuleMSG( npoint=256, radii=[0.1, 0.2], nsamples=[16, 32], mlps=[[c_in, 64, 64, 128], [c_in, 64, 96, 128]], )) c_out_1 = 128 + 128 c_in = c_out_1 self.SA_modules.append( PointnetSAModuleMSG( npoint=64, radii=[0.2, 0.4], nsamples=[16, 32], mlps=[[c_in, 128, 196, 256], [c_in, 128, 196, 256]], )) c_out_2 = 256 + 256 c_in = c_out_2 self.SA_modules.append( PointnetSAModuleMSG( npoint=16, radii=[0.4, 0.8], nsamples=[16, 32], mlps=[[c_in, 256, 256, 512], [c_in, 256, 384, 512]], )) c_out_3 = 512 + 512 self.FP_modules = nn.ModuleList() self.FP_modules.append( PointnetFPModule( mlp=[256 + (input_channels if use_xyz else 0), 128, 128])) self.FP_modules.append(PointnetFPModule(mlp=[512 + c_out_0, 256, 256])) self.FP_modules.append(PointnetFPModule(mlp=[512 + c_out_1, 512, 512])) self.FP_modules.append( PointnetFPModule(mlp=[c_out_3 + c_out_2, 512, 512])) self.FC_layer = nn.Sequential( pt_utils.Conv1d(128, 128, bn=True), nn.Dropout(), pt_utils.Conv1d(128, num_classes, activation=None))
def __init__(self, input_feature_dim=0, SCALE=1): super().__init__() self.sa1 = PointnetSAModuleVotes( npoint=2048, radius=0.2, nsample=64, mlp=[0, 64*SCALE, 64*SCALE, 128*SCALE], use_xyz=True, normalize_xyz=True ) self.sa2 = PointnetSAModuleVotes( npoint=1024, radius=0.4, nsample=32, mlp=[128*SCALE, 128*SCALE, 128*SCALE, 256*SCALE], use_xyz=True, normalize_xyz=True ) self.sa3 = PointnetSAModuleVotes( npoint=512, radius=0.8, nsample=16, mlp=[256*SCALE, 128*SCALE, 128*SCALE, 256*SCALE], use_xyz=True, normalize_xyz=True ) self.sa4 = PointnetSAModuleVotes( npoint=256, radius=1.2, nsample=16, mlp=[256*SCALE, 128*SCALE, 128*SCALE, 256*SCALE], use_xyz=True, normalize_xyz=True ) if SCALE == 1: self.fp1 = PointnetFPModule(mlp=[256+256,512,512]) self.fp2 = PointnetFPModule(mlp=[512+256,512,512]) else: self.fp1 = PointnetFPModule(mlp=[256*SCALE+256*SCALE,256*SCALE,256*SCALE]) self.fp2 = PointnetFPModule(mlp=[256*SCALE+256*SCALE,256*SCALE,256*SCALE])
def __init__(self, input_feature_dim=0, width=1, depth=2): super().__init__() self.depth = depth self.width = width self.sa1 = PointnetSAModuleVotes( npoint=2048, radius=0.2, nsample=64, mlp=[input_feature_dim] + [64 * width for i in range(depth)] + [128 * width], use_xyz=True, normalize_xyz=True ) self.sa2 = PointnetSAModuleVotes( npoint=1024, radius=0.4, nsample=32, mlp=[128 * width] + [128 * width for i in range(depth)] + [256 * width], use_xyz=True, normalize_xyz=True ) self.sa3 = PointnetSAModuleVotes( npoint=512, radius=0.8, nsample=16, mlp=[256 * width] + [128 * width for i in range(depth)] + [256 * width], use_xyz=True, normalize_xyz=True ) self.sa4 = PointnetSAModuleVotes( npoint=256, radius=1.2, nsample=16, mlp=[256 * width] + [128 * width for i in range(depth)] + [256 * width], use_xyz=True, normalize_xyz=True ) self.fp1 = PointnetFPModule(mlp=[256 * width + 256 * width, 256 * width, 256 * width]) self.fp2 = PointnetFPModule(mlp=[256 * width + 256 * width, 256 * width, 288])
def __init__(self, num_classes): super().__init__() self.SA_modules = nn.ModuleList() self.SA_modules.append( PointnetSAModuleMSG( npoint=512, radii=[0.2], nsamples=[64], mlps=[[6, 64, 64, 128]], first_layer=True, use_xyz=True, ) ) self.SA_modules.append( PointnetSAModuleMSG( npoint=128, radii=[0.4], nsamples=[64], mlps=[[128+9, 128, 128, 256]], use_xyz=False, last_layer=True, ) ) # global pooling self.SA_modules.append( PointnetSAModule( nsample=128, mlp=[256, 256, 512, 1024], use_xyz=False ) ) self.FP_modules = nn.ModuleList() self.FP_modules.append(PointnetFPModule(mlp=[128, 128, 128, 128])) self.FP_modules.append(PointnetFPModule(mlp=[384, 256, 128])) self.FP_modules.append(PointnetFPModule(mlp=[1280, 256, 256])) self.FC_layer = nn.Sequential( pt_utils.Conv1d(128, 128, bn=True), nn.Dropout(), pt_utils.Conv1d(128, num_classes, activation=None) )
def __init__(self, num_classes, input_channels=3, use_xyz=True, bn=True): super().__init__() NPOINTS = [1024, 256, 64, 16] RADIUS = [[0.05, 0.1], [0.1, 0.2], [0.2, 0.4], [0.4, 0.8]] NSAMPLE = [[16, 32], [16, 32], [16, 32], [16, 32]] MLPS = [[[16, 16, 32], [32, 32, 64]], [[64, 64, 128], [64, 96, 128]], [[128, 196, 256], [128, 196, 256]], [[256, 256, 512], [256, 384, 512]]] FP_MLPS = [[128, 128], [256, 256], [512, 512], [512, 512]] CLS_FC = [128] DP_RATIO = 0.5 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=use_xyz, bn=bn)) 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], bn=bn)) 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=bn)) pre_channel = CLS_FC[k] cls_layers.append( pt_utils.Conv1d(pre_channel, num_classes, activation=None, bn=bn)) cls_layers.insert(1, nn.Dropout(DP_RATIO)) self.cls_layer = nn.Sequential(*cls_layers)
def __init__(self, num_classes, input_channels=3, use_xyz=True, bn=True): super().__init__() 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=use_xyz, bn=bn)) 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], bn=bn)) 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=bn)) pre_channel = CLS_FC[k] cls_layers.append( pt_utils.Conv1d(pre_channel, num_classes, activation=None, bn=bn)) cls_layers.insert(1, nn.Dropout(0.5)) self.cls_layer = nn.Sequential(*cls_layers)
def _build_model(self): self.SA_modules = nn.ModuleList() for i in range(len(self.npoints)): self.SA_modules.append( PointnetSAModule( npoint=self.npoints[i], radius=self.radii[i], # note: radius-radii nsample=self.nsamples[i], mlp=self.mlps[i], use_xyz=self.use_xyz)) self.FP_modules = nn.ModuleList() for i in range(len(self.mlps_fp)): self.FP_modules.append(PointnetFPModule(mlp=self.mlps_fp[i])) self.fc_layer = nn.Sequential( nn.Conv1d(128, 128, kernel_size=1, bias=False), nn.BatchNorm1d(128), nn.ReLU(True), nn.Dropout(0.5), nn.Conv1d(128, self.num_classes, kernel_size=1), )
def __init__(self, num_classes, input_channels=0, relation_prior=1, use_xyz=True): super().__init__() self.SA_modules = nn.ModuleList() c_in = input_channels self.SA_modules.append( # 0 PointnetSAModuleMSG( npoint=1024, radii=[0.075, 0.1, 0.125], nsamples=[16, 32, 48], mlps=[[c_in, 64], [c_in, 64], [c_in, 64]], first_layer=True, use_xyz=use_xyz, relation_prior=relation_prior ) ) c_out_0 = 64*3 c_in = c_out_0 self.SA_modules.append( # 1 PointnetSAModuleMSG( npoint=256, radii=[0.1, 0.15, 0.2], nsamples=[16, 48, 64], mlps=[[c_in, 128], [c_in, 128], [c_in, 128]], use_xyz=use_xyz, relation_prior=relation_prior ) ) c_out_1 = 128*3 c_in = c_out_1 self.SA_modules.append( # 2 PointnetSAModuleMSG( npoint=64, radii=[0.2, 0.3, 0.4], nsamples=[16, 32, 48], mlps=[[c_in, 256], [c_in, 256], [c_in, 256]], use_xyz=use_xyz, relation_prior=relation_prior ) ) c_out_2 = 256*3 c_in = c_out_2 self.SA_modules.append( # 3 PointnetSAModuleMSG( npoint=16, radii=[0.4, 0.6, 0.8], nsamples=[16, 24, 32], mlps=[[c_in, 512], [c_in, 512], [c_in, 512]], use_xyz=use_xyz, relation_prior=relation_prior ) ) c_out_3 = 512*3 self.SA_modules.append( # 4 global pooling PointnetSAModule( nsample = 16, mlp=[c_out_3, 128], use_xyz=use_xyz ) ) global_out = 128 self.SA_modules.append( # 5 global pooling PointnetSAModule( nsample = 64, mlp=[c_out_2, 128], use_xyz=use_xyz ) ) global_out2 = 128 self.FP_modules = nn.ModuleList() self.FP_modules.append( PointnetFPModule(mlp=[256 + input_channels, 128, 128]) ) self.FP_modules.append(PointnetFPModule(mlp=[512 + c_out_0, 256, 256])) self.FP_modules.append(PointnetFPModule(mlp=[512 + c_out_1, 512, 512])) self.FP_modules.append( PointnetFPModule(mlp=[c_out_3 + c_out_2, 512, 512]) ) self.context_prior=cp.Context(128+global_out+global_out2+16,128+global_out+global_out2+16) self.FC_layer = nn.Sequential( pt_utils.Conv1d((128+global_out+global_out2+16)*3, 128, bn=True), nn.Dropout(), pt_utils.Conv1d(128, num_classes, activation=None) )