Ejemplo n.º 1
0
    def __init__(self, d_out):  #  d_in = d_out//2
        super().__init__()
        self.mlp1 = pt_utils.Conv2d(10,
                                    d_out // 2,
                                    kernel_size=(1, 1),
                                    bn=True)
        self.att_pooling_1 = Att_pooling(d_out, d_out // 2)

        self.mlp2 = pt_utils.Conv2d(d_out // 2,
                                    d_out // 2,
                                    kernel_size=(1, 1),
                                    bn=True)
        self.att_pooling_2 = Att_pooling(d_out, d_out)
Ejemplo n.º 2
0
    def __init__(self, d_out, groups):  #  d_in = d_out//2
        super().__init__()
        self.groups = groups

        self.lpe = pt_utils.Conv2d(10,
                                   d_out // (2 * self.groups),
                                   kernel_size=(1, 1),
                                   bn=True)
Ejemplo n.º 3
0
    def __init__(self, d_in, d_out):
        super().__init__()

        self.mlp1 = pt_utils.Conv2d(d_in,
                                    d_out // 2,
                                    kernel_size=(1, 1),
                                    bn=True)
        self.lfa = Building_block(d_out)
        self.mlp2 = pt_utils.Conv2d(d_out,
                                    d_out * 2,
                                    kernel_size=(1, 1),
                                    bn=True,
                                    activation=None)
        self.shortcut = pt_utils.Conv2d(d_in,
                                        d_out * 2,
                                        kernel_size=(1, 1),
                                        bn=True,
                                        activation=None)
Ejemplo n.º 4
0
    def __init__(self, d_out, groups):  #  d_in = d_out//2
        super().__init__()

        self.groups = groups

        self.gcv = d_out // (
            2 * 2
        )  # first 2 for halfed feature, second 4 for local/non-local ratio
        self.lcv = d_out // 2 - self.gcv

        self.lpe = pt_utils.Conv2d(d_out // (2 * self.groups),
                                   self.lcv // (self.groups),
                                   kernel_size=(1, 1),
                                   bn=True)
        self.gpe = pt_utils.Conv2d(10,
                                   self.gcv // (self.groups),
                                   kernel_size=(1, 1),
                                   bn=True)
Ejemplo n.º 5
0
    def __init__(self, radius: float, nsamples: int, in_channels: int,
                 out_channels: int):
        super().__init__()

        self.radius = radius
        self.nsamples = nsamples
        self.in_channels = in_channels

        self.fc = pt_utils.Conv2d(in_size=in_channels + out_channels + 3,
                                  out_size=out_channels,
                                  activation=None,
                                  bn=None)
Ejemplo n.º 6
0
    def __init__(self, d_in, d_out, groups):
        super().__init__()

        # query/key for Local Block
        self.qk1 = pt_utils.Conv2d(d_in, d_out, kernel_size=(1, 1), bn=False)
        self.v1 = pt_utils.Conv2d(d_in,
                                  d_out // 2,
                                  kernel_size=(1, 1),
                                  bn=True)

        # query/key for Local/Global Blocks (i-1)
        self.qk2 = pt_utils.Conv2d(d_out, d_out, kernel_size=(1, 1), bn=False)
        self.v2 = pt_utils.Conv2d(d_out,
                                  d_out // 2,
                                  kernel_size=(1, 1),
                                  bn=True)

        # value for Local/Global Blocks
        self.lblock = GTLModule(d_out, groups)
        self.gblock = GTModule(d_out, groups)

        # After Aggregation
        self.mlp2 = pt_utils.Conv2d(d_out,
                                    d_out * 2,
                                    kernel_size=(1, 1),
                                    bn=True,
                                    activation=None)
        self.shortcut = pt_utils.Conv2d(d_in,
                                        d_out * 2,
                                        kernel_size=(1, 1),
                                        bn=True,
                                        activation=None)
Ejemplo n.º 7
0
    def __init__(self, config, dataset_name='SemanticKITTI'):
        super().__init__()
        self.config = config
        self.class_weights = DP.get_class_weights(dataset_name)

        self.fc0 = pt_utils.Conv1d(3, 8, kernel_size=1, bn=True)

        self.dilated_res_blocks = nn.ModuleList()
        d_in = 8
        for i in range(self.config.num_layers):
            d_out = self.config.d_out[i]
            self.dilated_res_blocks.append(Dilated_res_block(d_in, d_out))
            d_in = 2 * d_out

        d_out = d_in
        self.decoder_0 = pt_utils.Conv2d(d_in,
                                         d_out,
                                         kernel_size=(1, 1),
                                         bn=True)

        self.decoder_blocks = nn.ModuleList()
        for j in range(self.config.num_layers):
            if j < 3:
                d_in = d_out + 2 * self.config.d_out[-j - 2]
                d_out = 2 * self.config.d_out[-j - 2]
            else:
                d_in = 4 * self.config.d_out[-4]
                d_out = 2 * self.config.d_out[-4]
            self.decoder_blocks.append(
                pt_utils.Conv2d(d_in, d_out, kernel_size=(1, 1), bn=True))

        self.fc1 = pt_utils.Conv2d(d_out, 64, kernel_size=(1, 1), bn=True)
        self.fc2 = pt_utils.Conv2d(64, 32, kernel_size=(1, 1), bn=True)
        self.dropout = nn.Dropout(0.5)
        self.fc3 = pt_utils.Conv2d(32,
                                   self.config.num_classes,
                                   kernel_size=(1, 1),
                                   bn=False,
                                   activation=None)
Ejemplo n.º 8
0
 def __init__(self, d_in, d_out):
     super().__init__()
     self.fc = nn.Conv2d(d_in, d_in, (1, 1), bias=False)
     self.mlp = pt_utils.Conv2d(d_in, d_out, kernel_size=(1, 1), bn=True)
Ejemplo n.º 9
0
    def __init__(self, config):
        super().__init__()

        self.config = config
        self.class_weights = self.config.class_weights

        if self.config.name == 'SemanticKITTI':
            self.fc0 = pt_utils.Conv1d(3, 8, kernel_size=1, bn=True)
        elif self.config.name == 'S3DIS':
            self.fc0 = pt_utils.Conv1d(6, 8, kernel_size=1, bn=True)
        elif self.config.name == 'Semantic3D':
            assert 1 == 2, "Not checked yet"

        self.dilated_res_blocks = nn.ModuleList()

        d_in = 8

        # Encoder
        for i in range(self.config.num_layers):
            d_out = self.config.d_out[i]
            self.dilated_res_blocks.append(Dilated_res_block(d_in, d_out))
            d_in = 2 * d_out

        d_out = d_in

        # First layer of Decoder
        self.decoder_0 = pt_utils.Conv2d(d_in,
                                         d_out,
                                         kernel_size=(1, 1),
                                         bn=True)

        # Decoder
        self.decoder_blocks = nn.ModuleList()

        for j in range(self.config.num_layers):
            if self.config.name == "SemanticKITTI":
                if j < 3:
                    # j = 0, -j-2 = -2, 512 + 128*2 -> 256
                    # j = 1, -j-2 = -3, 256 + 64*2 -> 128
                    # j = 2, -j-2 = -4, 128 + 16*2 -> 32
                    d_in = d_out + 2 * self.config.d_out[-j - 2]
                    d_out = 2 * self.config.d_out[-j - 2]
                else:
                    # j = 3, 32 + 32 -> 32
                    d_in = 4 * self.config.d_out[-4]
                    d_out = 2 * self.config.d_out[-4]
            elif self.config.name in ["S3DIS", "Semantic3D"]:
                if j < 4:
                    d_in = d_out + 2 * self.config.d_out[-j - 2]
                    d_out = 2 * self.config.d_out[-j - 2]
                else:
                    d_in = 4 * self.config.d_out[-5]
                    d_out = 2 * self.config.d_out[-5]

            self.decoder_blocks.append(
                pt_utils.Conv2d(d_in, d_out, kernel_size=(1, 1), bn=True))
            #print("j : {}, d_in : {}, d_out : {}".format(j, d_in, d_out))

        self.fc1 = pt_utils.Conv2d(d_out, 64, kernel_size=(1, 1), bn=True)
        self.fc2 = pt_utils.Conv2d(64, 32, kernel_size=(1, 1), bn=True)
        self.dropout = nn.Dropout(0.5)
        self.fc3 = pt_utils.Conv2d(32,
                                   self.config.num_classes,
                                   kernel_size=(1, 1),
                                   bn=False,
                                   activation=None)