def __init__(self, num_classes, input_channels=3, use_xyz=True, type_r=None): super(Pointnet2SSG, self).__init__() self.SA_modules = nn.ModuleList() self.SA_modules.append( PointnetSAModule( npoint=512, radius=0.2, nsample=32, mlp=[input_channels, 64, 64, 128], use_xyz=True, )) self.SA_modules.append( PointnetSAModule( npoint=128, radius=0.4, nsample=64, mlp=[128, 128, 128, 256], use_xyz=use_xyz, )) self.SA_modules.append( PointnetSAModule(mlp=[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, input_channels=3, use_xyz=True): super(Pointnet_Backbone, self).__init__() self.SA_modules = nn.ModuleList() self.SA_modules.append( PointnetSAModule( radius=0.3, nsample=32, mlp=[input_channels, 64, 64, 128], use_xyz=use_xyz, )) self.SA_modules.append( PointnetSAModule( radius=0.5, nsample=32, mlp=[128, 128, 128, 256], use_xyz=use_xyz, )) self.SA_modules.append( PointnetSAModule( radius=0.7, nsample=32, mlp=[256, 256, 256, 256], use_xyz=use_xyz, )) self.cov_final = nn.Conv1d(256, 256, kernel_size=1)
def __init__(self, num_classes, input_channels=3, use_xyz=True, type_r='qpu', loss='ce'): super(PointNetPoseEstimate, self).__init__() self.PN = nn.ModuleList() if type_r == 'qpu': self.PN.append( PointnetSAModuleQPU(npoint=256, radius=0.4, nsample=32, mlp=nn.Sequential( qpu_layers.QPU(4 * 8, 64 * 4), qpu_layers.KeepImPart(dim=-1, type_r='angle'), ), use_xyz=use_xyz)) else: self.PN.append( PointnetSAModule( npoint=256, radius=0.4, nsample=32, mlp=[input_channels, 64, 64, 64 * 3], use_xyz=True, )) self.PN.append( PointnetSAModule( npoint=128, radius=0.4, nsample=16, # 64 # mlp=[32, 128], mlp=[64 * 3, 192, 192, 256], use_xyz=use_xyz)) self.PN.append( PointnetSAModule(mlp=[256, 256, 512, 1024], use_xyz=use_xyz)) # self.PN.append(PointnetSAModule(mlp=[256, 384, 384, 512], use_xyz=use_xyz)) self.loss = loss self.step = 5 self.mix = lambda x, y: torch.cat([x.squeeze(-1), y.squeeze(-1)], -1) featShape = (512 * 2, 384) # featShape = (512,128) if loss == 'ce': # include ['ce'] self.pred_theta = self.multi_cls_head(*featShape, 360 // self.step) self.pred_alpha = self.multi_cls_head(*featShape, 180 // self.step) self.pred_beta = self.multi_cls_head(*featShape, 180 // self.step) elif loss == 'weighted_ce': self.pred_theta = self.multi_cls_head(*featShape, 360 // self.step, -1) self.pred_alpha = self.multi_cls_head(*featShape, 180 // self.step, -1) self.pred_beta = self.multi_cls_head(*featShape, 180 // self.step, -1) else: # include ['mse'] self.pred_theta = self.regression_head(*featShape, 1) self.pred_alpha = self.regression_head(*featShape, 1) self.pred_beta = self.regression_head(*featShape, 1)
def __init__(self, num_classes, input_channels=3, use_xyz=True): super().__init__() self.SA_modules = nn.ModuleList() self.SA_modules.append( PointnetSAModuleMSG(npoint=512, radii=[0.1, 0.2, 0.4], nsamples=[15, 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 = nn.Sequential( pt_utils.FC(1024, 512, bn=True), nn.Dropout(p=0.5), pt_utils.FC(512, 256, bn=True), nn.Dropout(p=0.5), pt_utils.FC(256, num_classes, activation=None))
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, num_classes, input_channels=3, use_xyz=True): super(Pointnet2SSG, self).__init__() self.SA_modules = nn.ModuleList() self.SA_modules.append( PointnetSAModule( npoint=1024, radius=0.1, nsample=32, mlp=[input_channels, 32, 32, 64], use_xyz=use_xyz, )) self.SA_modules.append( PointnetSAModule( npoint=256, radius=0.2, nsample=32, mlp=[64, 64, 64, 128], use_xyz=use_xyz, )) self.SA_modules.append( PointnetSAModule( npoint=64, radius=0.4, nsample=32, mlp=[128, 128, 128, 256], use_xyz=use_xyz, )) self.SA_modules.append( PointnetSAModule( npoint=16, radius=0.8, nsample=32, mlp=[256, 256, 256, 512], use_xyz=use_xyz, )) 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 = (pt_utils.Seq(128).conv1d( 128, bn=True).dropout().conv1d(num_classes, activation=None))
def __init__(self, num_classes, input_channels=3, use_xyz=True): super(Pointnet2SSGQPU, self).__init__() self.SA_modules = nn.ModuleList() self.SA_modules.append( PointnetSAModuleQPU( npoint=256, radius=0.4, nsample=32, mlp=nn.Sequential( qpu_layers.QPU(4*8, 64*4), qpu_layers.KeepRealPart(dim=-1), nn.Linear(64, 128) ), use_xyz=use_xyz ) ) self.SA_modules.append( PointnetSAModule( npoint=128, radius=0.4, nsample=16, # 64 # mlp=[32, 128], mlp=[128, 128, 128, 256], use_xyz=use_xyz ) ) self.SA_modules.append( PointnetSAModule(mlp=[256, 256, 512, 1024], use_xyz=use_xyz) ) self.FC_layer = ( pt_utils.Seq(1024) .fc(256, bn=True) .dropout(0.5) .fc(128, bn=True) .dropout(0.5) .fc(num_classes, activation=None) )
def __init__(self, num_classes, input_channels=3, use_xyz=True, type_r='r'): super(Pointnet2SSGQPU, self).__init__() if type_r == 'no_r': kp = qpu_layers.KeepImPart temp_size = 64 * 3 else: kp = qpu_layers.KeepRealPart temp_size = 64 + 63 * ('inner' in type_r) self.SA_modules = nn.ModuleList() self.SA_modules.append( PointnetSAModuleQPU(npoint=256, radius=0.4, nsample=32, mlp=nn.Sequential( qpu_layers.QPU(4 * 8, 64 * 4), kp(dim=-1, type_r=type_r), nn.Linear(temp_size, 128)), use_xyz=use_xyz)) self.SA_modules.append( PointnetSAModule( npoint=128, radius=0.4, nsample=16, # 64 # mlp=[32, 128], mlp=[128, 128, 128, 256], use_xyz=use_xyz)) self.SA_modules.append( PointnetSAModule(mlp=[256, 256, 512, 1024], use_xyz=use_xyz)) self.FC_layer = (pt_utils.Seq(1024).fc(256, bn=True).dropout(0.5).fc( 128, bn=True).dropout(0.5).fc(num_classes, activation=None))
def __init__(self, num_classes, input_channels=3, use_xyz=True): super().__init__() self.SA_modules = nn.ModuleList() self.SA_modules.append( PointnetSAModule(npoint=512, radius=0.2, nsample=64, mlp=[input_channels, 64, 64, 128], use_xyz=use_xyz)) self.SA_modules.append( PointnetSAModule(npoint=128, radius=0.4, nsample=64, mlp=[128, 128, 128, 256], use_xyz=use_xyz)) self.SA_modules.append( PointnetSAModule(mlp=[256, 256, 512, 1024], use_xyz=use_xyz)) self.FC_layer = nn.Sequential( pt_utils.FC(1024, 512, bn=True), nn.Dropout(p=0.5), pt_utils.FC(512, 256, bn=True), nn.Dropout(p=0.5), pt_utils.FC(256, num_classes, activation=None))
def __init__(self, input_channels=3, use_xyz=True): super(PCEncoder, self).__init__() self.SA_modules = nn.ModuleList() self.SA_modules.append( PointnetSAModule( npoint=512, radius=0.2, nsample=64, mlp=[input_channels, 64, 64, 128], use_xyz=use_xyz, )) self.SA_modules.append( PointnetSAModule( npoint=128, radius=0.4, nsample=64, mlp=[128, 128, 128, 256], use_xyz=use_xyz, )) self.SA_modules.append( PointnetSAModule(mlp=[256, 256, 512, 1024], use_xyz=use_xyz)) self.FC_layer = (pt_utils.Seq(1024).fc(256, bn=False, activation=None))
def __init__(self, num_classes, input_channels=3, use_xyz=True, n_strxmani=None, align=False): super(Pointnet2MSG_manimix, 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)) if n_strxmani is not None: self.mixupbias_layer = (pt_utils.Seq(n_strxmani).fc( 64, bn=True).fc(num_classes, activation=None)) self.EMD = emd_module.emdModule() self.cd = CD() self.align = align
def __init__(self, input_channels=3, use_xyz=True, objective=False): super(Pointnet_Tracking, self).__init__() self.backbone_net = Pointnet_Backbone(input_channels, use_xyz) self.cosine = nn.CosineSimilarity(dim=1) self.mlp = pt_utils.SharedMLP([4 + 256, 256, 256, 256], bn=True) self.FC_layer_cla = (pt_utils.Seq(256).conv1d(256, bn=True).conv1d( 256, bn=True).conv1d(1, activation=None)) self.fea_layer = (pt_utils.Seq(256).conv1d(256, bn=True).conv1d( 256, activation=None)) self.vote_layer = (pt_utils.Seq(3 + 256).conv1d(256, bn=True).conv1d( 256, bn=True).conv1d(3 + 256, activation=None)) self.vote_aggregation = PointnetSAModule(radius=0.3, nsample=16, mlp=[1 + 256, 256, 256, 256], use_xyz=use_xyz) self.num_proposal = 64 self.FC_proposal = (pt_utils.Seq(256).conv1d(256, bn=True).conv1d( 256, bn=True).conv1d(3 + 1 + 1, activation=None))
def __init__(self, input_channels=3, use_xyz=True, objective=False): super(Pointnet_Tracking, self).__init__() self.backbone_net = Pointnet_Backbone(input_channels, use_xyz) self.cosine = nn.CosineSimilarity(dim=1) self.mlp = pt_utils.SharedMLP([4 + 256, 256, 256, 256], bn=True) # SharedMLP( # (layer0): Conv2d( # (conv): Conv2d(260, 256, kernel_size=(1, 1), stride=(1, 1), bias=False) # (normlayer): BatchNorm2d( # (bn): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True) # ) # (activation): ReLU(inplace=True) # ) # (layer1): Conv2d( # (conv): Conv2d(256, 256, kernel_size=(1, 1), stride=(1, 1), bias=False) # (normlayer): BatchNorm2d( # (bn): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True) # ) # (activation): ReLU(inplace=True) # ) # (layer2): Conv2d( # (conv): Conv2d(256, 256, kernel_size=(1, 1), stride=(1, 1), bias=False) # (normlayer): BatchNorm2d( # (bn): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True) # ) # (activation): ReLU(inplace=True) # ) # ) self.FC_layer_cla = (pt_utils.Seq(256).conv1d(256, bn=True).conv1d( 256, bn=True).conv1d(1, activation=None)) # Seq( # (0): Conv1d( # (conv): Conv1d(256, 256, kernel_size=(1,), stride=(1,), bias=False) # (normlayer): BatchNorm1d( # (bn): BatchNorm1d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True) # ) # (activation): ReLU(inplace=True) # ) # (1): Conv1d( # (conv): Conv1d(256, 256, kernel_size=(1,), stride=(1,), bias=False) # (normlayer): BatchNorm1d( # (bn): BatchNorm1d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True) # ) # (activation): ReLU(inplace=True) # ) # (2): Conv1d( # (conv): Conv1d(256, 1, kernel_size=(1,), stride=(1,)) # ) # ) self.fea_layer = (pt_utils.Seq(256).conv1d(256, bn=True).conv1d( 256, activation=None)) # Seq( # (0): Conv1d( # (conv): Conv1d(256, 256, kernel_size=(1,), stride=(1,), bias=False) # (normlayer): BatchNorm1d( # (bn): BatchNorm1d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True) # ) # (activation): ReLU(inplace=True) # ) # (1): Conv1d( # (conv): Conv1d(256, 256, kernel_size=(1,), stride=(1,)) # ) # ) self.vote_layer = (pt_utils.Seq(3 + 256).conv1d(256, bn=True).conv1d( 256, bn=True).conv1d(3 + 256, activation=None)) # Seq( # (0): Conv1d( # (conv): Conv1d(259, 256, kernel_size=(1,), stride=(1,), bias=False) # (normlayer): BatchNorm1d( # (bn): BatchNorm1d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True) # ) # (activation): ReLU(inplace=True) # ) # (1): Conv1d( # (conv): Conv1d(256, 256, kernel_size=(1,), stride=(1,), bias=False) # (normlayer): BatchNorm1d( # (bn): BatchNorm1d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True) # ) # (activation): ReLU(inplace=True) # ) # (2): Conv1d( # (conv): Conv1d(256, 259, kernel_size=(1,), stride=(1,)) # ) # ) self.vote_aggregation = PointnetSAModule( radius=0.3, nsample=16, mlp=[1 + 256, 256, 256, 256], use_xyz=use_xyz) # 根据投票聚合投影候选中心点 # PointnetSAModule( # (groupers): ModuleList( # (0): QueryAndGroup() # ) # (mlps): ModuleList( # (0): SharedMLP( # (layer0): Conv2d( # (conv): Conv2d(260, 256, kernel_size=(1, 1), stride=(1, 1), bias=False) # (normlayer): BatchNorm2d( # (bn): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True) # ) # (activation): ReLU(inplace=True) # ) # (layer1): Conv2d( # (conv): Conv2d(256, 256, kernel_size=(1, 1), stride=(1, 1), bias=False) # (normlayer): BatchNorm2d( # (bn): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True) # ) # (activation): ReLU(inplace=True) # ) # (layer2): Conv2d( # (conv): Conv2d(256, 256, kernel_size=(1, 1), stride=(1, 1), bias=False) # (normlayer): BatchNorm2d( # (bn): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True) # ) # (activation): ReLU(inplace=True) # ) # ) # ) # ) self.num_proposal = 64 # 实际上是_PointnetSAModuleBase(nn.Module)的forward中的npoint输入参数 self.FC_proposal = (pt_utils.Seq(256).conv1d(256, bn=True).conv1d( 256, bn=True).conv1d(3 + 1 + 1, activation=None))
def __init__(self, input_channels=3, use_xyz=True): super(Pointnet_Backbone, self).__init__() self.SA_modules = nn.ModuleList() self.SA_modules.append( PointnetSAModule( radius=0.3, nsample=32, mlp=[input_channels, 64, 64, 128], use_xyz=use_xyz, )) self.SA_modules.append( PointnetSAModule( radius=0.5, nsample=32, mlp=[128, 128, 128, 256], use_xyz=use_xyz, )) self.SA_modules.append( PointnetSAModule( radius=0.7, nsample=32, mlp=[256, 256, 256, 256], use_xyz=use_xyz, )) # ModuleList( # (0): PointnetSAModule( # (groupers): ModuleList( # (0): QueryAndGroup(radius=0.3, nsample=32) # ) # (mlps): ModuleList( # (0): SharedMLP( # (layer0): Conv2d( # (conv): Conv2d(3, 64, kernel_size=(1, 1), stride=(1, 1), bias=False) # (normlayer): BatchNorm2d( # (bn): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True) # ) # (activation): ReLU(inplace=True) # ) # (layer1): Conv2d( # (conv): Conv2d(64, 64, kernel_size=(1, 1), stride=(1, 1), bias=False) # (normlayer): BatchNorm2d( # (bn): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True) # ) # (activation): ReLU(inplace=True) # ) # (layer2): Conv2d( # (conv): Conv2d(64, 128, kernel_size=(1, 1), stride=(1, 1), bias=False) # (normlayer): BatchNorm2d( # (bn): BatchNorm2d(128, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True) # ) # (activation): ReLU(inplace=True) # ) # ) # ) # ) # (1): PointnetSAModule( # (groupers): ModuleList( # (0): QueryAndGroup(radius=0.5, nsample=32) # ) # (mlps): ModuleList( # (0): SharedMLP( # (layer0): Conv2d( # (conv): Conv2d(131, 128, kernel_size=(1, 1), stride=(1, 1), bias=False) # (normlayer): BatchNorm2d( # (bn): BatchNorm2d(128, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True) # ) # (activation): ReLU(inplace=True) # ) # (layer1): Conv2d( # (conv): Conv2d(128, 128, kernel_size=(1, 1), stride=(1, 1), bias=False) # (normlayer): BatchNorm2d( # (bn): BatchNorm2d(128, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True) # ) # (activation): ReLU(inplace=True) # ) # (layer2): Conv2d( # (conv): Conv2d(128, 256, kernel_size=(1, 1), stride=(1, 1), bias=False) # (normlayer): BatchNorm2d( # (bn): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True) # ) # (activation): ReLU(inplace=True) # ) # ) # ) # ) # (2): PointnetSAModule( # (groupers): ModuleList( # (0): QueryAndGroup(radius=0.7, nsample=32) # ) # (mlps): ModuleList( # (0): SharedMLP( # (layer0): Conv2d( # (conv): Conv2d(259, 256, kernel_size=(1, 1), stride=(1, 1), bias=False) # (normlayer): BatchNorm2d( # (bn): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True) # ) # (activation): ReLU(inplace=True) # ) # (layer1): Conv2d( # (conv): Conv2d(256, 256, kernel_size=(1, 1), stride=(1, 1), bias=False) # (normlayer): BatchNorm2d( # (bn): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True) # ) # (activation): ReLU(inplace=True) # ) # (layer2): Conv2d( # (conv): Conv2d(256, 256, kernel_size=(1, 1), stride=(1, 1), bias=False) # (normlayer): BatchNorm2d( # (bn): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True) # ) # (activation): ReLU(inplace=True) # ) # ) # ) # ) # ) self.cov_final = nn.Conv1d(256, 256, kernel_size=1)