Commit 7ed412b7 authored by zhangwenwei's avatar zhangwenwei
Browse files

Migrate to MMDet V2.0-stable using mmcv cnn bricks

parent 99db60dd
......@@ -8,7 +8,7 @@ from .. import builder
from .base import BaseDetector
@DETECTORS.register_module
@DETECTORS.register_module()
class MVXTwoStageDetector(BaseDetector):
def __init__(self,
......
......@@ -6,7 +6,7 @@ from mmdet.models import DETECTORS, TwoStageDetector
from .. import builder
@DETECTORS.register_module
@DETECTORS.register_module()
class PartA2(TwoStageDetector):
def __init__(self,
......
......@@ -6,7 +6,7 @@ from mmdet.models import DETECTORS, SingleStageDetector
from .. import builder
@DETECTORS.register_module
@DETECTORS.register_module()
class VoxelNet(SingleStageDetector):
def __init__(self,
......@@ -88,7 +88,7 @@ class VoxelNet(SingleStageDetector):
return bbox_list
@DETECTORS.register_module
@DETECTORS.register_module()
class DynamicVoxelNet(VoxelNet):
def __init__(self,
......
import torch
import torch.nn as nn
import torch.nn.functional as F
from mmcv.cnn import xavier_init
from mmcv.cnn import ConvModule, xavier_init
from mmdet.ops import ConvModule
from ..registry import FUSION_LAYERS
......@@ -96,7 +95,7 @@ def point_sample(
return point_features.squeeze().t()
@FUSION_LAYERS.register_module
@FUSION_LAYERS.register_module()
class PointFusion(nn.Module):
"""Fuse image features from fused single scale features
"""
......
......@@ -4,7 +4,7 @@ from torch import nn
from ..registry import MIDDLE_ENCODERS
@MIDDLE_ENCODERS.register_module
@MIDDLE_ENCODERS.register_module()
class PointPillarsScatter(nn.Module):
def __init__(self, in_channels, output_shape):
......
import torch.nn as nn
from mmcv.cnn import build_norm_layer
import mmdet3d.ops.spconv as spconv
from mmdet.ops import build_norm_layer
from ..registry import MIDDLE_ENCODERS
@MIDDLE_ENCODERS.register_module
@MIDDLE_ENCODERS.register_module()
class SparseEncoder(nn.Module):
def __init__(self,
......
import torch
import torch.nn as nn
from mmcv.cnn import build_norm_layer
import mmdet3d.ops.spconv as spconv
from mmdet3d.ops import SparseBasicBlock
from mmdet.ops import build_norm_layer
from ..registry import MIDDLE_ENCODERS
@MIDDLE_ENCODERS.register_module
@MIDDLE_ENCODERS.register_module()
class SparseUNet(nn.Module):
def __init__(self,
......
......@@ -2,16 +2,15 @@ from functools import partial
import torch
import torch.nn as nn
from mmcv.cnn import constant_init, kaiming_init
from mmcv.cnn import build_norm_layer, constant_init, kaiming_init
from torch.nn import Sequential
from torch.nn.modules.batchnorm import _BatchNorm
from mmdet.models import NECKS
from mmdet.ops import build_norm_layer
from .. import builder
@NECKS.register_module
@NECKS.register_module()
class SECONDFPN(nn.Module):
"""Compare with RPN, RPNV2 support arbitrary number of stage.
"""
......@@ -64,7 +63,7 @@ class SECONDFPN(nn.Module):
return [out]
@NECKS.register_module
@NECKS.register_module()
class SECONDFusionFPN(SECONDFPN):
"""Compare with RPN, RPNV2 support arbitrary number of stage.
"""
......
import torch
from mmcv.cnn import build_norm_layer
from torch import nn
from mmdet3d.ops import DynamicScatter
from mmdet.ops import build_norm_layer
from ..registry import VOXEL_ENCODERS
from .utils import PFNLayer, get_paddings_indicator
@VOXEL_ENCODERS.register_module
@VOXEL_ENCODERS.register_module()
class PillarFeatureNet(nn.Module):
def __init__(self,
......@@ -118,7 +118,7 @@ class PillarFeatureNet(nn.Module):
return features.squeeze()
@VOXEL_ENCODERS.register_module
@VOXEL_ENCODERS.register_module()
class DynamicPillarFeatureNet(PillarFeatureNet):
def __init__(self,
......@@ -237,7 +237,7 @@ class DynamicPillarFeatureNet(PillarFeatureNet):
return voxel_feats, voxel_coors
@VOXEL_ENCODERS.register_module
@VOXEL_ENCODERS.register_module()
class AlignedPillarFeatureNet(nn.Module):
def __init__(self,
......
import torch
from mmcv.cnn import build_norm_layer
from torch import nn
from torch.nn import functional as F
from mmdet.ops import build_norm_layer
class Empty(nn.Module):
......
import torch
from mmcv.cnn import build_norm_layer
from torch import nn
from torch.nn import functional as F
from mmdet3d.ops import DynamicScatter
from mmdet.ops import build_norm_layer
from .. import builder
from ..registry import VOXEL_ENCODERS
from .utils import Empty, VFELayer, get_paddings_indicator
@VOXEL_ENCODERS.register_module
@VOXEL_ENCODERS.register_module()
class VoxelFeatureExtractor(nn.Module):
def __init__(self,
......@@ -71,7 +71,7 @@ class VoxelFeatureExtractor(nn.Module):
return voxelwise
@VOXEL_ENCODERS.register_module
@VOXEL_ENCODERS.register_module()
class VoxelFeatureExtractorV2(nn.Module):
def __init__(self,
......@@ -132,7 +132,7 @@ class VoxelFeatureExtractorV2(nn.Module):
return voxelwise
@VOXEL_ENCODERS.register_module
@VOXEL_ENCODERS.register_module()
class VoxelFeatureExtractorV3(nn.Module):
def __init__(self,
......@@ -152,7 +152,7 @@ class VoxelFeatureExtractorV3(nn.Module):
return points_mean.contiguous()
@VOXEL_ENCODERS.register_module
@VOXEL_ENCODERS.register_module()
class DynamicVFEV3(nn.Module):
def __init__(self,
......@@ -170,7 +170,7 @@ class DynamicVFEV3(nn.Module):
return features, features_coors
@VOXEL_ENCODERS.register_module
@VOXEL_ENCODERS.register_module()
class DynamicVFE(nn.Module):
def __init__(self,
......@@ -318,7 +318,7 @@ class DynamicVFE(nn.Module):
return voxel_feats, voxel_coors
@VOXEL_ENCODERS.register_module
@VOXEL_ENCODERS.register_module()
class HardVFE(nn.Module):
def __init__(self,
......
......@@ -13,7 +13,6 @@ __all__ = [
'roi_align',
'get_compiler_version',
'get_compiling_cuda_version',
'build_conv_layer',
'NaiveSyncBatchNorm1d',
'NaiveSyncBatchNorm2d',
'batched_nms',
......
import torch
import torch.distributed as dist
import torch.nn as nn
from mmcv.cnn import NORM_LAYERS
from torch.autograd.function import Function
from mmdet.ops.norm import norm_cfg
class AllReduce(Function):
......@@ -24,6 +23,7 @@ class AllReduce(Function):
return grad_output
@NORM_LAYERS.register_module('naiveSyncBN1d')
class NaiveSyncBatchNorm1d(nn.BatchNorm1d):
"""Syncronized Batch Normalization for 3D Tensors
......@@ -68,6 +68,7 @@ class NaiveSyncBatchNorm1d(nn.BatchNorm1d):
return input * scale + bias
@NORM_LAYERS.register_module('naiveSyncBN2d')
class NaiveSyncBatchNorm2d(nn.BatchNorm2d):
"""Syncronized Batch Normalization for 4D Tensors
......@@ -110,10 +111,3 @@ class NaiveSyncBatchNorm2d(nn.BatchNorm2d):
scale = scale.reshape(1, -1, 1, 1)
bias = bias.reshape(1, -1, 1, 1)
return input * scale + bias
norm_cfg.update({
'BN1d': ('bn', nn.BatchNorm1d),
'naiveSyncBN2d': ('bn', NaiveSyncBatchNorm2d),
'naiveSyncBN1d': ('bn', NaiveSyncBatchNorm1d),
})
from mmcv.cnn import build_norm_layer
from torch import nn
import mmdet3d.ops.spconv as spconv
from mmdet.models.backbones.resnet import BasicBlock, Bottleneck
from mmdet.ops import build_norm_layer
from mmdet.ops.conv import conv_cfg
conv_cfg.update({'SubMConv3d': spconv.SubMConv3d})
def conv3x3(in_planes, out_planes, stride=1, indice_key=None):
......
......@@ -16,6 +16,7 @@ import math
import numpy as np
import torch
from mmcv.cnn import CONV_LAYERS
from torch.nn import init
from torch.nn.parameter import Parameter
......@@ -205,6 +206,7 @@ class SparseConvolution(SparseModule):
return out_tensor
@CONV_LAYERS.register_module()
class SparseConv2d(SparseConvolution):
def __init__(self,
......@@ -230,6 +232,7 @@ class SparseConv2d(SparseConvolution):
indice_key=indice_key)
@CONV_LAYERS.register_module()
class SparseConv3d(SparseConvolution):
def __init__(self,
......@@ -255,6 +258,7 @@ class SparseConv3d(SparseConvolution):
indice_key=indice_key)
@CONV_LAYERS.register_module()
class SparseConv4d(SparseConvolution):
def __init__(self,
......@@ -280,6 +284,7 @@ class SparseConv4d(SparseConvolution):
indice_key=indice_key)
@CONV_LAYERS.register_module()
class SparseConvTranspose2d(SparseConvolution):
def __init__(self,
......@@ -306,6 +311,7 @@ class SparseConvTranspose2d(SparseConvolution):
indice_key=indice_key)
@CONV_LAYERS.register_module()
class SparseConvTranspose3d(SparseConvolution):
def __init__(self,
......@@ -332,6 +338,7 @@ class SparseConvTranspose3d(SparseConvolution):
indice_key=indice_key)
@CONV_LAYERS.register_module()
class SparseInverseConv2d(SparseConvolution):
def __init__(self,
......@@ -350,6 +357,7 @@ class SparseInverseConv2d(SparseConvolution):
indice_key=indice_key)
@CONV_LAYERS.register_module()
class SparseInverseConv3d(SparseConvolution):
def __init__(self,
......@@ -368,6 +376,7 @@ class SparseInverseConv3d(SparseConvolution):
indice_key=indice_key)
@CONV_LAYERS.register_module()
class SubMConv2d(SparseConvolution):
def __init__(self,
......@@ -394,6 +403,7 @@ class SubMConv2d(SparseConvolution):
indice_key=indice_key)
@CONV_LAYERS.register_module()
class SubMConv3d(SparseConvolution):
def __init__(self,
......@@ -420,6 +430,7 @@ class SubMConv3d(SparseConvolution):
indice_key=indice_key)
@CONV_LAYERS.register_module()
class SubMConv4d(SparseConvolution):
def __init__(self,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment