def __init__(self, num_classes, ins_channel): super(PointNet2ASIS, self).__init__() self.sa1 = PointNetSetAbstraction(1024, 0.1, 32, 6 + 3, [32, 32, 64], None) self.sa2 = PointNetSetAbstraction(256, 0.2, 32, 64 + 3, [64, 64, 128], None) self.sa3 = PointNetSetAbstraction(64, 0.4, 32, 128 + 3, [128, 128, 256], None) self.sa4 = PointNetSetAbstraction(16, 0.8, 32, 256 + 3, [256, 256, 512], None) self.fp_sem4 = PointNetFeaturePropagation(768, [256, 256]) self.fp_sem3 = PointNetFeaturePropagation(384, [256, 256]) self.fp_sem2 = PointNetFeaturePropagation(320, [256, 128]) self.fp_sem1 = PointNetFeaturePropagation(128 + 6, [128, 128, 128]) self.fp_ins4 = PointNetFeaturePropagation(768, [256, 256]) self.fp_ins3 = PointNetFeaturePropagation(384, [256, 256]) self.fp_ins2 = PointNetFeaturePropagation(320, [256, 128]) self.fp_ins1 = PointNetFeaturePropagation(128 + 6, [128, 128, 128]) self.sem_fc = PointwiseConv1D(128, 128) # for F_SEM self.ins_fc = PointwiseConv1D(128, 128) # for F_INS self.asis = ASIS(128, num_classes, 128, ins_channel, 30)
def __init__(self, point_feature_size, out_channel, use_x_transform=True): super().__init__() self.xconv1 = XConv( coord2feature_channel=48 // 2, # C//2 point_feature_size=point_feature_size, # fts channels out_channel=48, # C k=8, dilation=1, depth_multiplier=4, use_x_transformation=use_x_transform) self.xconv2 = XConv( coord2feature_channel=48 // 4, # previous_C//4 point_feature_size=48, # fts channels (previous_C) out_channel=96, # C k=12, dilation=2, depth_multiplier=2, use_x_transformation=use_x_transform) self.xconv3 = XConv( coord2feature_channel=96 // 4, # previous_C//4 point_feature_size=96, # fts channels (previous_C) out_channel=192, # C k=16, dilation=2, depth_multiplier=2, use_x_transformation=use_x_transform) self.xconv4 = XConv( coord2feature_channel=192 // 4, # previous_C//4 point_feature_size=192, # fts channels (previous_C) out_channel=384, # C k=16, dilation=3, depth_multiplier=2, use_x_transformation=use_x_transform) # self.fc = nn.Sequential( # Linear(384, 384), # Linear(384, 192), # nn.Dropout(0.2), # nn.Linear(192, out_channel) # ) # output warning (last channel warning) # self.fc1 = Linear(384, 384) # self.fc2 = Linear(384, 192) # self.dropout = nn.Dropout(0.2) # self.fc3 = Linear(192, out_channel, act=None, with_bn=False) self.convs = nn.Sequential(PointwiseConv1D(384, 384), PointwiseConv1D(384, 192), nn.Dropout(p=0.2), nn.Conv1d(192, out_channel, 1)) self.point_feature_size = point_feature_size
def __init__(self, in_channel_size, out_channel_size, coords_channel_size, k): super().__init__() # self.input_linear = nn.Conv1d(in_channel_size, out_channel_size*3, 1, bias=False) self.phi = PointwiseConv1D(in_channel_size, out_channel_size, conv_args={"bias": False}) self.psi = PointwiseConv2D(in_channel_size, out_channel_size, conv_args={"bias": False}) self.alpha = PointwiseConv2D(in_channel_size, out_channel_size, conv_args={"bias": False}) # gamma (mapping function) self.mlp_gamma = nn.Sequential( nn.Conv2d(out_channel_size, out_channel_size, (1, 1), bias=False), nn.ReLU(inplace=True), nn.Conv2d(out_channel_size, out_channel_size, (1, 1), bias=False)) # rho (normalization function) self.normalization_rho = nn.Softmax(dim=-1) # delta (potition encoding) self.pe_delta = PositionEncoding(coords_channel_size, out_channel_size) self.k = k
def __init__(self, num_classes, point_feature_size=0): super().__init__() in_channel = 3+point_feature_size self.sa1 = PointNetSetAbstraction(num_fps_points=1024, radius=0.1, num_bq_points=32, init_in_channel=in_channel, mlp=[32, 32, 64], group_all=False) self.sa2 = PointNetSetAbstraction(num_fps_points=256, radius=0.2, num_bq_points=32, init_in_channel=64 + 3, mlp=[64, 64, 128], group_all=False) self.sa3 = PointNetSetAbstraction(num_fps_points=64, radius=0.4, num_bq_points=32, init_in_channel=128+3, mlp=[128, 128, 256], group_all=False) self.sa4 = PointNetSetAbstraction(num_fps_points=16, radius=0.8, num_bq_points=32, init_in_channel=256 + 3, mlp=[256, 256, 512], group_all=False) self.fp4 = PointNetFeaturePropagation(768, [256, 256]) self.fp3 = PointNetFeaturePropagation(384, [256, 256]) self.fp2 = PointNetFeaturePropagation(320, [256, 128]) self.fp1 = PointNetFeaturePropagation(128+in_channel, [128, 128, 128]) self.output_layers = nn.Sequential( PointwiseConv1D(128, 128), nn.Dropout(0.5), nn.Conv1d(128, num_classes, 1) ) self.point_feature_size = point_feature_size
def __init__(self, sem_in_channels, sem_out_channels, ins_in_channels, ins_out_channels, k, memory_saving=True): super(ASIS, self).__init__() # sem branch self.sem_pred_fc = nn.Sequential( nn.Dropout(inplace=True), nn.Conv1d(sem_in_channels, sem_out_channels, 1)) # input: F_ISEM, output: P_SEM # interactive module: sem to ins self.adaptation = PointwiseConv1D(sem_in_channels, ins_in_channels) # ins branch self.ins_emb_fc = nn.Sequential( nn.Dropout(inplace=True), nn.Conv1d(ins_in_channels, ins_out_channels, 1)) # input: F_SINS, output: E_INS # interactive module: ins to sem # using knn_index and index2points self.k = k self.memory_saving = memory_saving
def __init__(self, in_channel_size, out_channel_size, pt_mid_channel_size, coord_channel_size, pt_k): super().__init__() self.pwc = PointwiseConv1D(in_channel_size, out_channel_size, conv_args={"bias": False}) self.pt = PointTransformerBlock(out_channel_size, pt_mid_channel_size, coord_channel_size, pt_k)
def __init__(self, init_in_channel, mlp): super().__init__() layers = [] in_channel = init_in_channel for out_channel in mlp: layers.append(PointwiseConv1D(in_channel, out_channel)) in_channel = out_channel self.mlp = nn.Sequential(*layers)
def __init__(self, point_feature_size, out_channel, use_x_transform=True): super().__init__() self.xconv1 = XConv( coord2feature_channel=48 // 2, # C//2 point_feature_size=point_feature_size, # fts channels out_channel=48, # C k=8, dilation=1, depth_multiplier=4, use_x_transformation=use_x_transform) self.xconv2 = XConv( coord2feature_channel=48 // 4, # previous_C//4 point_feature_size=48, # fts channels (previous_C) out_channel=96, # C k=12, dilation=2, depth_multiplier=2, use_x_transformation=use_x_transform) self.xconv3 = XConv( coord2feature_channel=96 // 4, # previous_C//4 point_feature_size=96, # fts channels (previous_C) out_channel=192, # C k=16, dilation=2, depth_multiplier=2, use_x_transformation=use_x_transform) self.xconv4 = XConv( coord2feature_channel=192 // 4, # previous_C//4 point_feature_size=192, # fts channels (previous_C) out_channel=384, # C k=16, dilation=3, depth_multiplier=2, use_x_transformation=use_x_transform) self.convs = nn.Sequential(PointwiseConv1D(384, 384), PointwiseConv1D(384, 192), nn.Dropout(p=0.2), nn.Conv1d(192, out_channel, 1)) self.point_feature_size = point_feature_size
def __init__(self, point_feature_size, num_points=NPOINTS, radius=RADIUS, num_sample=NSAMPLE, mlps=MLPS, fp_mls=FP_MLPS, cls_fc=CLS_FC, dp_ratio=DP_RATIO): super().__init__() # create sa modules self.sa_msg_modules = nn.ModuleList() prev_feature_size = point_feature_size sa_output_feature_size = [] for i in range(len(num_points)): self.sa_msg_modules.append( PointNetSetAbstractionMSG( num_points[i], radius[i], num_sample[i], prev_feature_size, mlps[i] ) ) prev_feature_size = 0 for feature_size in mlps[i]: prev_feature_size += feature_size[-1] sa_output_feature_size.append(prev_feature_size) # create fp module self.fp_modules = nn.ModuleList() sa_output_feature_size = list(reversed(sa_output_feature_size)) prev_feature_size = sa_output_feature_size[0] for i in range(len(fp_mls)): input_feature_size = prev_feature_size if len(sa_output_feature_size) > i+1: input_feature_size += sa_output_feature_size[i+1] self.fp_modules.append( PointNetFeaturePropagation( input_feature_size, fp_mls[i] ) ) prev_feature_size = fp_mls[i][-1] # create branch self.cls_fc = nn.ModuleList() prev_feature_size = fp_mls[-1][-1] for i in range(len(cls_fc)): self.cls_fc.append(PointwiseConv1D(prev_feature_size, cls_fc[i])) prev_feature_size = cls_fc[i]
def __init__(self, use_xyz=True, mode='TRAIN'): super().__init__() self.training_mode = (mode == 'TRAIN') # MODEL = importlib.import_module(cfg.RPN.BACKBONE) # self.backbone_net = MODEL.get_model(input_channels=int(cfg.RPN.USE_INTENSITY), use_xyz=use_xyz) self.point_feature_size = int(cfg.RPN.USE_INTENSITY) self.backbone_net = PointNet2MSGSemanticSegmentation( self.point_feature_size) # classification branch # cls_layers = [] # pre_channel = cfg.RPN.FP_MLPS[0][-1] # for k in range(0, cfg.RPN.CLS_FC.__len__()): # cls_layers.append(pt_utils.Conv1d(pre_channel, cfg.RPN.CLS_FC[k], bn=cfg.RPN.USE_BN)) # pre_channel = cfg.RPN.CLS_FC[k] # cls_layers.append(pt_utils.Conv1d(pre_channel, 1, activation=None)) # if cfg.RPN.DP_RATIO >= 0: # cls_layers.insert(1, nn.Dropout(cfg.RPN.DP_RATIO)) # self.rpn_cls_layer = nn.Sequential(*cls_layers) cls_branch = [ PointwiseConv1D(128, 128), nn.Dropout(0.5), PointwiseConv1D(128, 1, act=None), ] self.cls_branch = nn.Sequential(*cls_branch) # regression branch # per_loc_bin_num = int(cfg.RPN.LOC_SCOPE / cfg.RPN.LOC_BIN_SIZE) * 2 # if cfg.RPN.LOC_XZ_FINE: # reg_channel = per_loc_bin_num * 4 + cfg.RPN.NUM_HEAD_BIN * 2 + 3 # else: # reg_channel = per_loc_bin_num * 2 + cfg.RPN.NUM_HEAD_BIN * 2 + 3 # reg_channel += 1 # reg y # reg_layers = [] # pre_channel = cfg.RPN.FP_MLPS[0][-1] # for k in range(0, cfg.RPN.REG_FC.__len__()): # reg_layers.append(pt_utils.Conv1d(pre_channel, cfg.RPN.REG_FC[k], bn=cfg.RPN.USE_BN)) # pre_channel = cfg.RPN.REG_FC[k] # reg_layers.append(pt_utils.Conv1d(pre_channel, reg_channel, activation=None)) # if cfg.RPN.DP_RATIO >= 0: # reg_layers.insert(1, nn.Dropout(cfg.RPN.DP_RATIO)) # self.rpn_reg_layer = nn.Sequential(*reg_layers) # regression branch per_loc_bin_num = int(cfg.RPN.LOC_SCOPE / cfg.RPN.LOC_BIN_SIZE) * 2 if cfg.RPN.LOC_XZ_FINE: reg_channel = per_loc_bin_num * 4 + cfg.RPN.NUM_HEAD_BIN * 2 + 3 else: reg_channel = per_loc_bin_num * 2 + cfg.RPN.NUM_HEAD_BIN * 2 + 3 reg_channel += 1 # reg y reg_branch = [ PointwiseConv1D(128, 128), nn.Dropout(0.5), PointwiseConv1D(128, reg_channel, act=None) ] self.reg_branch = nn.Sequential(*reg_branch) # if cfg.RPN.LOSS_CLS == 'DiceLoss': # self.rpn_cls_loss_func = loss_utils.DiceLoss(ignore_target=-1) # elif cfg.RPN.LOSS_CLS == 'SigmoidFocalLoss': # self.rpn_cls_loss_func = loss_utils.SigmoidFocalClassificationLoss(alpha=cfg.RPN.FOCAL_ALPHA[0], # gamma=cfg.RPN.FOCAL_GAMMA) # elif cfg.RPN.LOSS_CLS == 'BinaryCrossEntropy': # self.rpn_cls_loss_func = F.binary_cross_entropy # else: # raise NotImplementedError # self.proposal_layer = RPNProposalLayer(mode=mode) self.init_weights()