def __init__(self, pts_voxel_layer=None, pts_voxel_encoder=None, pts_middle_encoder=None, img_backbone=None, img_seg_head=None, pts_backbone=None, pts_neck=None, pts_bbox_head=None, train_cfg=None, test_cfg=None, pretrained=None, pts_fc=[], contrast_criterion=None, max_pts=4096, lambda_contrast=0.1): super(FusionContrastV2, self).__init__() if img_backbone: self.img_backbone = builder.build_backbone(img_backbone) if img_seg_head: self.img_seg_head = builder.build_head(img_seg_head) if pts_voxel_layer: self.pts_voxel_layer = Voxelization(**pts_voxel_layer) if pts_voxel_encoder: self.pts_voxel_encoder = builder.build_voxel_encoder( pts_voxel_encoder) if pts_middle_encoder: self.pts_middle_encoder = builder.build_middle_encoder( pts_middle_encoder) if pts_backbone: self.pts_backbone = builder.build_backbone(pts_backbone) if pts_neck: self.pts_neck = builder.build_neck(pts_neck) if pts_bbox_head: pts_train_cfg = train_cfg.pts if train_cfg else None pts_bbox_head.update(train_cfg=pts_train_cfg) pts_test_cfg = test_cfg.pts if test_cfg else None pts_bbox_head.update(test_cfg=pts_test_cfg) self.pts_bbox_head = builder.build_head(pts_bbox_head) if contrast_criterion: self.contrast_criterion = builder.build_loss(contrast_criterion) self.max_pts = max_pts self.lambda_contrast = lambda_contrast fc_layers = [] for i, (in_c, out_c) in enumerate(zip(pts_fc[:-1], pts_fc[1:])): fc_layers.append(nn.Linear(in_c, out_c)) if i == len(pts_fc) - 2: break fc_layers.append(nn.ReLU(inplace=True)) self.fc_layers = nn.Sequential(*fc_layers) self.train_cfg = train_cfg self.test_cfg = test_cfg self.init_weights(pretrained=pretrained)
def test_imvoxel_neck(): if not torch.cuda.is_available(): pytest.skip('test requires GPU and torch+cuda') neck_cfg = dict( type='OutdoorImVoxelNeck', in_channels=64, out_channels=256) neck = build_neck(neck_cfg).cuda() inputs = torch.rand([1, 64, 216, 248, 12], device='cuda') outputs = neck(inputs) assert outputs[0].shape == (1, 256, 248, 216)
def test_centerpoint_fpn(): second_cfg = dict( type='SECOND', in_channels=64, out_channels=[64, 128, 256], layer_nums=[3, 5, 5], layer_strides=[2, 2, 2], norm_cfg=dict(type='BN', eps=1e-3, momentum=0.01), conv_cfg=dict(type='Conv2d', bias=False)) second = build_backbone(second_cfg) # centerpoint usage of fpn centerpoint_fpn_cfg = dict( type='SECONDFPN', in_channels=[64, 128, 256], out_channels=[128, 128, 128], upsample_strides=[0.5, 1, 2], norm_cfg=dict(type='BN', eps=1e-3, momentum=0.01), upsample_cfg=dict(type='deconv', bias=False), use_conv_for_no_stride=True) # original usage of fpn fpn_cfg = dict( type='SECONDFPN', in_channels=[64, 128, 256], upsample_strides=[1, 2, 4], out_channels=[128, 128, 128]) second_fpn = build_neck(fpn_cfg) centerpoint_second_fpn = build_neck(centerpoint_fpn_cfg) input = torch.rand([4, 64, 512, 512]) sec_output = second(input) centerpoint_output = centerpoint_second_fpn(sec_output) second_output = second_fpn(sec_output) assert centerpoint_output[0].shape == torch.Size([4, 384, 128, 128]) assert second_output[0].shape == torch.Size([4, 384, 256, 256])
def __init__(self, pts_voxel_layer=None, pts_voxel_encoder=None, pts_middle_encoder=None, img_backbone=None, img_seg_head=None, pts_backbone=None, pts_neck=None, pts_bbox_head=None, train_cfg=None, test_cfg=None, pretrained=None, pts_fc=[]): super(FusionBaseline4, self).__init__() if img_backbone: self.img_backbone = builder.build_backbone(img_backbone) if img_seg_head: self.img_seg_head = builder.build_head(img_seg_head) if pts_voxel_layer: self.pts_voxel_layer = Voxelization(**pts_voxel_layer) if pts_voxel_encoder: self.pts_voxel_encoder = builder.build_voxel_encoder( pts_voxel_encoder) if pts_middle_encoder: self.pts_middle_encoder = builder.build_middle_encoder( pts_middle_encoder) if pts_backbone: self.pts_backbone = builder.build_backbone(pts_backbone) if pts_neck is not None: self.pts_neck = builder.build_neck(pts_neck) if pts_bbox_head: pts_train_cfg = train_cfg.pts if train_cfg else None pts_bbox_head.update(train_cfg=pts_train_cfg) pts_test_cfg = test_cfg.pts if test_cfg else None pts_bbox_head.update(test_cfg=pts_test_cfg) self.pts_bbox_head = builder.build_head(pts_bbox_head) fc_layers = [] for i, (in_c, out_c) in enumerate(zip(pts_fc[:-1], pts_fc[1:])): fc_layers.append(nn.Linear(in_c, out_c)) if i == len(pts_fc) - 2: break fc_layers.append(nn.ReLU(inplace=True)) self.fc_layers = nn.Sequential(*fc_layers) self.train_cfg = train_cfg self.test_cfg = test_cfg self.init_weights(pretrained=pretrained)
def __init__(self, pts_voxel_layer=None, pts_voxel_encoder=None, pts_middle_encoder=None, img_backbone=None, img_seg_head=None, pts_backbone=None, pts_neck=None, pts_bbox_head=None, train_cfg=None, test_cfg=None, pretrained=None, vfes=[]): super(FusionBaseline, self).__init__() if img_backbone: self.img_backbone = builder.build_backbone(img_backbone) if img_seg_head: self.img_seg_head = builder.build_head(img_seg_head) if pts_voxel_layer: self.pts_voxel_layer = Voxelization(**pts_voxel_layer) if pts_voxel_encoder: self.pts_voxel_encoder = builder.build_voxel_encoder( pts_voxel_encoder) if pts_middle_encoder: self.pts_middle_encoder = builder.build_middle_encoder( pts_middle_encoder) if pts_backbone: self.pts_backbone = builder.build_backbone(pts_backbone) if pts_neck is not None: self.pts_neck = builder.build_neck(pts_neck) if pts_bbox_head: pts_train_cfg = train_cfg.pts if train_cfg else None pts_bbox_head.update(train_cfg=pts_train_cfg) pts_test_cfg = test_cfg.pts if test_cfg else None pts_bbox_head.update(test_cfg=pts_test_cfg) self.pts_bbox_head = builder.build_head(pts_bbox_head) vfe_layers = [] for in_c, out_c in zip(vfes[:-1], vfes[1:]): vfe_layers.append(VFELayer(in_c, out_c, max_out=False)) self.vfe_layers = nn.Sequential(*vfe_layers) self.train_cfg = train_cfg self.test_cfg = test_cfg self.init_weights(pretrained=pretrained)
def __init__(self, pts_voxel_layer=None, pts_voxel_encoder=None, pts_middle_encoder=None, img_backbone=None, img_seg_head=None, pts_backbone=None, pts_neck=None, pts_bbox_head=None, train_cfg=None, test_cfg=None, pretrained=None): super(MultiTaskSep, self).__init__() if img_backbone: self.img_backbone = builder.build_backbone(img_backbone) if img_seg_head: self.img_seg_head = builder.build_head(img_seg_head) if pts_voxel_layer: self.pts_voxel_layer = Voxelization(**pts_voxel_layer) if pts_voxel_encoder: self.pts_voxel_encoder = builder.build_voxel_encoder( pts_voxel_encoder) if pts_middle_encoder: self.pts_middle_encoder = builder.build_middle_encoder( pts_middle_encoder) if pts_backbone: self.pts_backbone = builder.build_backbone(pts_backbone) if pts_neck is not None: self.pts_neck = builder.build_neck(pts_neck) if pts_bbox_head: pts_train_cfg = train_cfg.pts if train_cfg else None pts_bbox_head.update(train_cfg=pts_train_cfg) pts_test_cfg = test_cfg.pts if test_cfg else None pts_bbox_head.update(test_cfg=pts_test_cfg) self.pts_bbox_head = builder.build_head(pts_bbox_head) self.train_cfg = train_cfg self.test_cfg = test_cfg self.init_weights(pretrained=pretrained)