def __init__(self, *, npoint: int, radii: List[float], nsamples: List[int], mlps: List[List[int]], bn: bool = True, use_xyz: bool = True): super().__init__() assert len(radii) == len(nsamples) == len(mlps) self.npoint = npoint self.groupers = nn.ModuleList() self.mlps = nn.ModuleList() for i in range(len(radii)): radius = radii[i] nsample = nsamples[i] self.groupers.append( pointnet2_utils.QueryAndGroup(radius, nsample, use_xyz=use_xyz) if npoint is not None else pointnet2_utils.GroupAll(use_xyz)) mlp_spec = mlps[i] if use_xyz: mlp_spec[0] += 3 self.mlps.append(pt_utils.SharedMLP(mlp_spec, bn=bn))
def __init__(self, radii, nsamples, mlps, bn=True, use_xyz=True, vote=False): # type: (PointnetSAModuleMSG, int, list[float], list[int], list[list[int]], bool, bool) -> None super(PointnetSAModuleMSG, self).__init__() # 继承了_PointnetSAModuleBase中定义的操作方法 assert len(radii) == len(nsamples) == len(mlps) self.groupers = nn.ModuleList() self.mlps = nn.ModuleList() for i in range(len(radii)): radius = radii[i] # 多尺度就在于球查询有多种半径 nsample = nsamples[i] if vote is False: self.groupers.append( pointnet2_utils.QueryAndGroup(radius, nsample, use_xyz=use_xyz)) # self.add_module(str(len(self)), module) else: # 如果要霍夫投票,就要计算得分 self.groupers.append( pointnet2_utils.QueryAndGroup_score(radius, nsample, use_xyz=use_xyz)) mlp_spec = mlps[i] if use_xyz: # 如果要使用坐标信息,则MLP的输入要加三个 mlp_spec[0] += 3 self.mlps.append(pt_utils.SharedMLP(mlp_spec, bn=bn))
def __init__(self, radii, nsamples, mlps, bn=True, use_xyz=True, vote=False): # type: (PointnetSAModuleMSG, int, List[float], List[int], List[List[int]], bool, bool) -> None super(PointnetSAModuleMSG, self).__init__() assert len(radii) == len(nsamples) == len(mlps) self.groupers = nn.ModuleList() self.mlps = nn.ModuleList() for i in range(len(radii)): radius = radii[i] nsample = nsamples[i] if vote is False: self.groupers.append( pointnet2_utils.QueryAndGroup(radius, nsample, use_xyz=use_xyz)) else: self.groupers.append( pointnet2_utils.QueryAndGroup_score(radius, nsample, use_xyz=use_xyz)) mlp_spec = mlps[i] if use_xyz: mlp_spec[0] += 3 self.mlps.append(pt_utils.SharedMLP(mlp_spec, bn=bn))
def __init__(self, npoint, radius, nsample, c_in, c_out, first_layer, mlp): super(RSSAModule2, self).__init__() self.npoint = npoint self.radius = radius self.nsample = nsample # self.group_all = group_all self.mlp_convs = nn.ModuleList() self.mlp_bns = nn.ModuleList() self.queryandgroup = pointutils.QueryAndGroup(radius, nsample) self.first_layer = first_layer # RS c_in = c_in + 3 if first_layer: self.mapping_func1 = nn.Conv2d(in_channels=10, out_channels=math.floor(c_out / 2), kernel_size=(1, 1), stride=(1, 1), bias=True) self.bn_mapping = nn.BatchNorm2d(math.floor(c_out / 2)) self.mapping_func2 = nn.Conv2d(in_channels=math.floor(c_out / 2), out_channels=16, kernel_size=(1, 1), stride=(1, 1), bias=True) self.xyz_raising = nn.Conv2d(in_channels=c_in, out_channels=16, kernel_size=(1, 1), stride=(1, 1), bias=True) self.bn_xyz_raising = nn.BatchNorm2d(16) self.bn_rsconv = nn.BatchNorm2d(16) # self.cr_mapping = nn.Conv1d(in_channels=16, out_channels=c_out, kernel_size=1, stride=1, bias=True) # self.bn_channel_raising = nn.BatchNorm1d(c_out) else: self.mapping_func1 = nn.Conv2d(in_channels=10, out_channels=math.floor(c_out / 4), kernel_size=(1, 1), stride=(1, 1), bias=True) self.bn_mapping = nn.BatchNorm2d(math.floor(c_out / 4)) self.mapping_func2 = nn.Conv2d(in_channels=math.floor(c_out / 4), out_channels=c_in, kernel_size=(1, 1), stride=(1, 1), bias=True) self.bn_rsconv = nn.BatchNorm2d(c_in) # self.cr_mapping = nn.Conv1d(in_channels=c_in, out_channels=c_out, kernel_size=1, stride=1, bias=True) # self.bn_channel_raising = nn.BatchNorm1d(c_out) last_channel = c_in if not first_layer else 16 for out_channel in mlp: self.mlp_convs.append( nn.Conv2d(last_channel, out_channel, 1, bias=False)) self.mlp_bns.append(nn.BatchNorm2d(out_channel)) last_channel = out_channel
def __init__(self, npoint, radius, nsample, in_channel, mlp, group_all): super(SAModule, self).__init__() self.npoint = npoint self.radius = radius self.nsample = nsample self.group_all = group_all self.mlp_convs = nn.ModuleList() self.mlp_bns = nn.ModuleList() last_channel = in_channel + 3 # TODO: for out_channel in mlp: self.mlp_convs.append( nn.Conv2d(last_channel, out_channel, 1, bias=False)) self.mlp_bns.append(nn.BatchNorm2d(out_channel)) last_channel = out_channel if group_all: self.queryandgroup = pointutils.GroupAll() else: self.queryandgroup = pointutils.QueryAndGroup(radius, nsample)