Exemple #1
0
    def __init__(self,
                 in_channels,
                 out_channels,
                 growth_rate,
                 mesh_kernel_size,
                 max_iter=2,
                 bn_momentum=0.1):
        super(EncoderMeshBlock, self).__init__()
        self.maxIter = max_iter

        factor = 4
        self.MeshConvGroup = []
        _in_channels_ = in_channels
        for n in range(0, self.maxIter):
            MeshConv1 = V2VConv3d(_in_channels_,
                                  [factor * growth_rate, factor * growth_rate],
                                  mesh_kernel_size,
                                  dual_depth_multiplier=[1, 1],
                                  bn_momentum=bn_momentum)
            MeshConv2 = V2VConv3d(factor * growth_rate,
                                  [factor * growth_rate, growth_rate],
                                  mesh_kernel_size,
                                  dual_depth_multiplier=[1, 1],
                                  bn_momentum=bn_momentum)
            self.MeshConvGroup.append(MeshConv1)
            self.MeshConvGroup.append(MeshConv2)
            _in_channels_ += growth_rate

        self.Transit = PerItemConv3d(_in_channels_,
                                     out_channels,
                                     bn_momentum=bn_momentum)
Exemple #2
0
 def __init__(self, in_channels, out_channels, mesh_kernel_size,
              scope='', with_bn=True, bn_momentum=0.9):
     super(FirstBlock, self).__init__()
     self.MLP0 = PerItemConv3d(in_channels, out_channels, with_bn=with_bn,
                               scope='mlp0', bn_momentum=bn_momentum)
     self.F2V0 = F2VConv3d(out_channels, out_channels, mesh_kernel_size,
                           depth_multiplier=2, scope=scope+'/F2V0',
                           with_bn=with_bn, bn_momentum=bn_momentum)
Exemple #3
0
    def __init__(self,
                 in_channels,
                 out_channels,
                 growth_rate,
                 mesh_kernel_size,
                 radius,
                 max_iter=2,
                 max_nn=None,
                 bn_momentum=0.1):
        super(DualBlock, self).__init__()
        self.radius = radius
        self.max_nn = max_nn
        self.maxIter = max_iter
        self.pcloud_kernel = [8, 4, 1]  # keep as default

        factor = 4
        self.DualConvGroup = []
        _in_channels_ = in_channels
        for n in range(0, self.maxIter):
            MeshConv1 = V2VConv3d(_in_channels_,
                                  [factor * growth_rate, factor * growth_rate],
                                  mesh_kernel_size,
                                  dual_depth_multiplier=[1, 1],
                                  bn_momentum=bn_momentum)
            MeshConv2 = V2VConv3d(factor * growth_rate,
                                  [factor * growth_rate, 2 * growth_rate],
                                  mesh_kernel_size,
                                  dual_depth_multiplier=[1, 1],
                                  bn_momentum=bn_momentum)
            Dense = PerItemConv3d(_in_channels_,
                                  factor * growth_rate,
                                  bn_momentum=bn_momentum)
            PCloudConv1 = PCloudConv3d(factor * growth_rate,
                                       2 * growth_rate,
                                       np.prod(self.pcloud_kernel) + 1,
                                       bn_momentum=bn_momentum)
            self.DualConvGroup.append(MeshConv1)
            self.DualConvGroup.append(MeshConv2)
            self.DualConvGroup.append(Dense)
            self.DualConvGroup.append(PCloudConv1)
            _in_channels_ += (2 * growth_rate * 2)

        self.Transit = PerItemConv3d(_in_channels_,
                                     out_channels,
                                     bn_momentum=bn_momentum)
Exemple #4
0
 def __init__(self, in_channels, out_channels, mesh_kernel_size, scope='',
              with_bn=True, bn_momentum=0.9):
     super(FirstBlockTexture, self).__init__()
     GeometryInChannels, TextureInChannels = in_channels
     self.F2F0 = F2FConv3d(TextureInChannels, out_channels, with_bn=with_bn,
                           scope='f2f0', bn_momentum=bn_momentum)
     self.MLP0 = PerItemConv3d(GeometryInChannels, out_channels, with_bn=with_bn,
                               scope='mlp0', bn_momentum=bn_momentum)
     self.F2V0 = F2VConv3d(out_channels*2, out_channels, mesh_kernel_size,
                           depth_multiplier=1, scope=scope+'/F2V0',
                           with_bn=with_bn, bn_momentum=bn_momentum)
Exemple #5
0
    def __init__(self,
                 num_class,
                 stride=None,
                 mix_components=27,
                 use_height=False,
                 pred_facet=False):
        super(PicassoNetII, self).__init__()

        if stride is None:
            self.stride = [1.5, 1.5, 1.5, 1.5]
        self.num_class = num_class
        self.num_clusters = mix_components
        self.useArea, self.wgtBnd = (
            True, 1.)  # recommended hyper-parameters for mesh decimation
        self.temperature = 0.1
        self.bn_momentum = 0.99
        self.num_blocks = 5
        self.Niters = [2, 2, 4, 4, 4]
        self.radius = [0.2, 0.4, 0.8]
        self.EncodeChannels = [32, 64, 96, 128, 192, 256]
        self.useHeight = use_height
        if self.useHeight:
            geometry_in_channels = 12
        else:
            geometry_in_channels = 9
        self.predFacet = pred_facet

        self.min_nv = 80  # set the minimum vertex number for the coarsest layer
        self.stride = np.float32(self.stride)
        self.nv_limit = np.int32(
            np.cumprod(self.stride[::-1])[::-1] * self.min_nv)
        self.build_mesh_hierarchy = meshUtil.MeshHierarchy(
            self.stride, self.nv_limit, self.useArea, self.wgtBnd)
        self.cluster = []
        for k in range(self.num_blocks + 1):
            self.cluster.append(
                BuildF2VCoeff(self.num_clusters,
                              tau=self.temperature,
                              scope='cluster%d' % k))

        # FirstBlock
        self.Conv0 = FirstBlock(geometry_in_channels,
                                self.EncodeChannels[0],
                                self.num_clusters,
                                bn_momentum=self.bn_momentum,
                                scope='conv0')

        # setting of convolution blocks in the encoder
        self.Block = []
        growth_rate = 32
        self.Block.append(
            EncoderMeshBlock(self.EncodeChannels[0],
                             self.EncodeChannels[1],
                             growth_rate,
                             self.num_clusters,
                             max_iter=self.Niters[0],
                             bn_momentum=self.bn_momentum,
                             scope='block1'))
        self.Block.append(
            EncoderMeshBlock(self.EncodeChannels[1],
                             self.EncodeChannels[2],
                             growth_rate,
                             self.num_clusters,
                             max_iter=self.Niters[1],
                             bn_momentum=self.bn_momentum,
                             scope='block2'))
        self.Block.append(
            DualBlock(self.EncodeChannels[2],
                      self.EncodeChannels[3],
                      growth_rate,
                      self.num_clusters,
                      radius=self.radius[0],
                      max_iter=self.Niters[2],
                      bn_momentum=self.bn_momentum,
                      scope='block3'))
        self.Block.append(
            DualBlock(self.EncodeChannels[3],
                      self.EncodeChannels[4],
                      growth_rate,
                      self.num_clusters,
                      radius=self.radius[1],
                      max_iter=self.Niters[3],
                      bn_momentum=self.bn_momentum,
                      scope='block4'))
        self.Block.append(
            DualBlock(self.EncodeChannels[4],
                      self.EncodeChannels[5],
                      growth_rate,
                      self.num_clusters,
                      radius=self.radius[2],
                      max_iter=self.Niters[4],
                      bn_momentum=self.bn_momentum,
                      scope='block5'))

        # reducing channels of low-level features in the encoder
        self.Decode = []
        self.DecodeChannels = [self.EncodeChannels[-1], 128, 128, 96, 96, 96]
        for k in range(self.num_blocks):
            m = self.num_blocks - k - 1
            self.Decode.append(
                PerItemConv3d(self.EncodeChannels[m] + self.DecodeChannels[k],
                              self.DecodeChannels[k + 1],
                              bn_momentum=self.bn_momentum,
                              scope='decode%d' % m))
            print(self.EncodeChannels[m] + self.DecodeChannels[k],
                  self.DecodeChannels[k + 1])

        # mesh pooling, unpooling configuration
        self.Mesh_Pool = mesh_pool(method='max')
        self.Mesh_Unpool = mesh_unpool()

        # classifier
        if self.predFacet:
            self.V2F0 = V2FConv3d(96, 96, scope='V2F0_pred')
        self.Predict = PerItemConv3d(96,
                                     self.num_class,
                                     scope='prediction',
                                     with_bn=False,
                                     activation_fn=None)
Exemple #6
0
    def __init__(self,
                 num_class,
                 stride=None,
                 mix_components=27,
                 use_height=False):
        super(PicassoNetII, self).__init__()

        if stride is None:
            self.stride = [1.5, 1.5, 1.5, 1.5]
        else:
            assert (len(stride) == 4)
            self.stride = stride
        self.num_class = num_class
        self.num_clusters = mix_components
        self.useArea, self.wgtBnd = (
            True, 1.)  # recommended hyper-parameters for mesh decimation
        self.temperature = 0.1
        self.bn_momentum = 0.01
        self.num_blocks = 5
        self.Niters = [2, 2, 4, 4, 4]
        self.radius = [0.2, 0.4, 0.8]
        self.EncodeChannels = [32, 64, 96, 128, 192, 256]
        self.useHeight = use_height
        if self.useHeight:
            geometry_in_channels = 12
        else:
            geometry_in_channels = 9

        self.min_nv = 80  # set the minimum vertex number for the coarsest layer
        self.stride = np.float32(self.stride)
        self.nv_limit = np.int32(
            np.cumprod(self.stride[::-1])[::-1] * self.min_nv)

        self.build_mesh_hierarchy = meshUtil.MeshHierarchy(
            self.stride, self.nv_limit, self.useArea, self.wgtBnd)

        self.cluster = []
        for k in range(self.num_blocks):
            self.cluster.append(
                BuildF2VCoeff(self.num_clusters, tau=self.temperature))

        # FirstBlock
        self.Conv0 = FirstBlock(geometry_in_channels,
                                self.EncodeChannels[0],
                                self.num_clusters,
                                bn_momentum=self.bn_momentum)

        # setting of convolution blocks in the encoder
        self.Block = []
        growth_rate = 32
        self.Block.append(
            EncoderMeshBlock(self.EncodeChannels[0],
                             self.EncodeChannels[1],
                             growth_rate,
                             self.num_clusters,
                             max_iter=self.Niters[0],
                             bn_momentum=self.bn_momentum))
        self.Block.append(
            EncoderMeshBlock(self.EncodeChannels[1],
                             self.EncodeChannels[2],
                             growth_rate,
                             self.num_clusters,
                             max_iter=self.Niters[1],
                             bn_momentum=self.bn_momentum))
        self.Block.append(
            DualBlock(self.EncodeChannels[2],
                      self.EncodeChannels[3],
                      growth_rate,
                      self.num_clusters,
                      radius=self.radius[0],
                      max_iter=self.Niters[2],
                      bn_momentum=self.bn_momentum))
        self.Block.append(
            DualBlock(self.EncodeChannels[3],
                      self.EncodeChannels[4],
                      growth_rate,
                      self.num_clusters,
                      radius=self.radius[1],
                      max_iter=self.Niters[3],
                      bn_momentum=self.bn_momentum))
        self.Block.append(
            DualBlock(self.EncodeChannels[4],
                      self.EncodeChannels[5],
                      growth_rate,
                      self.num_clusters,
                      radius=self.radius[2],
                      max_iter=self.Niters[4],
                      bn_momentum=self.bn_momentum))

        # mesh pooling, unpooling configuration
        self.Mesh_Pool = mesh_pool(method='max')
        self.Mesh_Unpool = mesh_unpool()
        self.globalPool = global_mesh_pool(method='avg')

        # classifier
        self.FC1 = PerItemConv3d(self.EncodeChannels[-1], 128)
        self.DP = nn.Dropout(0.2)
        self.FC2 = PerItemConv3d(128,
                                 self.num_class,
                                 with_bn=False,
                                 activation_fn=None)