def build_losses(self, losses_cfg): self.cls_loss_func = loss_utils.SigmoidFocalClassificationLoss_v1( alpha=0.25, gamma=2.0) self.reg_loss_func = F.smooth_l1_loss if losses_cfg.get( 'LOSS_REG', None) == 'smooth-l1' else F.l1_loss print("done")
def __init__(self, inchannel): super().__init__() norm_fun = partial(nn.BatchNorm1d, eps=1e-3, momentum=0.01) block = self.conv_block self.conv1 = nn.Sequential( nn.Conv1d(inchannel, 32, 3, bias=False, stride=1, padding=1), norm_fun(32), nn.ReLU()) self.conv2 = nn.Sequential( nn.Conv1d(32, 32, 3, bias=False, stride=1, padding=1), norm_fun(32), nn.ReLU()) self.conv3 = nn.Sequential( nn.Conv1d(32, 32, 3, bias=False, stride=1, padding=1), norm_fun(32), nn.ReLU()) self.deconv1 = nn.Sequential( nn.ConvTranspose1d(32, 64, 3, stride=1, bias=False, padding=1), norm_fun(64), nn.ReLU()) self.conv4 = nn.Sequential( nn.Conv1d(32, 32, 3, bias=False, stride=1, padding=1), norm_fun(32), nn.ReLU()) self.conv5 = nn.Sequential( nn.Conv1d(32, 32, 3, bias=False, stride=1, padding=1), norm_fun(32), nn.ReLU()) self.conv6 = nn.Sequential( nn.Conv1d(32, 32, 3, bias=False, stride=1, padding=1), norm_fun(32), nn.ReLU()) self.deconv2 = nn.Sequential( nn.ConvTranspose1d(32, 64, 3, stride=1, bias=False, padding=1), norm_fun(64), nn.ReLU()) self.cls_layer = nn.Conv1d(128, 2, 1, bias=True) self.seg_loss_func = loss_utils.SigmoidFocalClassificationLoss_v1( alpha=0.25, gamma=2.0) self.ret = {} self.init_weights()
def __init__(self, in_channels): super().__init__() # self.print_info = cfg.print_info norm_fn = partial(nn.BatchNorm1d, eps=1e-3, momentum=0.01) self.conv_input = spconv.SparseSequential( spconv.SubMConv3d(in_channels, 16, 3, padding=1, bias=False, indice_key='subm1'), norm_fn(16), nn.ReLU(), ) block = self.post_act_block self.conv1 = spconv.SparseSequential( block(16, 16, 3, norm_fn=norm_fn, padding=1, indice_key='subm1'), ) self.conv2 = spconv.SparseSequential( # [1600, 1408, 41] <- [800, 704, 21] block(16, 32, 3, norm_fn=norm_fn, stride=2, padding=1, indice_key='spconv2', conv_type='spconv'), block(32, 32, 3, norm_fn=norm_fn, padding=1, indice_key='subm2'), block(32, 32, 3, norm_fn=norm_fn, padding=1, indice_key='subm2'), ) self.conv3 = spconv.SparseSequential( # [800, 704, 21] <- [400, 352, 11] block(32, 64, 3, norm_fn=norm_fn, stride=2, padding=1, indice_key='spconv3', conv_type='spconv'), block(64, 64, 3, norm_fn=norm_fn, padding=1, indice_key='subm3'), block(64, 64, 3, norm_fn=norm_fn, padding=1, indice_key='subm3'), ) self.conv4 = spconv.SparseSequential( # [400, 352, 11] <- [200, 176, 5] block(64, 64, 3, norm_fn=norm_fn, stride=2, padding=(0, 1, 1), indice_key='spconv4', conv_type='spconv'), block(64, 64, 3, norm_fn=norm_fn, padding=1, indice_key='subm4'), block(64, 64, 3, norm_fn=norm_fn, padding=1, indice_key='subm4'), ) last_pad = 0 if cfg.DATA_CONFIG.VOXEL_GENERATOR.VOXEL_SIZE[-1] in [ 0.1, 0.2 ] else (1, 0, 0) self.conv_out = spconv.SparseSequential( # [200, 150, 5] -> [200, 150, 2] spconv.SparseConv3d(64, 128, (3, 1, 1), stride=(2, 1, 1), padding=last_pad, bias=False, indice_key='spconv_down2'), norm_fn(128), nn.ReLU(), ) self.seg_net = SegNet(16) self.seg_loss_func = loss_utils.SigmoidFocalClassificationLoss_v1( alpha=0.25, gamma=2.0) self.num_point_features = 128 self.ret = {}
def build_losses(self,losses_cfg): # loss function definition self.cls_loss_layer = loss_utils.SigmoidFocalClassificationLoss_v1(alpha=0.25, gamma=2.0) self.reg_loss_layer = loss_utils.WeightedSmoothL1Loss_v1(code_weights=losses_cfg['code_loss_weight']) self.dir_loss_layer = loss_utils.WeightedCrossEntropyLoss_v1()