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
7193e54c
"...pytorch/rgcn/git@developer.sourcefind.cn:OpenDAS/dgl.git" did not exist on "668bd928fe75c3eed33597790197d72176d9b731"
Commit
7193e54c
authored
May 02, 2020
by
wuyuefeng
Browse files
SparseUNet
parent
66315452
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
18 deletions
+16
-18
mmdet3d/models/middle_encoders/__init__.py
mmdet3d/models/middle_encoders/__init__.py
+2
-2
mmdet3d/models/middle_encoders/sparse_unet.py
mmdet3d/models/middle_encoders/sparse_unet.py
+11
-13
tests/test_sparse_unet.py
tests/test_sparse_unet.py
+3
-3
No files found.
mmdet3d/models/middle_encoders/__init__.py
View file @
7193e54c
from
.pillar_scatter
import
PointPillarsScatter
from
.pillar_scatter
import
PointPillarsScatter
from
.sparse_encoder
import
SparseEncoder
from
.sparse_encoder
import
SparseEncoder
from
.sparse_unet
import
SparseU
n
et
from
.sparse_unet
import
SparseU
N
et
__all__
=
[
'PointPillarsScatter'
,
'SparseEncoder'
,
'SparseU
n
et'
]
__all__
=
[
'PointPillarsScatter'
,
'SparseEncoder'
,
'SparseU
N
et'
]
mmdet3d/models/middle_encoders/sparse_unet.py
View file @
7193e54c
...
@@ -8,7 +8,7 @@ from ..registry import MIDDLE_ENCODERS
...
@@ -8,7 +8,7 @@ from ..registry import MIDDLE_ENCODERS
@
MIDDLE_ENCODERS
.
register_module
@
MIDDLE_ENCODERS
.
register_module
class
SparseU
n
et
(
nn
.
Module
):
class
SparseU
N
et
(
nn
.
Module
):
def
__init__
(
self
,
def
__init__
(
self
,
in_channels
,
in_channels
,
...
@@ -24,7 +24,7 @@ class SparseUnet(nn.Module):
...
@@ -24,7 +24,7 @@ class SparseUnet(nn.Module):
decoder_channels
=
((
64
,
64
,
64
),
(
64
,
64
,
32
),
(
32
,
32
,
16
),
decoder_channels
=
((
64
,
64
,
64
),
(
64
,
64
,
32
),
(
32
,
32
,
16
),
(
16
,
16
,
16
)),
(
16
,
16
,
16
)),
decoder_paddings
=
((
1
,
0
),
(
1
,
0
),
(
0
,
0
),
(
0
,
1
))):
decoder_paddings
=
((
1
,
0
),
(
1
,
0
),
(
0
,
0
),
(
0
,
1
))):
"""SparseU
n
et for PartA^2
"""SparseU
N
et for PartA^2
See https://arxiv.org/abs/1907.03670 for more detials.
See https://arxiv.org/abs/1907.03670 for more detials.
...
@@ -99,7 +99,7 @@ class SparseUnet(nn.Module):
...
@@ -99,7 +99,7 @@ class SparseUnet(nn.Module):
)
)
def
forward
(
self
,
voxel_features
,
coors
,
batch_size
):
def
forward
(
self
,
voxel_features
,
coors
,
batch_size
):
"""Forward of SparseU
n
et
"""Forward of SparseU
N
et
Args:
Args:
voxel_features (torch.float32): shape [N, C]
voxel_features (torch.float32): shape [N, C]
...
@@ -128,8 +128,6 @@ class SparseUnet(nn.Module):
...
@@ -128,8 +128,6 @@ class SparseUnet(nn.Module):
N
,
C
,
D
,
H
,
W
=
spatial_features
.
shape
N
,
C
,
D
,
H
,
W
=
spatial_features
.
shape
spatial_features
=
spatial_features
.
view
(
N
,
C
*
D
,
H
,
W
)
spatial_features
=
spatial_features
.
view
(
N
,
C
*
D
,
H
,
W
)
ret
=
{
'spatial_features'
:
spatial_features
}
# for segmentation head, with output shape:
# for segmentation head, with output shape:
# [400, 352, 11] <- [200, 176, 5]
# [400, 352, 11] <- [200, 176, 5]
# [800, 704, 21] <- [400, 352, 11]
# [800, 704, 21] <- [400, 352, 11]
...
@@ -149,7 +147,8 @@ class SparseUnet(nn.Module):
...
@@ -149,7 +147,8 @@ class SparseUnet(nn.Module):
seg_features
=
decode_features
[
-
1
].
features
seg_features
=
decode_features
[
-
1
].
features
ret
.
update
({
'seg_features'
:
seg_features
})
ret
=
dict
(
spatial_features
=
spatial_features
,
seg_features
=
seg_features
)
return
ret
return
ret
...
@@ -159,7 +158,7 @@ class SparseUnet(nn.Module):
...
@@ -159,7 +158,7 @@ class SparseUnet(nn.Module):
Args:
Args:
x_lateral (SparseConvTensor): lateral tensor
x_lateral (SparseConvTensor): lateral tensor
x_bottom (SparseConvTensor):
tensor
from bottom layer
x_bottom (SparseConvTensor):
feature
from bottom layer
lateral_layer (SparseBasicBlock): convolution for lateral tensor
lateral_layer (SparseBasicBlock): convolution for lateral tensor
merge_layer (SparseSequential): convolution for merging features
merge_layer (SparseSequential): convolution for merging features
upsample_layer (SparseSequential): convolution for upsampling
upsample_layer (SparseSequential): convolution for upsampling
...
@@ -167,12 +166,11 @@ class SparseUnet(nn.Module):
...
@@ -167,12 +166,11 @@ class SparseUnet(nn.Module):
Returns:
Returns:
SparseConvTensor: upsampled feature
SparseConvTensor: upsampled feature
"""
"""
x_trans
=
lateral_layer
(
x_lateral
)
x
=
lateral_layer
(
x_lateral
)
x
=
x_trans
x
.
features
=
torch
.
cat
((
x_bottom
.
features
,
x
.
features
),
dim
=
1
)
x
.
features
=
torch
.
cat
((
x_bottom
.
features
,
x_trans
.
features
),
dim
=
1
)
x_merge
=
merge_layer
(
x
)
x_m
=
merge_layer
(
x
)
x
=
self
.
reduce_channel
(
x
,
x_merge
.
features
.
shape
[
1
])
x
=
self
.
reduce_channel
(
x
,
x_m
.
features
.
shape
[
1
])
x
.
features
=
x_merge
.
features
+
x
.
features
x
.
features
=
x_m
.
features
+
x
.
features
x
=
upsample_layer
(
x
)
x
=
upsample_layer
(
x
)
return
x
return
x
...
...
tests/test_sparse_unet.py
View file @
7193e54c
...
@@ -4,9 +4,9 @@ import mmdet3d.ops.spconv as spconv
...
@@ -4,9 +4,9 @@ import mmdet3d.ops.spconv as spconv
from
mmdet3d.ops
import
SparseBasicBlock
,
SparseBasicBlockV0
from
mmdet3d.ops
import
SparseBasicBlock
,
SparseBasicBlockV0
def
test_SparseU
n
et
():
def
test_SparseU
N
et
():
from
mmdet3d.models.middle_encoders.sparse_unet
import
SparseU
n
et
from
mmdet3d.models.middle_encoders.sparse_unet
import
SparseU
N
et
self
=
SparseU
n
et
(
self
=
SparseU
N
et
(
in_channels
=
4
,
output_shape
=
[
41
,
1600
,
1408
],
pre_act
=
False
)
in_channels
=
4
,
output_shape
=
[
41
,
1600
,
1408
],
pre_act
=
False
)
# test encoder layers
# test encoder layers
...
...
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