Beispiel #1
0
    def __init__(self,
                 n_class=40,
                 num_points=8192,
                 bottleneck_size=1024,
                 n_primitives=16,
                 norm_mode='none'):
        super(PMSN_pretrain_cls, self).__init__()

        # MSN
        self.num_points = num_points
        self.bottleneck_size = bottleneck_size
        self.n_primitives = n_primitives
        self.norm_mode = norm_mode
        self.MSN_encoder = nn.Sequential(
            PointNetfeat(num_points, global_feat=True),
            nn.Linear(1024, self.bottleneck_size),
            nn.BatchNorm1d(self.bottleneck_size), nn.ReLU())
        self.decoder = nn.ModuleList([
            PointGenCon(bottleneck_size=2 + self.bottleneck_size)
            for i in range(0, self.n_primitives)
        ])
        self.expansion = expansion.expansionPenaltyModule()

        # cls
        self.fc1 = nn.Linear(1024, 512)
        self.fc2 = nn.Linear(512, 256)
        self.fc3 = nn.Linear(256, n_class)
        self.dropout = nn.Dropout(p=0.4)
        self.bn1 = nn.BatchNorm1d(512)
        self.bn2 = nn.BatchNorm1d(256)
        self.relu = nn.ReLU()
Beispiel #2
0
 def __init__(self, num_points=2048, bottleneck_size=256, n_primitives=16):
     super(MSN, self).__init__()
     self.num_points = num_points
     self.bottleneck_size = bottleneck_size
     self.n_primitives = n_primitives
     self.decoder = nn.ModuleList([
         PointGenCon(bottleneck_size=2 + self.bottleneck_size)
         for i in range(0, self.n_primitives)
     ])
     self.res = PointNetRes()
     self.expansion = expansion.expansionPenaltyModule()
Beispiel #3
0
 def __init__(self, num_points=8192, bottleneck_size=1024, n_primitives=16):
     super(MSN, self).__init__()
     self.num_points = num_points
     self.bottleneck_size = bottleneck_size
     self.n_primitives = n_primitives
     self.encoder = nn.Sequential(
         PointNetfeat(num_points, global_feat=True),
         nn.Linear(1024, self.bottleneck_size),
         nn.BatchNorm1d(self.bottleneck_size), nn.ReLU())
     self.decoder = nn.ModuleList([
         PointGenCon(bottleneck_size=2 + self.bottleneck_size)
         for i in range(0, self.n_primitives)
     ])
     self.res = PointNetRes()
     self.expansion = expansion.expansionPenaltyModule()
Beispiel #4
0
    def __init__(self,
                 n_class=40,
                 num_points=8192,
                 bottleneck_size=1024,
                 n_primitives=16,
                 norm_mode='none',
                 a=1,
                 b=1):
        super(PMSN_concat_cls, self).__init__()

        # PointNet
        self.PN_encoder = PointNetEncoder(global_feat=True,
                                          feature_transform=True,
                                          channel=3)

        # MSN
        self.num_points = num_points
        self.bottleneck_size = bottleneck_size
        self.n_primitives = n_primitives
        self.norm_mode = norm_mode
        self.a = a
        self.b = b

        self.MSN_encoder = nn.Sequential(
            PointNetfeat(num_points, global_feat=True),
            nn.Linear(1024, self.bottleneck_size),
            nn.BatchNorm1d(self.bottleneck_size), nn.ReLU())

        self.alpha = nn.Parameter(torch.FloatTensor([self.a]))
        self.beta = nn.Parameter(torch.FloatTensor([self.b]))

        self.decoder = nn.ModuleList([
            PointGenCon(bottleneck_size=2 + self.bottleneck_size)
            for i in range(0, self.n_primitives)
        ])
        self.expansion = expansion.expansionPenaltyModule()

        # cls
        self.fc1 = nn.Linear(2048, 512)
        self.fc2 = nn.Linear(512, 256)
        self.fc3 = nn.Linear(256, n_class)
        self.dropout = nn.Dropout(p=0.4)
        self.bn1 = nn.BatchNorm1d(512)
        self.bn2 = nn.BatchNorm1d(256)
        self.relu = nn.ReLU()
Beispiel #5
0
    def __init__(self,
                 num_points=8192,
                 n_regions=16,
                 dim_pn=256,
                 sp_points=1024):
        super(Network, self).__init__()
        self.num_points = num_points
        self.dim_pn = dim_pn
        self.n_regions = n_regions
        self.sp_points = sp_points
        self.sp_ratio = n_regions

        self.pn_enc = nn.Sequential(PointNetFeat(num_points, 1024),
                                    nn.Linear(1024, dim_pn),
                                    nn.BatchNorm1d(dim_pn), nn.ReLU())

        self.softpool_enc = SoftPoolFeat(num_points,
                                         regions=self.n_regions,
                                         sp_points=2048,
                                         sp_ratio=self.sp_ratio)

        # Firstly we do not merge information among regions
        # We merge regional informations in latent space
        self.reg_conv1 = nn.Sequential(
            nn.Conv2d(1 * dim_pn,
                      dim_pn,
                      kernel_size=(1, 7),
                      stride=(1, 2),
                      padding=(0, 3),
                      padding_mode='same'), nn.Tanh())
        self.reg_conv2 = nn.Sequential(
            nn.Conv2d(dim_pn,
                      2 * dim_pn,
                      kernel_size=(1, 7),
                      stride=(1, 2),
                      padding=(0, 3),
                      padding_mode='same'), nn.Tanh())
        self.reg_conv3 = nn.Sequential(
            nn.Conv2d(2 * dim_pn,
                      2 * dim_pn,
                      kernel_size=(1, 5),
                      stride=(1, 2),
                      padding=(0, 2),
                      padding_mode='same'), nn.Tanh())

        # input for embedding has 32 points now, then in total it is regions x 32 points
        # down-sampled by 2*2*2=8
        ebd_pnt_reg = (self.num_points) // (self.sp_ratio * 8)
        self.embedding = nn.Sequential(
            nn.MaxPool2d(kernel_size=(1, ebd_pnt_reg),
                         stride=(1, ebd_pnt_reg)),
            nn.MaxPool2d(kernel_size=(1, self.n_regions),
                         stride=(1, self.n_regions)),
            nn.ConvTranspose2d(2 * dim_pn,
                               2 * dim_pn,
                               kernel_size=(1, 256),
                               stride=(1, 256),
                               padding=(0, 0)))
        """
        self.embedding = nn.Sequential(
            nn.MaxPool2d(
                kernel_size=(1, ebd_pnt_reg), stride=(1, ebd_pnt_reg)),
            nn.Conv2d(
                2 * dim_pn,
                2 * dim_pn,
                kernel_size=(1, self.n_regions)),
            nn.ConvTranspose2d(
                2 * dim_pn,
                2 * dim_pn,
                kernel_size=(1, 4),
                stride=(1, 4),
                padding=(0, 0)),
            nn.UpsamplingBilinear2d(scale_factor=(1, 4)),
            nn.Conv2d(
                2 * dim_pn,
                2 * dim_pn,
                kernel_size=(1, 5),
                stride=(1, 1),
                padding=(0, 2),
                padding_mode='same'),
            nn.UpsamplingBilinear2d(scale_factor=(1, 16)))
        """
        self.pt_mixing = nn.Sequential(nn.Linear(256, 256), nn.ReLU(),
                                       nn.Linear(256, 256), nn.ReLU(),
                                       nn.Linear(256, 256), nn.ReLU(),
                                       nn.Linear(256, 256), nn.ReLU())

        self.reg_conv4 = nn.Sequential(
            nn.Conv2d(4 * dim_pn,
                      4 * dim_pn,
                      kernel_size=(self.n_regions, 1),
                      stride=(1, 1)))

        self.reg_deconv3 = nn.Sequential(
            nn.ConvTranspose2d(2 * dim_pn,
                               2 * dim_pn,
                               kernel_size=(1, 2),
                               stride=(1, 2),
                               padding=(0, 0)), nn.Tanh())
        self.reg_deconv2 = nn.Sequential(
            nn.ConvTranspose2d(2 * dim_pn,
                               dim_pn,
                               kernel_size=(1, 2),
                               stride=(1, 2),
                               padding=(0, 0)), nn.Tanh())
        self.reg_deconv1 = nn.Sequential(
            nn.ConvTranspose2d(dim_pn,
                               dim_pn,
                               kernel_size=(1, 1),
                               stride=(1, 1),
                               padding=(0, 0)), nn.Tanh())
        self.translate = nn.Sequential(
            nn.Conv2d(dim_pn, dim_pn, kernel_size=(1, 1), stride=(1, 1)),
            nn.Tanh())

        self.decoder1 = PointGenCon(bottleneck_size=self.dim_pn)
        self.decoder2 = PointGenCon(bottleneck_size=self.dim_pn + 3 + 2)
        self.decoder_fold = PointGenCon(bottleneck_size=2 + self.dim_pn)
        self.res = PointNetRes()
        self.expansion = expansion.expansionPenaltyModule()
        self.grnet = grnet.GRNet()
        self.msn = MSN()
Beispiel #6
0
 def __init__(self,
              num_points=8192,
              n_primitives=16,
              dim_pn=256,
              sp_points=1024):
     super(MSN, self).__init__()
     self.num_points = num_points
     self.dim_pn = dim_pn
     self.n_primitives = n_primitives
     self.sp_points = sp_points
     self.pncoder = nn.Sequential(PointNetFeat(num_points, 1024),
                                  nn.Linear(1024, dim_pn),
                                  nn.BatchNorm1d(dim_pn), nn.ReLU())
     # self.spcoder = SoftPoolFeat(num_points, regions=self.n_primitives, sp_points=self.sp_points)
     self.spcoder = SoftPoolFeat(num_points,
                                 regions=self.n_primitives,
                                 sp_points=2048)
     # Firstly we do not merge information among regions
     # We merge regional informations in latent space
     self.ptmapper = nn.Sequential(
         nn.Conv2d(dim_pn + dim_pn + 12 + 3,
                   dim_pn,
                   kernel_size=(1, 7),
                   stride=(1, 2),
                   padding=(0, 3),
                   padding_mode='same'), nn.Tanh(),
         nn.Conv2d(dim_pn,
                   2 * dim_pn,
                   kernel_size=(1, 7),
                   stride=(1, 2),
                   padding=(0, 3),
                   padding_mode='same'), nn.Tanh(),
         nn.Conv2d(2 * dim_pn,
                   2 * dim_pn,
                   kernel_size=(1, 5),
                   stride=(1, 1),
                   padding=(0, 2),
                   padding_mode='same'), nn.Tanh(),
         nn.ConvTranspose2d(2 * dim_pn,
                            dim_pn,
                            kernel_size=(1, 2),
                            stride=(1, 2),
                            padding=(0, 0)),
         nn.ConvTranspose2d(dim_pn,
                            dim_pn,
                            kernel_size=(1, 2),
                            stride=(1, 2),
                            padding=(0, 0)))
     """
         nn.Linear(self.sp_points, self.sp_points),
         nn.ReLU(),
         nn.MaxPool2d(kernel_size=(1, 2), stride=(1, 2)),
         nn.Linear(self.sp_points // 2, self.sp_points // 2),
         nn.ReLU(),
         nn.Linear(self.sp_points // 2, self.sp_points))
     """
     """
         nn.Conv2d(
             n_primitives,
             n_primitives,
             kernel_size=(1, 3),
             stride=(1, 1),
             padding=(0, 1),
             padding_mode='same'), nn.Tanh(),
         nn.Conv2d(
             n_primitives,
             2 * n_primitives,
             kernel_size=(1, 7),
             stride=(1, 2),
             padding=(0, 3),
             padding_mode='same'), nn.Tanh(),
         nn.Conv2d(
             2 * n_primitives,
             2 * n_primitives,
             kernel_size=(1, 7),
             stride=(1, 1),
             padding=(0, 3),
             padding_mode='same'), nn.Tanh(),
         nn.ConvTranspose2d(
             2 * n_primitives,
             n_primitives,
             kernel_size=(1, 2),
             stride=(1, 2),
             padding=(0, 0)),
     """
     # nn.Flatten(start_dim=2, end_dim=3))
     self.decoder1 = nn.ModuleList([
         # PointGenCon(bottleneck_size=self.n_primitives + self.dim_pn)
         PointGenCon(bottleneck_size=self.dim_pn)
         for i in range(0, self.n_primitives)
     ])
     self.decoder2 = nn.ModuleList([
         # PointGenCon(bottleneck_size=self.n_primitives + self.dim_pn)
         PointGenCon(bottleneck_size=2 + 2 * self.dim_pn)
         for i in range(0, self.n_primitives)
     ])
     self.decoder3 = PointGenCon(bottleneck_size=3 + self.dim_pn)
     self.res = PointNetRes()
     self.expansion = expansion.expansionPenaltyModule()