예제 #1
0
 def __init__(self, num_layers, ndim, shape, kernel_size, stride, padding,
              dilation):
     super().__init__()
     layers = [
         spconv.SparseMaxPool3d(kernel_size, stride, padding, dilation)
     ]
     for i in range(1, num_layers):
         layers.append(
             spconv.SparseMaxPool3d(kernel_size, stride, padding, dilation))
     self.net = spconv.SparseSequential(*layers, )
     self.shape = shape
예제 #2
0
 def __init__(self,
              num_layers,
              ndim,
              shape,
              in_channels,
              out_channels,
              kernel_size,
              stride,
              padding,
              dilation,
              algo=spconv.ConvAlgo.Native):
     super().__init__()
     layers = [
         spconv.SparseConv3d(in_channels,
                             out_channels,
                             kernel_size,
                             stride,
                             padding=padding,
                             dilation=dilation,
                             bias=False,
                             use_hash=False,
                             algo=algo)
     ]
     for i in range(1, num_layers):
         layers.append(
             spconv.SparseConv3d(out_channels,
                                 out_channels,
                                 kernel_size,
                                 stride,
                                 padding=padding,
                                 dilation=dilation,
                                 bias=False,
                                 use_hash=False,
                                 algo=algo))
     self.net = spconv.SparseSequential(*layers, )
     # self.grid = torch.full([3, *shape], -1, dtype=torch.int32).cuda()
     self.grid = None
     self.shape = shape
예제 #3
0
 def __init__(self, num_layers, ndim, shape, in_channels, out_channels,
              kernel_size, stride, padding, dilation):
     super().__init__()
     layers = [
         spconv.SparseConvTranspose3d(in_channels,
                                      out_channels,
                                      kernel_size,
                                      stride,
                                      padding=padding,
                                      dilation=dilation,
                                      bias=False)
     ]
     for i in range(1, num_layers):
         layers.append(
             spconv.SparseConvTranspose3d(out_channels,
                                          out_channels,
                                          kernel_size,
                                          stride,
                                          padding=padding,
                                          dilation=dilation,
                                          bias=False))
     self.net = spconv.SparseSequential(*layers, )
     self.shape = shape
예제 #4
0
    def __init__(self,
                 spatial_shape,
                 use_norm=True,
                 num_input_features=3,
                 name='SpMiddleFHDLite'):
        """
        @param: output_shape: a dense shape, which feed to RPN
        @param: use_norm: if use batchnorm
        @param: num_input_features: depends on the output shape from VFE block
        @param: name:
        """
        super(SpMiddleFHDLite, self).__init__()
        self.name = name
        if use_norm:
            BatchNorm1d = change_default_args(eps=1e-3, momentum=0.01)(nn.BatchNorm1d)
            SpConv3d = change_default_args(bias=False)(spconv.SparseConv3d)
        else:
            BatchNorm1d = Empty
            SpConv3d = change_default_args(bias=True)(spconv.SparseConv3d)

        # ToDO: add if condition for when need padding 3D tensor
        self.spatial_shape = np.array(spatial_shape) + [1, 0, 0]  # padding input shape e.g. [41 1280, 1056]
        # input: # [1600, 1200, 41]
        self.middle_conv = spconv.SparseSequential(
            SpConv3d(num_input_features, 16, 3, 2, padding=1),  # [1600, 1200, 41] -> [800, 600, 21]
            BatchNorm1d(16),
            nn.ReLU(),
            SpConv3d(16, 32, 3, 2, padding=1),  # [800, 600, 21] -> [400, 300, 11]
            BatchNorm1d(32),
            nn.ReLU(),
            SpConv3d(32, 64, 3, 2, padding=[0, 1, 1]),  # [400, 300, 11] -> [200, 150, 5]
            BatchNorm1d(64),
            nn.ReLU(),
            SpConv3d(64, 64, (3, 1, 1), (2, 1, 1)),  # [200, 150, 5] -> [200, 150, 2]
            BatchNorm1d(64),
            nn.ReLU(),
        )