Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
mmdetection3d
Commits
323bad26
Commit
323bad26
authored
May 12, 2020
by
zhangwenwei
Browse files
Merge branch 'refacor-sec-backbone' into 'master'
Refactor SECOND Backbone See merge request open-mmlab/mmdet.3d!26
parents
868c5fab
945edf21
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
41 additions
and
48 deletions
+41
-48
.gitlab-ci.yml
.gitlab-ci.yml
+1
-1
configs/kitti/dv_mvx-v2_second_secfpn_fpn-fusion_adamw_2x8_80e_kitti-3d-3class.py
...second_secfpn_fpn-fusion_adamw_2x8_80e_kitti-3d-3class.py
+1
-1
configs/kitti/dv_pointpillars_secfpn_6x8_160e_kitti-3d-car.py
...igs/kitti/dv_pointpillars_secfpn_6x8_160e_kitti-3d-car.py
+1
-1
configs/kitti/dv_second_secfpn_2x8_cosine_80e_kitti-3d-3class.py
.../kitti/dv_second_secfpn_2x8_cosine_80e_kitti-3d-3class.py
+1
-1
configs/kitti/dv_second_secfpn_6x8_80e_kitti-3d-car.py
configs/kitti/dv_second_secfpn_6x8_80e_kitti-3d-car.py
+1
-1
configs/kitti/hv_PartA2_secfpn_4x8_cosine_80e_kitti-3d-3class.py
.../kitti/hv_PartA2_secfpn_4x8_cosine_80e_kitti-3d-3class.py
+1
-1
configs/kitti/hv_pointpillars_secfpn_6x8_160e_kitti-3d-car.py
...igs/kitti/hv_pointpillars_secfpn_6x8_160e_kitti-3d-car.py
+1
-1
configs/kitti/hv_second_secfpn_6x8_80e_kitti-3d-car.py
configs/kitti/hv_second_secfpn_6x8_80e_kitti-3d-car.py
+1
-1
configs/nus/hv_pointpillars_secfpn_sbn-all_4x8_2x_nus-3d.py
configs/nus/hv_pointpillars_secfpn_sbn-all_4x8_2x_nus-3d.py
+1
-1
mmdet3d/models/backbones/second.py
mmdet3d/models/backbones/second.py
+32
-39
No files found.
.gitlab-ci.yml
View file @
323bad26
...
@@ -16,7 +16,7 @@ before_script:
...
@@ -16,7 +16,7 @@ before_script:
.linting_template
:
&linting_template_def
.linting_template
:
&linting_template_def
stage
:
linting
stage
:
linting
script
:
script
:
-
pip install flake8 yapf isort
-
pip install flake8
==3.7.9
yapf isort
-
flake8 .
-
flake8 .
-
isort -rc --check-only --diff mmdet3d/ tools/ tests/
-
isort -rc --check-only --diff mmdet3d/ tools/ tests/
-
yapf -r -d mmdet3d/ tools/ tests/ configs/
-
yapf -r -d mmdet3d/ tools/ tests/ configs/
...
...
configs/kitti/dv_mvx-v2_second_secfpn_fpn-fusion_adamw_2x8_80e_kitti-3d-3class.py
View file @
323bad26
...
@@ -57,7 +57,7 @@ model = dict(
...
@@ -57,7 +57,7 @@ model = dict(
in_channels
=
256
,
in_channels
=
256
,
layer_nums
=
[
5
,
5
],
layer_nums
=
[
5
,
5
],
layer_strides
=
[
1
,
2
],
layer_strides
=
[
1
,
2
],
num_filter
s
=
[
128
,
256
],
out_channel
s
=
[
128
,
256
],
),
),
pts_neck
=
dict
(
pts_neck
=
dict
(
type
=
'SECONDFPN'
,
type
=
'SECONDFPN'
,
...
...
configs/kitti/dv_pointpillars_secfpn_6x8_160e_kitti-3d-car.py
View file @
323bad26
...
@@ -28,7 +28,7 @@ model = dict(
...
@@ -28,7 +28,7 @@ model = dict(
in_channels
=
64
,
in_channels
=
64
,
layer_nums
=
[
3
,
5
,
5
],
layer_nums
=
[
3
,
5
,
5
],
layer_strides
=
[
2
,
2
,
2
],
layer_strides
=
[
2
,
2
,
2
],
num_filter
s
=
[
64
,
128
,
256
],
out_channel
s
=
[
64
,
128
,
256
],
),
),
neck
=
dict
(
neck
=
dict
(
type
=
'SECONDFPN'
,
type
=
'SECONDFPN'
,
...
...
configs/kitti/dv_second_secfpn_2x8_cosine_80e_kitti-3d-3class.py
View file @
323bad26
...
@@ -26,7 +26,7 @@ model = dict(
...
@@ -26,7 +26,7 @@ model = dict(
in_channels
=
256
,
in_channels
=
256
,
layer_nums
=
[
5
,
5
],
layer_nums
=
[
5
,
5
],
layer_strides
=
[
1
,
2
],
layer_strides
=
[
1
,
2
],
num_filter
s
=
[
128
,
256
],
out_channel
s
=
[
128
,
256
],
),
),
neck
=
dict
(
neck
=
dict
(
type
=
'SECONDFPN'
,
type
=
'SECONDFPN'
,
...
...
configs/kitti/dv_second_secfpn_6x8_80e_kitti-3d-car.py
View file @
323bad26
...
@@ -26,7 +26,7 @@ model = dict(
...
@@ -26,7 +26,7 @@ model = dict(
in_channels
=
256
,
in_channels
=
256
,
layer_nums
=
[
5
,
5
],
layer_nums
=
[
5
,
5
],
layer_strides
=
[
1
,
2
],
layer_strides
=
[
1
,
2
],
num_filter
s
=
[
128
,
256
],
out_channel
s
=
[
128
,
256
],
),
),
neck
=
dict
(
neck
=
dict
(
type
=
'SECONDFPN'
,
type
=
'SECONDFPN'
,
...
...
configs/kitti/hv_PartA2_secfpn_4x8_cosine_80e_kitti-3d-3class.py
View file @
323bad26
...
@@ -22,7 +22,7 @@ model = dict(
...
@@ -22,7 +22,7 @@ model = dict(
in_channels
=
256
,
in_channels
=
256
,
layer_nums
=
[
5
,
5
],
layer_nums
=
[
5
,
5
],
layer_strides
=
[
1
,
2
],
layer_strides
=
[
1
,
2
],
num_filter
s
=
[
128
,
256
]),
out_channel
s
=
[
128
,
256
]),
neck
=
dict
(
neck
=
dict
(
type
=
'SECONDFPN'
,
type
=
'SECONDFPN'
,
in_channels
=
[
128
,
256
],
in_channels
=
[
128
,
256
],
...
...
configs/kitti/hv_pointpillars_secfpn_6x8_160e_kitti-3d-car.py
View file @
323bad26
...
@@ -27,7 +27,7 @@ model = dict(
...
@@ -27,7 +27,7 @@ model = dict(
in_channels
=
64
,
in_channels
=
64
,
layer_nums
=
[
3
,
5
,
5
],
layer_nums
=
[
3
,
5
,
5
],
layer_strides
=
[
2
,
2
,
2
],
layer_strides
=
[
2
,
2
,
2
],
num_filter
s
=
[
64
,
128
,
256
],
out_channel
s
=
[
64
,
128
,
256
],
),
),
neck
=
dict
(
neck
=
dict
(
type
=
'SECONDFPN'
,
type
=
'SECONDFPN'
,
...
...
configs/kitti/hv_second_secfpn_6x8_80e_kitti-3d-car.py
View file @
323bad26
...
@@ -26,7 +26,7 @@ model = dict(
...
@@ -26,7 +26,7 @@ model = dict(
in_channels
=
256
,
in_channels
=
256
,
layer_nums
=
[
5
,
5
],
layer_nums
=
[
5
,
5
],
layer_strides
=
[
1
,
2
],
layer_strides
=
[
1
,
2
],
num_filter
s
=
[
128
,
256
],
out_channel
s
=
[
128
,
256
],
),
),
neck
=
dict
(
neck
=
dict
(
type
=
'SECONDFPN'
,
type
=
'SECONDFPN'
,
...
...
configs/nus/hv_pointpillars_secfpn_sbn-all_4x8_2x_nus-3d.py
View file @
323bad26
...
@@ -34,7 +34,7 @@ model = dict(
...
@@ -34,7 +34,7 @@ model = dict(
norm_cfg
=
dict
(
type
=
'naiveSyncBN2d'
,
eps
=
1e-3
,
momentum
=
0.01
),
norm_cfg
=
dict
(
type
=
'naiveSyncBN2d'
,
eps
=
1e-3
,
momentum
=
0.01
),
layer_nums
=
[
3
,
5
,
5
],
layer_nums
=
[
3
,
5
,
5
],
layer_strides
=
[
2
,
2
,
2
],
layer_strides
=
[
2
,
2
,
2
],
num_filter
s
=
[
64
,
128
,
256
],
out_channel
s
=
[
64
,
128
,
256
],
),
),
pts_neck
=
dict
(
pts_neck
=
dict
(
type
=
'SECONDFPN'
,
type
=
'SECONDFPN'
,
...
...
mmdet3d/models/backbones/second.py
View file @
323bad26
from
functools
import
partial
import
torch.nn
as
nn
import
torch.nn
as
nn
from
mmcv.cnn
import
build_norm_layer
from
mmcv.cnn
import
build_conv_layer
,
build_norm_layer
from
mmcv.runner
import
load_checkpoint
from
mmcv.runner
import
load_checkpoint
from
mmdet.models
import
BACKBONES
from
mmdet.models
import
BACKBONES
class
Empty
(
nn
.
Module
):
def
__init__
(
self
,
*
args
,
**
kwargs
):
super
(
Empty
,
self
).
__init__
()
def
forward
(
self
,
*
args
,
**
kwargs
):
if
len
(
args
)
==
1
:
return
args
[
0
]
elif
len
(
args
)
==
0
:
return
None
return
args
@
BACKBONES
.
register_module
()
@
BACKBONES
.
register_module
()
class
SECOND
(
nn
.
Module
):
class
SECOND
(
nn
.
Module
):
"""Compare with RPN, RPNV2 support arbitrary number of stage.
"""Backbone network for SECOND/PointPillars/PartA2/MVXNet
Args:
in_channels (int): Input channels
out_channels (list[int]): Output channels for multi-scale feature maps
layer_nums (list[int]): Number of layers in each stage
layer_strides (list[int]): Strides of each stage
norm_cfg (dict): Config dict of normalization layers
conv_cfg (dict): Config dict of convolutional layers
"""
"""
def
__init__
(
self
,
def
__init__
(
self
,
in_channels
=
128
,
in_channels
=
128
,
out_channels
=
[
128
,
128
,
256
],
layer_nums
=
[
3
,
5
,
5
],
layer_nums
=
[
3
,
5
,
5
],
layer_strides
=
[
2
,
2
,
2
],
layer_strides
=
[
2
,
2
,
2
],
n
um_filters
=
[
128
,
128
,
256
]
,
n
orm_cfg
=
dict
(
type
=
'BN'
,
eps
=
1e-3
,
momentum
=
0.01
)
,
norm
_cfg
=
dict
(
type
=
'
BN'
,
eps
=
1e-3
,
momentum
=
0.01
)):
conv
_cfg
=
dict
(
type
=
'
Conv2d'
,
bias
=
False
)):
super
(
SECOND
,
self
).
__init__
()
super
(
SECOND
,
self
).
__init__
()
assert
len
(
layer_strides
)
==
len
(
layer_nums
)
assert
len
(
layer_strides
)
==
len
(
layer_nums
)
assert
len
(
num_filters
)
==
len
(
layer_nums
)
assert
len
(
out_channels
)
==
len
(
layer_nums
)
if
norm_cfg
is
not
None
:
Conv2d
=
partial
(
nn
.
Conv2d
,
bias
=
False
)
else
:
Conv2d
=
partial
(
nn
.
Conv2d
,
bias
=
True
)
in_filters
=
[
in_channels
,
*
num_filter
s
[:
-
1
]]
in_filters
=
[
in_channels
,
*
out_channel
s
[:
-
1
]]
# note that when stride > 1, conv2d with same padding isn't
# note that when stride > 1, conv2d with same padding isn't
# equal to pad-conv2d. we should use pad-conv2d.
# equal to pad-conv2d. we should use pad-conv2d.
blocks
=
[]
blocks
=
[]
for
i
,
layer_num
in
enumerate
(
layer_nums
):
for
i
,
layer_num
in
enumerate
(
layer_nums
):
norm_layer
=
(
build_norm_layer
(
norm_cfg
,
num_filters
[
i
])[
1
]
if
norm_cfg
is
not
None
else
Empty
)
block
=
[
block
=
[
nn
.
ZeroPad2d
(
1
),
build_conv_layer
(
Conv2d
(
conv_cfg
,
in_filters
[
i
],
num_filters
[
i
],
3
,
stride
=
layer_strides
[
i
]),
in_filters
[
i
],
norm_layer
,
out_channels
[
i
],
3
,
stride
=
layer_strides
[
i
],
padding
=
1
),
build_norm_layer
(
norm_cfg
,
out_channels
[
i
])[
1
],
nn
.
ReLU
(
inplace
=
True
),
nn
.
ReLU
(
inplace
=
True
),
]
]
for
j
in
range
(
layer_num
):
for
j
in
range
(
layer_num
):
norm_layer
=
(
build_norm_layer
(
norm_cfg
,
num_filters
[
i
])[
1
]
if
norm_cfg
is
not
None
else
Empty
)
block
.
append
(
block
.
append
(
Conv2d
(
num_filters
[
i
],
num_filters
[
i
],
3
,
padding
=
1
))
build_conv_layer
(
block
.
append
(
norm_layer
)
conv_cfg
,
out_channels
[
i
],
out_channels
[
i
],
3
,
padding
=
1
))
block
.
append
(
build_norm_layer
(
norm_cfg
,
out_channels
[
i
])[
1
])
block
.
append
(
nn
.
ReLU
(
inplace
=
True
))
block
.
append
(
nn
.
ReLU
(
inplace
=
True
))
block
=
nn
.
Sequential
(
*
block
)
block
=
nn
.
Sequential
(
*
block
)
...
@@ -71,6 +62,8 @@ class SECOND(nn.Module):
...
@@ -71,6 +62,8 @@ class SECOND(nn.Module):
self
.
blocks
=
nn
.
ModuleList
(
blocks
)
self
.
blocks
=
nn
.
ModuleList
(
blocks
)
def
init_weights
(
self
,
pretrained
=
None
):
def
init_weights
(
self
,
pretrained
=
None
):
# Do not initialize the conv layers
# to follow the original implementation
if
isinstance
(
pretrained
,
str
):
if
isinstance
(
pretrained
,
str
):
from
mmdet3d.utils
import
get_root_logger
from
mmdet3d.utils
import
get_root_logger
logger
=
get_root_logger
()
logger
=
get_root_logger
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment