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
76e351a7
Unverified
Commit
76e351a7
authored
May 01, 2022
by
Wenwei Zhang
Committed by
GitHub
May 01, 2022
Browse files
Release v1.0.0rc2
parents
5111eda8
4422eaab
Changes
137
Show whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
92 additions
and
61 deletions
+92
-61
mmdet3d/models/builder.py
mmdet3d/models/builder.py
+48
-11
mmdet3d/models/decode_heads/dgcnn_head.py
mmdet3d/models/decode_heads/dgcnn_head.py
+1
-1
mmdet3d/models/decode_heads/paconv_head.py
mmdet3d/models/decode_heads/paconv_head.py
+1
-1
mmdet3d/models/decode_heads/pointnet2_head.py
mmdet3d/models/decode_heads/pointnet2_head.py
+1
-1
mmdet3d/models/dense_heads/anchor3d_head.py
mmdet3d/models/dense_heads/anchor3d_head.py
+1
-2
mmdet3d/models/dense_heads/anchor_free_mono3d_head.py
mmdet3d/models/dense_heads/anchor_free_mono3d_head.py
+1
-1
mmdet3d/models/dense_heads/base_conv_bbox_head.py
mmdet3d/models/dense_heads/base_conv_bbox_head.py
+1
-1
mmdet3d/models/dense_heads/centerpoint_head.py
mmdet3d/models/dense_heads/centerpoint_head.py
+5
-5
mmdet3d/models/dense_heads/fcos_mono3d_head.py
mmdet3d/models/dense_heads/fcos_mono3d_head.py
+1
-1
mmdet3d/models/dense_heads/free_anchor3d_head.py
mmdet3d/models/dense_heads/free_anchor3d_head.py
+1
-1
mmdet3d/models/dense_heads/groupfree3d_head.py
mmdet3d/models/dense_heads/groupfree3d_head.py
+1
-2
mmdet3d/models/dense_heads/monoflex_head.py
mmdet3d/models/dense_heads/monoflex_head.py
+1
-1
mmdet3d/models/dense_heads/parta2_rpn_head.py
mmdet3d/models/dense_heads/parta2_rpn_head.py
+4
-8
mmdet3d/models/dense_heads/pgd_head.py
mmdet3d/models/dense_heads/pgd_head.py
+1
-1
mmdet3d/models/dense_heads/point_rpn_head.py
mmdet3d/models/dense_heads/point_rpn_head.py
+19
-16
mmdet3d/models/dense_heads/shape_aware_head.py
mmdet3d/models/dense_heads/shape_aware_head.py
+1
-2
mmdet3d/models/dense_heads/smoke_mono3d_head.py
mmdet3d/models/dense_heads/smoke_mono3d_head.py
+1
-1
mmdet3d/models/dense_heads/ssd_3d_head.py
mmdet3d/models/dense_heads/ssd_3d_head.py
+1
-2
mmdet3d/models/dense_heads/vote_head.py
mmdet3d/models/dense_heads/vote_head.py
+1
-2
mmdet3d/models/detectors/centerpoint.py
mmdet3d/models/detectors/centerpoint.py
+1
-1
No files found.
mmdet3d/models/builder.py
View file @
76e351a7
...
@@ -4,45 +4,78 @@ import warnings
...
@@ -4,45 +4,78 @@ import warnings
from
mmcv.cnn
import
MODELS
as
MMCV_MODELS
from
mmcv.cnn
import
MODELS
as
MMCV_MODELS
from
mmcv.utils
import
Registry
from
mmcv.utils
import
Registry
from
mmdet.models.builder
import
(
BACKBONES
,
DETECTORS
,
HEADS
,
LOSSES
,
NECKS
,
from
mmdet.models.builder
import
BACKBONES
as
MMDET_BACKBONES
ROI_EXTRACTORS
,
SHARED_HEADS
)
from
mmdet.models.builder
import
DETECTORS
as
MMDET_DETECTORS
from
mmseg.models.builder
import
SEGMENTORS
from
mmdet.models.builder
import
HEADS
as
MMDET_HEADS
from
mmdet.models.builder
import
LOSSES
as
MMDET_LOSSES
from
mmdet.models.builder
import
NECKS
as
MMDET_NECKS
from
mmdet.models.builder
import
ROI_EXTRACTORS
as
MMDET_ROI_EXTRACTORS
from
mmdet.models.builder
import
SHARED_HEADS
as
MMDET_SHARED_HEADS
from
mmseg.models.builder
import
LOSSES
as
MMSEG_LOSSES
MODELS
=
Registry
(
'models'
,
parent
=
MMCV_MODELS
)
MODELS
=
Registry
(
'models'
,
parent
=
MMCV_MODELS
)
BACKBONES
=
MODELS
NECKS
=
MODELS
ROI_EXTRACTORS
=
MODELS
SHARED_HEADS
=
MODELS
HEADS
=
MODELS
LOSSES
=
MODELS
DETECTORS
=
MODELS
VOXEL_ENCODERS
=
MODELS
VOXEL_ENCODERS
=
MODELS
MIDDLE_ENCODERS
=
MODELS
MIDDLE_ENCODERS
=
MODELS
FUSION_LAYERS
=
MODELS
FUSION_LAYERS
=
MODELS
SEGMENTORS
=
MODELS
def
build_backbone
(
cfg
):
def
build_backbone
(
cfg
):
"""Build backbone."""
"""Build backbone."""
if
cfg
[
'type'
]
in
BACKBONES
.
_module_dict
.
keys
():
return
BACKBONES
.
build
(
cfg
)
return
BACKBONES
.
build
(
cfg
)
else
:
return
MMDET_BACKBONES
.
build
(
cfg
)
def
build_neck
(
cfg
):
def
build_neck
(
cfg
):
"""Build neck."""
"""Build neck."""
if
cfg
[
'type'
]
in
NECKS
.
_module_dict
.
keys
():
return
NECKS
.
build
(
cfg
)
return
NECKS
.
build
(
cfg
)
else
:
return
MMDET_NECKS
.
build
(
cfg
)
def
build_roi_extractor
(
cfg
):
def
build_roi_extractor
(
cfg
):
"""Build RoI feature extractor."""
"""Build RoI feature extractor."""
if
cfg
[
'type'
]
in
NECKS
.
_module_dict
.
keys
():
return
ROI_EXTRACTORS
.
build
(
cfg
)
return
ROI_EXTRACTORS
.
build
(
cfg
)
else
:
return
MMDET_ROI_EXTRACTORS
.
build
(
cfg
)
def
build_shared_head
(
cfg
):
def
build_shared_head
(
cfg
):
"""Build shared head of detector."""
"""Build shared head of detector."""
if
cfg
[
'type'
]
in
SHARED_HEADS
.
_module_dict
.
keys
():
return
SHARED_HEADS
.
build
(
cfg
)
return
SHARED_HEADS
.
build
(
cfg
)
else
:
return
MMDET_SHARED_HEADS
.
build
(
cfg
)
def
build_head
(
cfg
):
def
build_head
(
cfg
):
"""Build head."""
"""Build head."""
if
cfg
[
'type'
]
in
HEADS
.
_module_dict
.
keys
():
return
HEADS
.
build
(
cfg
)
return
HEADS
.
build
(
cfg
)
else
:
return
MMDET_HEADS
.
build
(
cfg
)
def
build_loss
(
cfg
):
def
build_loss
(
cfg
):
"""Build loss function."""
"""Build loss function."""
if
cfg
[
'type'
]
in
LOSSES
.
_module_dict
.
keys
():
return
LOSSES
.
build
(
cfg
)
return
LOSSES
.
build
(
cfg
)
elif
cfg
[
'type'
]
in
MMDET_LOSSES
.
_module_dict
.
keys
():
return
MMDET_LOSSES
.
build
(
cfg
)
else
:
return
MMSEG_LOSSES
.
build
(
cfg
)
def
build_detector
(
cfg
,
train_cfg
=
None
,
test_cfg
=
None
):
def
build_detector
(
cfg
,
train_cfg
=
None
,
test_cfg
=
None
):
...
@@ -55,8 +88,12 @@ def build_detector(cfg, train_cfg=None, test_cfg=None):
...
@@ -55,8 +88,12 @@ def build_detector(cfg, train_cfg=None, test_cfg=None):
'train_cfg specified in both outer field and model field '
'train_cfg specified in both outer field and model field '
assert
cfg
.
get
(
'test_cfg'
)
is
None
or
test_cfg
is
None
,
\
assert
cfg
.
get
(
'test_cfg'
)
is
None
or
test_cfg
is
None
,
\
'test_cfg specified in both outer field and model field '
'test_cfg specified in both outer field and model field '
if
cfg
[
'type'
]
in
DETECTORS
.
_module_dict
.
keys
():
return
DETECTORS
.
build
(
return
DETECTORS
.
build
(
cfg
,
default_args
=
dict
(
train_cfg
=
train_cfg
,
test_cfg
=
test_cfg
))
cfg
,
default_args
=
dict
(
train_cfg
=
train_cfg
,
test_cfg
=
test_cfg
))
else
:
return
MMDET_DETECTORS
.
build
(
cfg
,
default_args
=
dict
(
train_cfg
=
train_cfg
,
test_cfg
=
test_cfg
))
def
build_segmentor
(
cfg
,
train_cfg
=
None
,
test_cfg
=
None
):
def
build_segmentor
(
cfg
,
train_cfg
=
None
,
test_cfg
=
None
):
...
...
mmdet3d/models/decode_heads/dgcnn_head.py
View file @
76e351a7
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
from
mmcv.cnn.bricks
import
ConvModule
from
mmcv.cnn.bricks
import
ConvModule
from
mmdet3d.ops
import
DGCNNFPModule
from
mmdet3d.ops
import
DGCNNFPModule
from
mmdet.models
import
HEADS
from
..builder
import
HEADS
from
.decode_head
import
Base3DDecodeHead
from
.decode_head
import
Base3DDecodeHead
...
...
mmdet3d/models/decode_heads/paconv_head.py
View file @
76e351a7
# Copyright (c) OpenMMLab. All rights reserved.
# Copyright (c) OpenMMLab. All rights reserved.
from
mmcv.cnn.bricks
import
ConvModule
from
mmcv.cnn.bricks
import
ConvModule
from
mmdet.models
import
HEADS
from
..builder
import
HEADS
from
.pointnet2_head
import
PointNet2Head
from
.pointnet2_head
import
PointNet2Head
...
...
mmdet3d/models/decode_heads/pointnet2_head.py
View file @
76e351a7
...
@@ -3,7 +3,7 @@ from mmcv.cnn.bricks import ConvModule
...
@@ -3,7 +3,7 @@ from mmcv.cnn.bricks import ConvModule
from
torch
import
nn
as
nn
from
torch
import
nn
as
nn
from
mmdet3d.ops
import
PointFPModule
from
mmdet3d.ops
import
PointFPModule
from
mmdet.models
import
HEADS
from
..builder
import
HEADS
from
.decode_head
import
Base3DDecodeHead
from
.decode_head
import
Base3DDecodeHead
...
...
mmdet3d/models/dense_heads/anchor3d_head.py
View file @
76e351a7
...
@@ -8,8 +8,7 @@ from mmdet3d.core import (PseudoSampler, box3d_multiclass_nms, limit_period,
...
@@ -8,8 +8,7 @@ from mmdet3d.core import (PseudoSampler, box3d_multiclass_nms, limit_period,
xywhr2xyxyr
)
xywhr2xyxyr
)
from
mmdet.core
import
(
build_assigner
,
build_bbox_coder
,
from
mmdet.core
import
(
build_assigner
,
build_bbox_coder
,
build_prior_generator
,
build_sampler
,
multi_apply
)
build_prior_generator
,
build_sampler
,
multi_apply
)
from
mmdet.models
import
HEADS
from
..builder
import
HEADS
,
build_loss
from
..builder
import
build_loss
from
.train_mixins
import
AnchorTrainMixin
from
.train_mixins
import
AnchorTrainMixin
...
...
mmdet3d/models/dense_heads/anchor_free_mono3d_head.py
View file @
76e351a7
...
@@ -7,7 +7,7 @@ from mmcv.runner import force_fp32
...
@@ -7,7 +7,7 @@ from mmcv.runner import force_fp32
from
torch
import
nn
as
nn
from
torch
import
nn
as
nn
from
mmdet.core
import
multi_apply
from
mmdet.core
import
multi_apply
from
mmdet.models
.builder
import
HEADS
,
build_loss
from
.
.builder
import
HEADS
,
build_loss
from
.base_mono3d_dense_head
import
BaseMono3DDenseHead
from
.base_mono3d_dense_head
import
BaseMono3DDenseHead
...
...
mmdet3d/models/dense_heads/base_conv_bbox_head.py
View file @
76e351a7
...
@@ -4,7 +4,7 @@ from mmcv.cnn.bricks import build_conv_layer
...
@@ -4,7 +4,7 @@ from mmcv.cnn.bricks import build_conv_layer
from
mmcv.runner
import
BaseModule
from
mmcv.runner
import
BaseModule
from
torch
import
nn
as
nn
from
torch
import
nn
as
nn
from
mmdet.models
.builder
import
HEADS
from
.
.builder
import
HEADS
@
HEADS
.
register_module
()
@
HEADS
.
register_module
()
...
...
mmdet3d/models/dense_heads/centerpoint_head.py
View file @
76e351a7
...
@@ -3,16 +3,16 @@ import copy
...
@@ -3,16 +3,16 @@ import copy
import
torch
import
torch
from
mmcv.cnn
import
ConvModule
,
build_conv_layer
from
mmcv.cnn
import
ConvModule
,
build_conv_layer
from
mmcv.ops
import
nms_bev
as
nms_gpu
from
mmcv.runner
import
BaseModule
,
force_fp32
from
mmcv.runner
import
BaseModule
,
force_fp32
from
torch
import
nn
from
torch
import
nn
from
mmdet3d.core
import
(
circle_nms
,
draw_heatmap_gaussian
,
gaussian_radius
,
from
mmdet3d.core
import
(
circle_nms
,
draw_heatmap_gaussian
,
gaussian_radius
,
xywhr2xyxyr
)
xywhr2xyxyr
)
from
mmdet3d.core.post_processing
import
nms_bev
from
mmdet3d.models
import
builder
from
mmdet3d.models
import
builder
from
mmdet3d.models.builder
import
HEADS
,
build_loss
from
mmdet3d.models.utils
import
clip_sigmoid
from
mmdet3d.models.utils
import
clip_sigmoid
from
mmdet.core
import
build_bbox_coder
,
multi_apply
from
mmdet.core
import
build_bbox_coder
,
multi_apply
from
..builder
import
HEADS
,
build_loss
@
HEADS
.
register_module
()
@
HEADS
.
register_module
()
...
@@ -747,9 +747,9 @@ class CenterHead(BaseModule):
...
@@ -747,9 +747,9 @@ class CenterHead(BaseModule):
for
i
,
(
box_preds
,
cls_preds
,
cls_labels
)
in
enumerate
(
for
i
,
(
box_preds
,
cls_preds
,
cls_labels
)
in
enumerate
(
zip
(
batch_reg_preds
,
batch_cls_preds
,
batch_cls_labels
)):
zip
(
batch_reg_preds
,
batch_cls_preds
,
batch_cls_labels
)):
# Apply NMS in birdeye view
# Apply NMS in bird
eye view
# get highest score per prediction, th
a
n apply nms
# get
the
highest score per prediction, th
e
n apply nms
# to remove overlapped box.
# to remove overlapped box.
if
num_class_with_bg
==
1
:
if
num_class_with_bg
==
1
:
top_scores
=
cls_preds
.
squeeze
(
-
1
)
top_scores
=
cls_preds
.
squeeze
(
-
1
)
...
@@ -778,7 +778,7 @@ class CenterHead(BaseModule):
...
@@ -778,7 +778,7 @@ class CenterHead(BaseModule):
box_preds
[:,
:],
self
.
bbox_coder
.
code_size
).
bev
)
box_preds
[:,
:],
self
.
bbox_coder
.
code_size
).
bev
)
# the nms in 3d detection just remove overlap boxes.
# the nms in 3d detection just remove overlap boxes.
selected
=
nms_
gpu
(
selected
=
nms_
bev
(
boxes_for_nms
,
boxes_for_nms
,
top_scores
,
top_scores
,
thresh
=
self
.
test_cfg
[
'nms_thr'
],
thresh
=
self
.
test_cfg
[
'nms_thr'
],
...
...
mmdet3d/models/dense_heads/fcos_mono3d_head.py
View file @
76e351a7
...
@@ -11,7 +11,7 @@ from mmdet3d.core import (box3d_multiclass_nms, limit_period, points_img2cam,
...
@@ -11,7 +11,7 @@ from mmdet3d.core import (box3d_multiclass_nms, limit_period, points_img2cam,
xywhr2xyxyr
)
xywhr2xyxyr
)
from
mmdet.core
import
multi_apply
from
mmdet.core
import
multi_apply
from
mmdet.core.bbox.builder
import
build_bbox_coder
from
mmdet.core.bbox.builder
import
build_bbox_coder
from
mmdet.models
.builder
import
HEADS
,
build_loss
from
.
.builder
import
HEADS
,
build_loss
from
.anchor_free_mono3d_head
import
AnchorFreeMono3DHead
from
.anchor_free_mono3d_head
import
AnchorFreeMono3DHead
INF
=
1e8
INF
=
1e8
...
...
mmdet3d/models/dense_heads/free_anchor3d_head.py
View file @
76e351a7
...
@@ -4,7 +4,7 @@ from mmcv.runner import force_fp32
...
@@ -4,7 +4,7 @@ from mmcv.runner import force_fp32
from
torch.nn
import
functional
as
F
from
torch.nn
import
functional
as
F
from
mmdet3d.core.bbox
import
bbox_overlaps_nearest_3d
from
mmdet3d.core.bbox
import
bbox_overlaps_nearest_3d
from
mmdet.models
import
HEADS
from
..builder
import
HEADS
from
.anchor3d_head
import
Anchor3DHead
from
.anchor3d_head
import
Anchor3DHead
from
.train_mixins
import
get_direction_target
from
.train_mixins
import
get_direction_target
...
...
mmdet3d/models/dense_heads/groupfree3d_head.py
View file @
76e351a7
...
@@ -14,9 +14,8 @@ from torch import nn as nn
...
@@ -14,9 +14,8 @@ from torch import nn as nn
from
torch.nn
import
functional
as
F
from
torch.nn
import
functional
as
F
from
mmdet3d.core.post_processing
import
aligned_3d_nms
from
mmdet3d.core.post_processing
import
aligned_3d_nms
from
mmdet3d.models.builder
import
build_loss
from
mmdet.core
import
build_bbox_coder
,
multi_apply
from
mmdet.core
import
build_bbox_coder
,
multi_apply
from
mmdet.models
import
HEADS
from
..builder
import
HEADS
,
build_loss
from
.base_conv_bbox_head
import
BaseConvBboxHead
from
.base_conv_bbox_head
import
BaseConvBboxHead
EPS
=
1e-6
EPS
=
1e-6
...
...
mmdet3d/models/dense_heads/monoflex_head.py
View file @
76e351a7
...
@@ -9,11 +9,11 @@ from mmdet3d.models.utils import (filter_outside_objs, get_edge_indices,
...
@@ -9,11 +9,11 @@ from mmdet3d.models.utils import (filter_outside_objs, get_edge_indices,
get_keypoints
,
handle_proj_objs
)
get_keypoints
,
handle_proj_objs
)
from
mmdet.core
import
multi_apply
from
mmdet.core
import
multi_apply
from
mmdet.core.bbox.builder
import
build_bbox_coder
from
mmdet.core.bbox.builder
import
build_bbox_coder
from
mmdet.models.builder
import
HEADS
,
build_loss
from
mmdet.models.utils
import
gaussian_radius
,
gen_gaussian_target
from
mmdet.models.utils
import
gaussian_radius
,
gen_gaussian_target
from
mmdet.models.utils.gaussian_target
import
(
get_local_maximum
,
from
mmdet.models.utils.gaussian_target
import
(
get_local_maximum
,
get_topk_from_heatmap
,
get_topk_from_heatmap
,
transpose_and_gather_feat
)
transpose_and_gather_feat
)
from
..builder
import
HEADS
,
build_loss
from
.anchor_free_mono3d_head
import
AnchorFreeMono3DHead
from
.anchor_free_mono3d_head
import
AnchorFreeMono3DHead
...
...
mmdet3d/models/dense_heads/parta2_rpn_head.py
View file @
76e351a7
# Copyright (c) OpenMMLab. All rights reserved.
# Copyright (c) OpenMMLab. All rights reserved.
from
__future__
import
division
import
numpy
as
np
import
numpy
as
np
import
torch
import
torch
from
mmcv.ops
import
nms_bev
as
nms_gpu
from
mmcv.ops
import
nms_normal_bev
as
nms_normal_gpu
from
mmcv.runner
import
force_fp32
from
mmcv.runner
import
force_fp32
from
mmdet3d.core
import
limit_period
,
xywhr2xyxyr
from
mmdet3d.core
import
limit_period
,
xywhr2xyxyr
from
mmdet.models
import
HEADS
from
mmdet3d.core.post_processing
import
nms_bev
,
nms_normal_bev
from
..builder
import
HEADS
from
.anchor3d_head
import
Anchor3DHead
from
.anchor3d_head
import
Anchor3DHead
...
@@ -261,9 +258,9 @@ class PartA2RPNHead(Anchor3DHead):
...
@@ -261,9 +258,9 @@ class PartA2RPNHead(Anchor3DHead):
_scores
=
mlvl_max_scores
[
score_thr_inds
]
_scores
=
mlvl_max_scores
[
score_thr_inds
]
_bboxes_for_nms
=
mlvl_bboxes_for_nms
[
score_thr_inds
,
:]
_bboxes_for_nms
=
mlvl_bboxes_for_nms
[
score_thr_inds
,
:]
if
cfg
.
use_rotate_nms
:
if
cfg
.
use_rotate_nms
:
nms_func
=
nms_
gpu
nms_func
=
nms_
bev
else
:
else
:
nms_func
=
nms_normal_
gpu
nms_func
=
nms_normal_
bev
selected
=
nms_func
(
_bboxes_for_nms
,
_scores
,
cfg
.
nms_thr
)
selected
=
nms_func
(
_bboxes_for_nms
,
_scores
,
cfg
.
nms_thr
)
_mlvl_bboxes
=
mlvl_bboxes
[
score_thr_inds
,
:]
_mlvl_bboxes
=
mlvl_bboxes
[
score_thr_inds
,
:]
...
@@ -288,7 +285,6 @@ class PartA2RPNHead(Anchor3DHead):
...
@@ -288,7 +285,6 @@ class PartA2RPNHead(Anchor3DHead):
scores
=
torch
.
cat
(
scores
,
dim
=
0
)
scores
=
torch
.
cat
(
scores
,
dim
=
0
)
cls_scores
=
torch
.
cat
(
cls_scores
,
dim
=
0
)
cls_scores
=
torch
.
cat
(
cls_scores
,
dim
=
0
)
labels
=
torch
.
cat
(
labels
,
dim
=
0
)
labels
=
torch
.
cat
(
labels
,
dim
=
0
)
dir_scores
=
torch
.
cat
(
dir_scores
,
dim
=
0
)
if
bboxes
.
shape
[
0
]
>
max_num
:
if
bboxes
.
shape
[
0
]
>
max_num
:
_
,
inds
=
scores
.
sort
(
descending
=
True
)
_
,
inds
=
scores
.
sort
(
descending
=
True
)
inds
=
inds
[:
max_num
]
inds
=
inds
[:
max_num
]
...
...
mmdet3d/models/dense_heads/pgd_head.py
View file @
76e351a7
...
@@ -9,7 +9,7 @@ from torch.nn import functional as F
...
@@ -9,7 +9,7 @@ from torch.nn import functional as F
from
mmdet3d.core
import
box3d_multiclass_nms
,
xywhr2xyxyr
from
mmdet3d.core
import
box3d_multiclass_nms
,
xywhr2xyxyr
from
mmdet3d.core.bbox
import
points_cam2img
,
points_img2cam
from
mmdet3d.core.bbox
import
points_cam2img
,
points_img2cam
from
mmdet.core
import
distance2bbox
,
multi_apply
from
mmdet.core
import
distance2bbox
,
multi_apply
from
mmdet.models
.builder
import
HEADS
,
build_loss
from
.
.builder
import
HEADS
,
build_loss
from
.fcos_mono3d_head
import
FCOSMono3DHead
from
.fcos_mono3d_head
import
FCOSMono3DHead
...
...
mmdet3d/models/dense_heads/point_rpn_head.py
View file @
76e351a7
# Copyright (c) OpenMMLab. All rights reserved.
# Copyright (c) OpenMMLab. All rights reserved.
import
torch
import
torch
from
mmcv.ops
import
nms_bev
as
nms_gpu
from
mmcv.ops
import
nms_normal_bev
as
nms_normal_gpu
from
mmcv.runner
import
BaseModule
,
force_fp32
from
mmcv.runner
import
BaseModule
,
force_fp32
from
torch
import
nn
as
nn
from
torch
import
nn
as
nn
from
mmdet3d.core
import
xywhr2xyxyr
from
mmdet3d.core.bbox.structures
import
(
DepthInstance3DBoxes
,
from
mmdet3d.core.bbox.structures
import
(
DepthInstance3DBoxes
,
LiDARInstance3DBoxes
)
LiDARInstance3DBoxes
)
from
mmdet3d.core.post_processing
import
nms_bev
,
nms_normal_bev
from
mmdet.core
import
build_bbox_coder
,
multi_apply
from
mmdet.core
import
build_bbox_coder
,
multi_apply
from
mmdet.models
import
HEADS
,
build_loss
from
..builder
import
HEADS
,
build_loss
@
HEADS
.
register_module
()
@
HEADS
.
register_module
()
...
@@ -19,7 +19,7 @@ class PointRPNHead(BaseModule):
...
@@ -19,7 +19,7 @@ class PointRPNHead(BaseModule):
num_classes (int): Number of classes.
num_classes (int): Number of classes.
train_cfg (dict): Train configs.
train_cfg (dict): Train configs.
test_cfg (dict): Test configs.
test_cfg (dict): Test configs.
pred_layer_cfg (dict, optional): Config of classfication and
pred_layer_cfg (dict, optional): Config of class
i
fication and
regression prediction layers. Defaults to None.
regression prediction layers. Defaults to None.
enlarge_width (float, optional): Enlarge bbox for each side to ignore
enlarge_width (float, optional): Enlarge bbox for each side to ignore
close points. Defaults to 0.1.
close points. Defaults to 0.1.
...
@@ -121,7 +121,7 @@ class PointRPNHead(BaseModule):
...
@@ -121,7 +121,7 @@ class PointRPNHead(BaseModule):
batch_size
,
-
1
,
self
.
_get_cls_out_channels
())
batch_size
,
-
1
,
self
.
_get_cls_out_channels
())
point_box_preds
=
self
.
reg_layers
(
feat_reg
).
reshape
(
point_box_preds
=
self
.
reg_layers
(
feat_reg
).
reshape
(
batch_size
,
-
1
,
self
.
_get_reg_out_channels
())
batch_size
,
-
1
,
self
.
_get_reg_out_channels
())
return
(
point_box_preds
,
point_cls_preds
)
return
point_box_preds
,
point_cls_preds
@
force_fp32
(
apply_to
=
(
'bbox_preds'
))
@
force_fp32
(
apply_to
=
(
'bbox_preds'
))
def
loss
(
self
,
def
loss
(
self
,
...
@@ -159,7 +159,7 @@ class PointRPNHead(BaseModule):
...
@@ -159,7 +159,7 @@ class PointRPNHead(BaseModule):
semantic_targets
=
mask_targets
semantic_targets
=
mask_targets
semantic_targets
[
negative_mask
]
=
self
.
num_classes
semantic_targets
[
negative_mask
]
=
self
.
num_classes
semantic_points_label
=
semantic_targets
semantic_points_label
=
semantic_targets
# for ignore, but now we do not have ignore label
# for ignore, but now we do not have ignore
d
label
semantic_loss_weight
=
negative_mask
.
float
()
+
positive_mask
.
float
()
semantic_loss_weight
=
negative_mask
.
float
()
+
positive_mask
.
float
()
semantic_loss
=
self
.
cls_loss
(
semantic_points
,
semantic_loss
=
self
.
cls_loss
(
semantic_points
,
semantic_points_label
.
reshape
(
-
1
),
semantic_points_label
.
reshape
(
-
1
),
...
@@ -220,7 +220,7 @@ class PointRPNHead(BaseModule):
...
@@ -220,7 +220,7 @@ class PointRPNHead(BaseModule):
gt_bboxes_3d
=
gt_bboxes_3d
[
valid_gt
]
gt_bboxes_3d
=
gt_bboxes_3d
[
valid_gt
]
gt_labels_3d
=
gt_labels_3d
[
valid_gt
]
gt_labels_3d
=
gt_labels_3d
[
valid_gt
]
# transform the bbox coordinate to the pointcloud coordinate
# transform the bbox coordinate to the point
cloud coordinate
gt_bboxes_3d_tensor
=
gt_bboxes_3d
.
tensor
.
clone
()
gt_bboxes_3d_tensor
=
gt_bboxes_3d
.
tensor
.
clone
()
gt_bboxes_3d_tensor
[...,
2
]
+=
gt_bboxes_3d_tensor
[...,
5
]
/
2
gt_bboxes_3d_tensor
[...,
2
]
+=
gt_bboxes_3d_tensor
[...,
5
]
/
2
...
@@ -233,7 +233,6 @@ class PointRPNHead(BaseModule):
...
@@ -233,7 +233,6 @@ class PointRPNHead(BaseModule):
points
[...,
0
:
3
],
mask_targets
)
points
[...,
0
:
3
],
mask_targets
)
positive_mask
=
(
points_mask
.
max
(
1
)[
0
]
>
0
)
positive_mask
=
(
points_mask
.
max
(
1
)[
0
]
>
0
)
negative_mask
=
(
points_mask
.
max
(
1
)[
0
]
==
0
)
# add ignore_mask
# add ignore_mask
extend_gt_bboxes_3d
=
gt_bboxes_3d
.
enlarged_box
(
self
.
enlarge_width
)
extend_gt_bboxes_3d
=
gt_bboxes_3d
.
enlarged_box
(
self
.
enlarge_width
)
points_mask
,
_
=
self
.
_assign_targets_by_points_inside
(
points_mask
,
_
=
self
.
_assign_targets_by_points_inside
(
...
@@ -297,9 +296,9 @@ class PointRPNHead(BaseModule):
...
@@ -297,9 +296,9 @@ class PointRPNHead(BaseModule):
nms_cfg
=
self
.
test_cfg
.
nms_cfg
if
not
self
.
training
\
nms_cfg
=
self
.
test_cfg
.
nms_cfg
if
not
self
.
training
\
else
self
.
train_cfg
.
nms_cfg
else
self
.
train_cfg
.
nms_cfg
if
nms_cfg
.
use_rotate_nms
:
if
nms_cfg
.
use_rotate_nms
:
nms_func
=
nms_
gpu
nms_func
=
nms_
bev
else
:
else
:
nms_func
=
nms_normal_
gpu
nms_func
=
nms_normal_
bev
num_bbox
=
bbox
.
shape
[
0
]
num_bbox
=
bbox
.
shape
[
0
]
bbox
=
input_meta
[
'box_type_3d'
](
bbox
=
input_meta
[
'box_type_3d'
](
...
@@ -322,29 +321,33 @@ class PointRPNHead(BaseModule):
...
@@ -322,29 +321,33 @@ class PointRPNHead(BaseModule):
else
:
else
:
raise
NotImplementedError
(
'Unsupported bbox type!'
)
raise
NotImplementedError
(
'Unsupported bbox type!'
)
bbox
=
bbox
.
tensor
[
nonempty_box_mask
]
bbox
=
bbox
[
nonempty_box_mask
]
if
self
.
test_cfg
.
score_thr
is
not
None
:
if
self
.
test_cfg
.
score_thr
is
not
None
:
score_thr
=
self
.
test_cfg
.
score_thr
score_thr
=
self
.
test_cfg
.
score_thr
keep
=
(
obj_scores
>=
score_thr
)
keep
=
(
obj_scores
>=
score_thr
)
obj_scores
=
obj_scores
[
keep
]
obj_scores
=
obj_scores
[
keep
]
sem_scores
=
sem_scores
[
keep
]
sem_scores
=
sem_scores
[
keep
]
bbox
=
bbox
[
keep
]
bbox
=
bbox
.
tensor
[
keep
]
if
obj_scores
.
shape
[
0
]
>
0
:
if
obj_scores
.
shape
[
0
]
>
0
:
topk
=
min
(
nms_cfg
.
nms_pre
,
obj_scores
.
shape
[
0
])
topk
=
min
(
nms_cfg
.
nms_pre
,
obj_scores
.
shape
[
0
])
obj_scores_nms
,
indices
=
torch
.
topk
(
obj_scores
,
k
=
topk
)
obj_scores_nms
,
indices
=
torch
.
topk
(
obj_scores
,
k
=
topk
)
bbox_for_nms
=
bbox
[
indices
]
bbox_for_nms
=
xywhr2xyxyr
(
bbox
[
indices
]
.
bev
)
sem_scores_nms
=
sem_scores
[
indices
]
sem_scores_nms
=
sem_scores
[
indices
]
keep
=
nms_func
(
bbox_for_nms
[:,
0
:
7
],
obj_scores_nms
,
keep
=
nms_func
(
bbox_for_nms
,
obj_scores_nms
,
nms_cfg
.
iou_thr
)
nms_cfg
.
iou_thr
)
keep
=
keep
[:
nms_cfg
.
nms_post
]
keep
=
keep
[:
nms_cfg
.
nms_post
]
bbox_selected
=
bbox
_for_nms
[
keep
]
bbox_selected
=
bbox
.
tensor
[
indices
]
[
keep
]
score_selected
=
obj_scores_nms
[
keep
]
score_selected
=
obj_scores_nms
[
keep
]
cls_preds
=
sem_scores_nms
[
keep
]
cls_preds
=
sem_scores_nms
[
keep
]
labels
=
torch
.
argmax
(
cls_preds
,
-
1
)
labels
=
torch
.
argmax
(
cls_preds
,
-
1
)
else
:
bbox_selected
=
bbox
.
tensor
score_selected
=
obj_scores
.
new_zeros
([
0
])
labels
=
obj_scores
.
new_zeros
([
0
])
cls_preds
=
obj_scores
.
new_zeros
([
0
,
sem_scores
.
shape
[
-
1
]])
return
bbox_selected
,
score_selected
,
labels
,
cls_preds
return
bbox_selected
,
score_selected
,
labels
,
cls_preds
...
...
mmdet3d/models/dense_heads/shape_aware_head.py
View file @
76e351a7
...
@@ -9,8 +9,7 @@ from torch import nn as nn
...
@@ -9,8 +9,7 @@ from torch import nn as nn
from
mmdet3d.core
import
box3d_multiclass_nms
,
limit_period
,
xywhr2xyxyr
from
mmdet3d.core
import
box3d_multiclass_nms
,
limit_period
,
xywhr2xyxyr
from
mmdet.core
import
multi_apply
from
mmdet.core
import
multi_apply
from
mmdet.models
import
HEADS
from
..builder
import
HEADS
,
build_head
from
..builder
import
build_head
from
.anchor3d_head
import
Anchor3DHead
from
.anchor3d_head
import
Anchor3DHead
...
...
mmdet3d/models/dense_heads/smoke_mono3d_head.py
View file @
76e351a7
...
@@ -4,11 +4,11 @@ from torch.nn import functional as F
...
@@ -4,11 +4,11 @@ from torch.nn import functional as F
from
mmdet.core
import
multi_apply
from
mmdet.core
import
multi_apply
from
mmdet.core.bbox.builder
import
build_bbox_coder
from
mmdet.core.bbox.builder
import
build_bbox_coder
from
mmdet.models.builder
import
HEADS
from
mmdet.models.utils
import
gaussian_radius
,
gen_gaussian_target
from
mmdet.models.utils
import
gaussian_radius
,
gen_gaussian_target
from
mmdet.models.utils.gaussian_target
import
(
get_local_maximum
,
from
mmdet.models.utils.gaussian_target
import
(
get_local_maximum
,
get_topk_from_heatmap
,
get_topk_from_heatmap
,
transpose_and_gather_feat
)
transpose_and_gather_feat
)
from
..builder
import
HEADS
from
.anchor_free_mono3d_head
import
AnchorFreeMono3DHead
from
.anchor_free_mono3d_head
import
AnchorFreeMono3DHead
...
...
mmdet3d/models/dense_heads/ssd_3d_head.py
View file @
76e351a7
...
@@ -7,9 +7,8 @@ from torch.nn import functional as F
...
@@ -7,9 +7,8 @@ from torch.nn import functional as F
from
mmdet3d.core.bbox.structures
import
(
DepthInstance3DBoxes
,
from
mmdet3d.core.bbox.structures
import
(
DepthInstance3DBoxes
,
LiDARInstance3DBoxes
,
LiDARInstance3DBoxes
,
rotation_3d_in_axis
)
rotation_3d_in_axis
)
from
mmdet3d.models.builder
import
build_loss
from
mmdet.core
import
multi_apply
from
mmdet.core
import
multi_apply
from
mmdet.models
import
HEADS
from
..builder
import
HEADS
,
build_loss
from
.vote_head
import
VoteHead
from
.vote_head
import
VoteHead
...
...
mmdet3d/models/dense_heads/vote_head.py
View file @
76e351a7
...
@@ -6,12 +6,11 @@ from mmcv.runner import BaseModule, force_fp32
...
@@ -6,12 +6,11 @@ from mmcv.runner import BaseModule, force_fp32
from
torch.nn
import
functional
as
F
from
torch.nn
import
functional
as
F
from
mmdet3d.core.post_processing
import
aligned_3d_nms
from
mmdet3d.core.post_processing
import
aligned_3d_nms
from
mmdet3d.models.builder
import
build_loss
from
mmdet3d.models.losses
import
chamfer_distance
from
mmdet3d.models.losses
import
chamfer_distance
from
mmdet3d.models.model_utils
import
VoteModule
from
mmdet3d.models.model_utils
import
VoteModule
from
mmdet3d.ops
import
build_sa_module
from
mmdet3d.ops
import
build_sa_module
from
mmdet.core
import
build_bbox_coder
,
multi_apply
from
mmdet.core
import
build_bbox_coder
,
multi_apply
from
mmdet.models
import
HEADS
from
..builder
import
HEADS
,
build_loss
from
.base_conv_bbox_head
import
BaseConvBboxHead
from
.base_conv_bbox_head
import
BaseConvBboxHead
...
...
mmdet3d/models/detectors/centerpoint.py
View file @
76e351a7
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
import
torch
import
torch
from
mmdet3d.core
import
bbox3d2result
,
merge_aug_bboxes_3d
from
mmdet3d.core
import
bbox3d2result
,
merge_aug_bboxes_3d
from
mmdet.models
import
DETECTORS
from
..builder
import
DETECTORS
from
.mvx_two_stage
import
MVXTwoStageDetector
from
.mvx_two_stage
import
MVXTwoStageDetector
...
...
Prev
1
2
3
4
5
6
7
Next
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