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
b2c43ffd
Commit
b2c43ffd
authored
Jun 20, 2020
by
zhangwenwei
Browse files
Merge branch 'add_docstring' into 'master'
Add docstrings See merge request open-mmlab/mmdet.3d!72
parents
613c8844
8f88914d
Changes
31
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
162 additions
and
101 deletions
+162
-101
mmdet3d/datasets/kitti_dataset.py
mmdet3d/datasets/kitti_dataset.py
+2
-2
mmdet3d/models/dense_heads/anchor3d_head.py
mmdet3d/models/dense_heads/anchor3d_head.py
+37
-34
mmdet3d/models/dense_heads/parta2_rpn_head.py
mmdet3d/models/dense_heads/parta2_rpn_head.py
+22
-18
mmdet3d/models/dense_heads/train_mixins.py
mmdet3d/models/dense_heads/train_mixins.py
+10
-10
mmdet3d/models/dense_heads/vote_head.py
mmdet3d/models/dense_heads/vote_head.py
+25
-22
mmdet3d/models/detectors/base.py
mmdet3d/models/detectors/base.py
+9
-8
mmdet3d/models/detectors/single_stage.py
mmdet3d/models/detectors/single_stage.py
+4
-1
mmdet3d/models/detectors/votenet.py
mmdet3d/models/detectors/votenet.py
+7
-6
tools/data_converter/create_gt_database.py
tools/data_converter/create_gt_database.py
+21
-0
tools/data_converter/kitti_converter.py
tools/data_converter/kitti_converter.py
+13
-0
tools/data_converter/nuscenes_converter.py
tools/data_converter/nuscenes_converter.py
+12
-0
No files found.
mmdet3d/datasets/kitti_dataset.py
View file @
b2c43ffd
...
@@ -339,7 +339,7 @@ class KittiDataset(Custom3DDataset):
...
@@ -339,7 +339,7 @@ class KittiDataset(Custom3DDataset):
class_names
,
class_names
,
pklfile_prefix
=
None
,
pklfile_prefix
=
None
,
submission_prefix
=
None
):
submission_prefix
=
None
):
"""Convert results to kitti format for evaluation and test submission
"""Convert results to kitti format for evaluation and test submission
.
Args:
Args:
net_outputs (List[array]): list of array storing the bbox and score
net_outputs (List[array]): list of array storing the bbox and score
...
@@ -348,7 +348,7 @@ class KittiDataset(Custom3DDataset):
...
@@ -348,7 +348,7 @@ class KittiDataset(Custom3DDataset):
submission_prefix (str | None): The prefix of submission file.
submission_prefix (str | None): The prefix of submission file.
Return:
Return:
List
(
[dict]
)
: A list of dict have the kitti format
List[dict]: A list of dict have the kitti format
"""
"""
assert
len
(
net_outputs
)
==
len
(
self
.
data_infos
)
assert
len
(
net_outputs
)
==
len
(
self
.
data_infos
)
...
...
mmdet3d/models/dense_heads/anchor3d_head.py
View file @
b2c43ffd
...
@@ -134,10 +134,10 @@ class Anchor3DHead(nn.Module, AnchorTrainMixin):
...
@@ -134,10 +134,10 @@ class Anchor3DHead(nn.Module, AnchorTrainMixin):
"""Forward function on a single-scale feature map.
"""Forward function on a single-scale feature map.
Args:
Args:
x (Tensor): Input features.
x (
torch.
Tensor): Input features.
Returns:
Returns:
tuple[Tensor]: Contain score of each class, bbox predictions
tuple[
torch.
Tensor]: Contain score of each class, bbox predictions
and class predictions of direction.
and class predictions of direction.
"""
"""
cls_score
=
self
.
conv_cls
(
x
)
cls_score
=
self
.
conv_cls
(
x
)
...
@@ -151,11 +151,11 @@ class Anchor3DHead(nn.Module, AnchorTrainMixin):
...
@@ -151,11 +151,11 @@ class Anchor3DHead(nn.Module, AnchorTrainMixin):
"""Forward pass.
"""Forward pass.
Args:
Args:
feats (list[Tensor]): Multi-level features, e.g.,
feats (list[
torch.
Tensor]): Multi-level features, e.g.,
features produced by FPN.
features produced by FPN.
Returns:
Returns:
tuple[list[Tensor]]: Multi-level class score, bbox
tuple[list[
torch.
Tensor]]: Multi-level class score, bbox
and direction predictions.
and direction predictions.
"""
"""
return
multi_apply
(
self
.
forward_single
,
feats
)
return
multi_apply
(
self
.
forward_single
,
feats
)
...
@@ -185,20 +185,21 @@ class Anchor3DHead(nn.Module, AnchorTrainMixin):
...
@@ -185,20 +185,21 @@ class Anchor3DHead(nn.Module, AnchorTrainMixin):
"""Calculate loss of Single-level results.
"""Calculate loss of Single-level results.
Args:
Args:
cls_score (Tensor): Class score in single-level.
cls_score (
torch.
Tensor): Class score in single-level.
bbox_pred (Tensor): Bbox prediction in single-level.
bbox_pred (
torch.
Tensor): Bbox prediction in single-level.
dir_cls_preds (Tensor): Predictions of direction class
dir_cls_preds (
torch.
Tensor): Predictions of direction class
in single-level.
in single-level.
labels (Tensor): Labels of class.
labels (
torch.
Tensor): Labels of class.
label_weights (Tensor): Weights of class loss.
label_weights (
torch.
Tensor): Weights of class loss.
bbox_targets (Tensor): Targets of bbox predictions.
bbox_targets (
torch.
Tensor): Targets of bbox predictions.
bbox_weights (Tensor): Weights of bbox loss.
bbox_weights (
torch.
Tensor): Weights of bbox loss.
dir_targets (Tensor): Targets of direction predictions.
dir_targets (
torch.
Tensor): Targets of direction predictions.
dir_weights (Tensor): Weights of direction loss.
dir_weights (
torch.
Tensor): Weights of direction loss.
num_total_samples (int): The number of valid samples.
num_total_samples (int): The number of valid samples.
Returns:
Returns:
tuple[Tensor]: losses of class, bbox and direction, respectively.
tuple[torch.Tensor]: losses of class, bbox
and direction, respectively.
"""
"""
# classification loss
# classification loss
if
num_total_samples
is
None
:
if
num_total_samples
is
None
:
...
@@ -246,10 +247,10 @@ class Anchor3DHead(nn.Module, AnchorTrainMixin):
...
@@ -246,10 +247,10 @@ class Anchor3DHead(nn.Module, AnchorTrainMixin):
"""Convert the rotation difference to difference in sine function
"""Convert the rotation difference to difference in sine function
Args:
Args:
boxes1 (Tensor): shape (NxC), where C>=7 and
the 7th dimension is
boxes1 (
torch.
Tensor): shape (NxC), where C>=7 and
rotation dimension
the 7th dimension is
rotation dimension
boxes2 (Tensor): shape (NxC), where C>=7 and the 7th
dimension is
boxes2 (
torch.
Tensor): shape (NxC), where C>=7 and the 7th
rotation dimension
dimension is
rotation dimension
Returns:
Returns:
tuple: (boxes1, boxes2) whose 7th dimensions are changed
tuple: (boxes1, boxes2) whose 7th dimensions are changed
...
@@ -275,15 +276,16 @@ class Anchor3DHead(nn.Module, AnchorTrainMixin):
...
@@ -275,15 +276,16 @@ class Anchor3DHead(nn.Module, AnchorTrainMixin):
"""Calculate losses.
"""Calculate losses.
Args:
Args:
cls_scores (list[Tensor]): Multi-level class scores.
cls_scores (list[
torch.
Tensor]): Multi-level class scores.
bbox_preds (list[Tensor]): Multi-level bbox predictions.
bbox_preds (list[
torch.
Tensor]): Multi-level bbox predictions.
dir_cls_preds (list[Tensor]): Multi-level direction
dir_cls_preds (list[
torch.
Tensor]): Multi-level direction
class predictions.
class predictions.
gt_bboxes (list[:obj:BaseInstance3DBoxes]): Gt bboxes
gt_bboxes (list[:obj:BaseInstance3DBoxes]): Gt bboxes
of each sample.
of each sample.
gt_labels (list[Tensor]): Gt labels of each sample.
gt_labels (list[
torch.
Tensor]): Gt labels of each sample.
input_metas (list[dict]): Contain pcd and img's meta info.
input_metas (list[dict]): Contain pcd and img's meta info.
gt_bboxes_ignore (None | list[Tensor]): Specify which bounding.
gt_bboxes_ignore (None | list[torch.Tensor]): Specify
which bounding.
Returns:
Returns:
dict: Contain class, bbox and direction losses of each level.
dict: Contain class, bbox and direction losses of each level.
...
@@ -338,13 +340,13 @@ class Anchor3DHead(nn.Module, AnchorTrainMixin):
...
@@ -338,13 +340,13 @@ class Anchor3DHead(nn.Module, AnchorTrainMixin):
"""Get bboxes of anchor head.
"""Get bboxes of anchor head.
Args:
Args:
cls_scores (list[Tensor]): Multi-level class scores.
cls_scores (list[
torch.
Tensor]): Multi-level class scores.
bbox_preds (list[Tensor]): Multi-level bbox predictions.
bbox_preds (list[
torch.
Tensor]): Multi-level bbox predictions.
dir_cls_preds (list[Tensor]): Multi-level direction
dir_cls_preds (list[
torch.
Tensor]): Multi-level direction
class predictions.
class predictions.
input_metas (list[dict]): Contain pcd and img's meta info.
input_metas (list[dict]): Contain pcd and img's meta info.
cfg (None | ConfigDict): Training or testing config.
cfg (None | ConfigDict): Training or testing config.
rescale (list[Tensor]): whether th rescale bbox.
rescale (list[
torch.
Tensor]): whether th rescale bbox.
Returns:
Returns:
list[tuple]: prediction resultes of batches.
list[tuple]: prediction resultes of batches.
...
@@ -390,20 +392,21 @@ class Anchor3DHead(nn.Module, AnchorTrainMixin):
...
@@ -390,20 +392,21 @@ class Anchor3DHead(nn.Module, AnchorTrainMixin):
"""Get bboxes of single branch.
"""Get bboxes of single branch.
Args:
Args:
cls_scores (Tensor): Class score in single batch.
cls_scores (torch.Tensor): Class score in single batch.
bbox_preds (Tensor): Bbox prediction in single batch.
bbox_preds (torch.Tensor): Bbox prediction in single batch.
dir_cls_preds (Tensor): Predictions of direction class
dir_cls_preds (torch.Tensor): Predictions of direction class
in single batch.
mlvl_anchors (List[torch.Tensor]): Multi-level anchors
in single batch.
in single batch.
mlvl_anchors (List[Tensor]): Multi-level anchors in single batch.
input_meta (list[dict]): Contain pcd and img's meta info.
input_meta (list[dict]): Contain pcd and img's meta info.
cfg (None | ConfigDict): Training or testing config.
cfg (None | ConfigDict): Training or testing config.
rescale (list[Tensor]): whether th rescale bbox.
rescale (list[
torch.
Tensor]): whether th rescale bbox.
Returns:
Returns:
tuple: Contain predictions of single batch.
tuple: Contain predictions of single batch.
- bboxes (:obj:BaseInstance3DBoxes): Predicted 3d bboxes.
- bboxes (:obj:BaseInstance3DBoxes): Predicted 3d bboxes.
- scores (Tensor): Class score of each bbox.
- scores (
torch.
Tensor): Class score of each bbox.
- labels (Tensor): Label of each bbox.
- labels (
torch.
Tensor): Label of each bbox.
"""
"""
cfg
=
self
.
test_cfg
if
cfg
is
None
else
cfg
cfg
=
self
.
test_cfg
if
cfg
is
None
else
cfg
assert
len
(
cls_scores
)
==
len
(
bbox_preds
)
==
len
(
mlvl_anchors
)
assert
len
(
cls_scores
)
==
len
(
bbox_preds
)
==
len
(
mlvl_anchors
)
...
...
mmdet3d/models/dense_heads/parta2_rpn_head.py
View file @
b2c43ffd
...
@@ -109,21 +109,22 @@ class PartA2RPNHead(Anchor3DHead):
...
@@ -109,21 +109,22 @@ class PartA2RPNHead(Anchor3DHead):
"""Get bboxes of single branch.
"""Get bboxes of single branch.
Args:
Args:
cls_scores (Tensor): Class score in single batch.
cls_scores (torch.Tensor): Class score in single batch.
bbox_preds (Tensor): Bbox prediction in single batch.
bbox_preds (torch.Tensor): Bbox prediction in single batch.
dir_cls_preds (Tensor): Predictions of direction class
dir_cls_preds (torch.Tensor): Predictions of direction class
in single batch.
mlvl_anchors (List[torch.Tensor]): Multi-level anchors
in single batch.
in single batch.
mlvl_anchors (List[Tensor]): Multi-level anchors in single batch.
input_meta (list[dict]): Contain pcd and img's meta info.
input_meta (list[dict]): Contain pcd and img's meta info.
cfg (None | ConfigDict): Training or testing config.
cfg (None | ConfigDict): Training or testing config.
rescale (list[Tensor]): whether th rescale bbox.
rescale (list[
torch.
Tensor]): whether th rescale bbox.
Returns:
Returns:
dict: Predictions of single batch. Contain the keys:
dict: Predictions of single batch. Contain the keys:
- boxes_3d (:obj:BaseInstance3DBoxes): Predicted 3d bboxes.
- boxes_3d (:obj:BaseInstance3DBoxes): Predicted 3d bboxes.
- scores_3d (Tensor): Score of each bbox.
- scores_3d (
torch.
Tensor): Score of each bbox.
- labels_3d (Tensor): Label of each bbox.
- labels_3d (
torch.
Tensor): Label of each bbox.
- cls_preds (Tensor): Class score of each bbox.
- cls_preds (
torch.
Tensor): Class score of each bbox.
"""
"""
assert
len
(
cls_scores
)
==
len
(
bbox_preds
)
==
len
(
mlvl_anchors
)
assert
len
(
cls_scores
)
==
len
(
bbox_preds
)
==
len
(
mlvl_anchors
)
mlvl_bboxes
=
[]
mlvl_bboxes
=
[]
...
@@ -198,13 +199,16 @@ class PartA2RPNHead(Anchor3DHead):
...
@@ -198,13 +199,16 @@ class PartA2RPNHead(Anchor3DHead):
"""Class agnostic nms for single batch.
"""Class agnostic nms for single batch.
Args:
Args:
mlvl_bboxes (Tensor): Bboxes from Multi-level.
mlvl_bboxes (torch.Tensor): Bboxes from Multi-level.
mlvl_bboxes_for_nms (Tensor): Bboxes for nms (bev or minmax boxes)
mlvl_bboxes_for_nms (torch.Tensor): Bboxes for nms
from Multi-level.
(bev or minmax boxes) from Multi-level.
mlvl_max_scores (Tensor): Max scores of Multi-level bbox.
mlvl_max_scores (torch.Tensor): Max scores of Multi-level bbox.
mlvl_label_pred (Tensor): Class predictions of Multi-level bbox.
mlvl_label_pred (torch.Tensor): Class predictions
mlvl_cls_score (Tensor): Class scores of Multi-level bbox.
of Multi-level bbox.
mlvl_dir_scores (Tensor): Direction scores of Multi-level bbox.
mlvl_cls_score (torch.Tensor): Class scores of
Multi-level bbox.
mlvl_dir_scores (torch.Tensor): Direction scores of
Multi-level bbox.
score_thr (int): Score threshold.
score_thr (int): Score threshold.
max_num (int): Max number of bboxes after nms.
max_num (int): Max number of bboxes after nms.
cfg (None | ConfigDict): Training or testing config.
cfg (None | ConfigDict): Training or testing config.
...
@@ -213,9 +217,9 @@ class PartA2RPNHead(Anchor3DHead):
...
@@ -213,9 +217,9 @@ class PartA2RPNHead(Anchor3DHead):
Returns:
Returns:
dict: Predictions of single batch. Contain the keys:
dict: Predictions of single batch. Contain the keys:
- boxes_3d (:obj:BaseInstance3DBoxes): Predicted 3d bboxes.
- boxes_3d (:obj:BaseInstance3DBoxes): Predicted 3d bboxes.
- scores_3d (Tensor): Score of each bbox.
- scores_3d (
torch.
Tensor): Score of each bbox.
- labels_3d (Tensor): Label of each bbox.
- labels_3d (
torch.
Tensor): Label of each bbox.
- cls_preds (Tensor): Class score of each bbox.
- cls_preds (
torch.
Tensor): Class score of each bbox.
"""
"""
bboxes
=
[]
bboxes
=
[]
scores
=
[]
scores
=
[]
...
...
mmdet3d/models/dense_heads/train_mixins.py
View file @
b2c43ffd
...
@@ -24,7 +24,7 @@ class AnchorTrainMixin(object):
...
@@ -24,7 +24,7 @@ class AnchorTrainMixin(object):
bboxes of each image.
bboxes of each image.
input_metas (list[dict]): Meta info of each image.
input_metas (list[dict]): Meta info of each image.
gt_bboxes_ignore_list (None | list): Ignore list of gt bboxes.
gt_bboxes_ignore_list (None | list): Ignore list of gt bboxes.
gt_labels_list (list[Tensor]): Gt labels of batches.
gt_labels_list (list[
torch.
Tensor]): Gt labels of batches.
label_channels (int): The channel of labels.
label_channels (int): The channel of labels.
num_classes (int): The number of classes.
num_classes (int): The number of classes.
sampling (bool): Whether to sample anchors.
sampling (bool): Whether to sample anchors.
...
@@ -95,10 +95,10 @@ class AnchorTrainMixin(object):
...
@@ -95,10 +95,10 @@ class AnchorTrainMixin(object):
"""Compute targets of anchors in single batch.
"""Compute targets of anchors in single batch.
Args:
Args:
anchors (Tensor): Concatenated multi-level anchor.
anchors (
torch.
Tensor): Concatenated multi-level anchor.
gt_bboxes (:obj:BaseInstance3DBoxes): Gt bboxes.
gt_bboxes (:obj:BaseInstance3DBoxes): Gt bboxes.
gt_bboxes_ignore (Tensor): Ignored gt bboxes.
gt_bboxes_ignore (
torch.
Tensor): Ignored gt bboxes.
gt_labels (Tensor): Gt class labels.
gt_labels (
torch.
Tensor): Gt class labels.
input_meta (dict): Meta info of each image.
input_meta (dict): Meta info of each image.
label_channels (int): The channel of labels.
label_channels (int): The channel of labels.
num_classes (int): The number of classes.
num_classes (int): The number of classes.
...
@@ -184,10 +184,10 @@ class AnchorTrainMixin(object):
...
@@ -184,10 +184,10 @@ class AnchorTrainMixin(object):
Args:
Args:
bbox_assigner (BaseAssigner): assign positive and negative boxes.
bbox_assigner (BaseAssigner): assign positive and negative boxes.
anchors (Tensor): Concatenated multi-level anchor.
anchors (
torch.
Tensor): Concatenated multi-level anchor.
gt_bboxes (:obj:BaseInstance3DBoxes): Gt bboxes.
gt_bboxes (:obj:BaseInstance3DBoxes): Gt bboxes.
gt_bboxes_ignore (Tensor): Ignored gt bboxes.
gt_bboxes_ignore (
torch.
Tensor): Ignored gt bboxes.
gt_labels (Tensor): Gt class labels.
gt_labels (
torch.
Tensor): Gt class labels.
input_meta (dict): Meta info of each image.
input_meta (dict): Meta info of each image.
label_channels (int): The channel of labels.
label_channels (int): The channel of labels.
num_classes (int): The number of classes.
num_classes (int): The number of classes.
...
@@ -260,14 +260,14 @@ def get_direction_target(anchors,
...
@@ -260,14 +260,14 @@ def get_direction_target(anchors,
"""Encode direction to 0 ~ num_bins-1.
"""Encode direction to 0 ~ num_bins-1.
Args:
Args:
anchors (Tensor): Concatenated multi-level anchor.
anchors (
torch.
Tensor): Concatenated multi-level anchor.
reg_targets (Tensor): Bbox regression targets.
reg_targets (
torch.
Tensor): Bbox regression targets.
dir_offset (int): Direction offset.
dir_offset (int): Direction offset.
num_bins (int): Number of bins to divide 2*PI.
num_bins (int): Number of bins to divide 2*PI.
one_hot (bool): Whether to encode as one hot.
one_hot (bool): Whether to encode as one hot.
Returns:
Returns:
Tensor: Encoded direction targets.
torch.
Tensor: Encoded direction targets.
"""
"""
rot_gt
=
reg_targets
[...,
6
]
+
anchors
[...,
6
]
rot_gt
=
reg_targets
[...,
6
]
+
anchors
[...,
6
]
offset_rot
=
box_torch_ops
.
limit_period
(
rot_gt
-
dir_offset
,
0
,
2
*
np
.
pi
)
offset_rot
=
box_torch_ops
.
limit_period
(
rot_gt
-
dir_offset
,
0
,
2
*
np
.
pi
)
...
...
mmdet3d/models/dense_heads/vote_head.py
View file @
b2c43ffd
...
@@ -188,14 +188,17 @@ class VoteHead(nn.Module):
...
@@ -188,14 +188,17 @@ class VoteHead(nn.Module):
Args:
Args:
bbox_preds (dict): Predictions from forward of vote head.
bbox_preds (dict): Predictions from forward of vote head.
points (list[Tensor]): Input points.
points (list[
torch.
Tensor]): Input points.
gt_bboxes_3d (list[:obj:BaseInstance3DBoxes]): Gt bboxes
gt_bboxes_3d (list[:obj:BaseInstance3DBoxes]): Gt bboxes
of each sample.
of each sample.
gt_labels_3d (list[Tensor]): Gt labels of each sample.
gt_labels_3d (list[torch.Tensor]): Gt labels of each sample.
pts_semantic_mask (None | list[Tensor]): Point-wise semantic mask.
pts_semantic_mask (None | list[torch.Tensor]): Point-wise
pts_instance_mask (None | list[Tensor]): Point-wise instance mask.
semantic mask.
pts_instance_mask (None | list[torch.Tensor]): Point-wise
instance mask.
img_metas (list[dict]): Contain pcd and img's meta info.
img_metas (list[dict]): Contain pcd and img's meta info.
gt_bboxes_ignore (None | list[Tensor]): Specify which bounding.
gt_bboxes_ignore (None | list[torch.Tensor]): Specify
which bounding.
Returns:
Returns:
dict: Losses of Votenet.
dict: Losses of Votenet.
...
@@ -292,15 +295,15 @@ class VoteHead(nn.Module):
...
@@ -292,15 +295,15 @@ class VoteHead(nn.Module):
"""Generate targets of vote head.
"""Generate targets of vote head.
Args:
Args:
points (list[Tensor]): Points of each batch.
points (list[
torch.
Tensor]): Points of each batch.
gt_bboxes_3d (list[:obj:BaseInstance3DBoxes]): gt bboxes of
gt_bboxes_3d (list[:obj:BaseInstance3DBoxes]): gt bboxes of
each batch.
each batch.
gt_labels_3d (list[Tensor]): gt class labels of each batch.
gt_labels_3d (list[
torch.
Tensor]): gt class labels of each batch.
pts_semantic_mask (None | list[Tensor]): point-wise semantic
pts_semantic_mask (None | list[
torch.
Tensor]): point-wise semantic
label of each batch.
label of each batch.
pts_instance_mask (None | list[Tensor]): point-wise instance
pts_instance_mask (None | list[
torch.
Tensor]): point-wise instance
label of each batch.
label of each batch.
bbox_preds (Tensor): Bbox predictions of vote head.
bbox_preds (
torch.
Tensor): Bbox predictions of vote head.
Returns:
Returns:
tuple: Targets of vote head.
tuple: Targets of vote head.
...
@@ -378,14 +381,14 @@ class VoteHead(nn.Module):
...
@@ -378,14 +381,14 @@ class VoteHead(nn.Module):
"""Generate targets of vote head for single batch.
"""Generate targets of vote head for single batch.
Args:
Args:
points (Tensor): Points of each batch.
points (
torch.
Tensor): Points of each batch.
gt_bboxes_3d (:obj:BaseInstance3DBoxes): gt bboxes of each batch.
gt_bboxes_3d (:obj:BaseInstance3DBoxes): gt bboxes of each batch.
gt_labels_3d (Tensor): gt class labels of each batch.
gt_labels_3d (
torch.
Tensor): gt class labels of each batch.
pts_semantic_mask (None | Tensor): point-wise semantic
pts_semantic_mask (None |
torch.
Tensor): point-wise semantic
label of each batch.
label of each batch.
pts_instance_mask (None | Tensor): point-wise instance
pts_instance_mask (None |
torch.
Tensor): point-wise instance
label of each batch.
label of each batch.
aggregated_points (Tensor): Aggregated points from
aggregated_points (
torch.
Tensor): Aggregated points from
vote aggregation layer.
vote aggregation layer.
Returns:
Returns:
...
@@ -491,13 +494,13 @@ class VoteHead(nn.Module):
...
@@ -491,13 +494,13 @@ class VoteHead(nn.Module):
"""Generate bboxes from vote head predictions.
"""Generate bboxes from vote head predictions.
Args:
Args:
points (Tensor): Input points.
points (
torch.
Tensor): Input points.
bbox_preds (dict): Predictions from vote head.
bbox_preds (dict): Predictions from vote head.
input_metas (list[dict]): Contain pcd and img's meta info.
input_metas (list[dict]): Contain pcd and img's meta info.
rescale (bool): Whether to rescale bboxes.
rescale (bool): Whether to rescale bboxes.
Returns:
Returns:
list[tuple[Tensor]]: Contain bbox, scores and labels.
list[tuple[
torch.
Tensor]]: Contain bbox, scores and labels.
"""
"""
# decode boxes
# decode boxes
obj_scores
=
F
.
softmax
(
bbox_preds
[
'obj_scores'
],
dim
=-
1
)[...,
-
1
]
obj_scores
=
F
.
softmax
(
bbox_preds
[
'obj_scores'
],
dim
=-
1
)[...,
-
1
]
...
@@ -523,14 +526,14 @@ class VoteHead(nn.Module):
...
@@ -523,14 +526,14 @@ class VoteHead(nn.Module):
"""multi-class nms in single batch.
"""multi-class nms in single batch.
Args:
Args:
obj_scores (Tensor): Objectness score of bboxes.
obj_scores (
torch.
Tensor): Objectness score of bboxes.
sem_scores (Tensor): semantic class score of bboxes.
sem_scores (
torch.
Tensor): semantic class score of bboxes.
bbox (Tensor): Predicted bbox.
bbox (
torch.
Tensor): Predicted bbox.
points (Tensor): Input points.
points (
torch.
Tensor): Input points.
input_meta (dict): Contain pcd and img's meta info.
input_meta (dict): Contain pcd and img's meta info.
Returns:
Returns:
tuple[Tensor]: Contain bbox, scores and labels.
tuple[
torch.
Tensor]: Contain bbox, scores and labels.
"""
"""
bbox
=
input_meta
[
'box_type_3d'
](
bbox
=
input_meta
[
'box_type_3d'
](
bbox
,
bbox
,
...
...
mmdet3d/models/detectors/base.py
View file @
b2c43ffd
...
@@ -7,15 +7,16 @@ class Base3DDetector(BaseDetector):
...
@@ -7,15 +7,16 @@ class Base3DDetector(BaseDetector):
def
forward_test
(
self
,
points
,
img_metas
,
img
=
None
,
**
kwargs
):
def
forward_test
(
self
,
points
,
img_metas
,
img
=
None
,
**
kwargs
):
"""
"""
Args:
Args:
points (
L
ist[Tensor]): the outer list indicates test-time
points (
l
ist[
torch.
Tensor]): the outer list indicates test-time
augmentations and inner Tensor should have a shape NxC,
augmentations and inner
torch.
Tensor should have a shape NxC,
which contains all points in the batch.
which contains all points in the batch.
img_metas (
L
ist[
L
ist[dict]]): the outer list indicates test-time
img_metas (
l
ist[
l
ist[dict]]): the outer list indicates test-time
augs (multiscale, flip, etc.) and the inner list indicates
augs (multiscale, flip, etc.) and the inner list indicates
images in a batch
images in a batch
img (List[Tensor], optional): the outer list indicates test-time
img (list[torch.Tensor], optional): the outer
augmentations and inner Tensor should have a shape NxCxHxW,
list indicates test-time augmentations and inner
which contains all images in the batch. Defaults to None.
torch.Tensor should have a shape NxCxHxW, which contains
all images in the batch. Defaults to None.
"""
"""
for
var
,
name
in
[(
points
,
'points'
),
(
img_metas
,
'img_metas'
)]:
for
var
,
name
in
[(
points
,
'points'
),
(
img_metas
,
'img_metas'
)]:
if
not
isinstance
(
var
,
list
):
if
not
isinstance
(
var
,
list
):
...
@@ -42,9 +43,9 @@ class Base3DDetector(BaseDetector):
...
@@ -42,9 +43,9 @@ class Base3DDetector(BaseDetector):
Calls either forward_train or forward_test depending on whether
Calls either forward_train or forward_test depending on whether
return_loss=True. Note this setting will change the expected inputs.
return_loss=True. Note this setting will change the expected inputs.
When `return_loss=True`, img and img_metas are single-nested (i.e.
When `return_loss=True`, img and img_metas are single-nested (i.e.
Tensor and
L
ist[dict]), and when `resturn_loss=False`, img and
torch.
Tensor and
l
ist[dict]), and when `resturn_loss=False`, img and
img_metas should be double nested
img_metas should be double nested
(i.e.
L
ist[Tensor],
L
ist[
L
ist[dict]]), with the outer list
(i.e.
l
ist[
torch.
Tensor],
l
ist[
l
ist[dict]]), with the outer list
indicating test time augmentations.
indicating test time augmentations.
"""
"""
if
return_loss
:
if
return_loss
:
...
...
mmdet3d/models/detectors/single_stage.py
View file @
b2c43ffd
...
@@ -52,7 +52,10 @@ class SingleStage3DDetector(Base3DDetector):
...
@@ -52,7 +52,10 @@ class SingleStage3DDetector(Base3DDetector):
self
.
bbox_head
.
init_weights
()
self
.
bbox_head
.
init_weights
()
def
extract_feat
(
self
,
points
,
img_metas
=
None
):
def
extract_feat
(
self
,
points
,
img_metas
=
None
):
"""Directly extract features from the backbone+neck
"""Directly extract features from the backbone+neck.
Args:
points (torch.Tensor): Input points.
"""
"""
x
=
self
.
backbone
(
points
)
x
=
self
.
backbone
(
points
)
if
self
.
with_neck
:
if
self
.
with_neck
:
...
...
mmdet3d/models/detectors/votenet.py
View file @
b2c43ffd
...
@@ -36,15 +36,16 @@ class VoteNet(SingleStage3DDetector):
...
@@ -36,15 +36,16 @@ class VoteNet(SingleStage3DDetector):
"""Forward of training.
"""Forward of training.
Args:
Args:
points (list[Tensor]): Points of each batch.
points (list[
torch.
Tensor]): Points of each batch.
img_metas (list): Image metas.
img_metas (list): Image metas.
gt_bboxes_3d (:obj:BaseInstance3DBoxes): gt bboxes of each batch.
gt_bboxes_3d (:obj:BaseInstance3DBoxes): gt bboxes of each batch.
gt_labels_3d (list[Tensor]): gt class labels of each batch.
gt_labels_3d (list[
torch.
Tensor]): gt class labels of each batch.
pts_semantic_mask (None | list[Tensor]): point-wise semantic
pts_semantic_mask (None | list[
torch.
Tensor]): point-wise semantic
label of each batch.
label of each batch.
pts_instance_mask (None | list[Tensor]): point-wise instance
pts_instance_mask (None | list[
torch.
Tensor]): point-wise instance
label of each batch.
label of each batch.
gt_bboxes_ignore (None | list[Tensor]): Specify which bounding.
gt_bboxes_ignore (None | list[torch.Tensor]): Specify
which bounding.
Returns:
Returns:
dict: Losses.
dict: Losses.
...
@@ -63,7 +64,7 @@ class VoteNet(SingleStage3DDetector):
...
@@ -63,7 +64,7 @@ class VoteNet(SingleStage3DDetector):
"""Forward of testing.
"""Forward of testing.
Args:
Args:
points (list[Tensor]): Points of each sample.
points (list[
torch.
Tensor]): Points of each sample.
img_metas (list): Image metas.
img_metas (list): Image metas.
rescale (bool): Whether to rescale results.
rescale (bool): Whether to rescale results.
...
...
tools/data_converter/create_gt_database.py
View file @
b2c43ffd
...
@@ -120,6 +120,27 @@ def create_groundtruth_database(dataset_class_name,
...
@@ -120,6 +120,27 @@ def create_groundtruth_database(dataset_class_name,
bev_only
=
False
,
bev_only
=
False
,
coors_range
=
None
,
coors_range
=
None
,
with_mask
=
False
):
with_mask
=
False
):
"""Given the raw data, generate the ground truth database.
Args:
dataset_class_name (str): Name of the input dataset.
data_path (str): Path of the data.
info_prefix (str): Prefix of the info file.
info_path (str): Path of the info file.
Default: None.
mask_anno_path (str): Path of the mask_anno.
Default: None.
used_classes (list[str]): Classes have been used.
Default: None.
database_save_path (str): Path to save database.
Default: None.
db_info_save_path (str): Path to save db_info.
Default: None.
relative_path (bool): Whether to use relative path.
Default: True.
with_mask (bool): Whether to use mask.
Default: False.
"""
print
(
f
'Create GT Database of
{
dataset_class_name
}
'
)
print
(
f
'Create GT Database of
{
dataset_class_name
}
'
)
dataset_cfg
=
dict
(
dataset_cfg
=
dict
(
type
=
dataset_class_name
,
type
=
dataset_class_name
,
...
...
tools/data_converter/kitti_converter.py
View file @
b2c43ffd
...
@@ -10,6 +10,9 @@ from .kitti_data_utils import get_kitti_image_info
...
@@ -10,6 +10,9 @@ from .kitti_data_utils import get_kitti_image_info
def
convert_to_kitti_info_version2
(
info
):
def
convert_to_kitti_info_version2
(
info
):
"""convert kitti info v1 to v2 if possible.
"""convert kitti info v1 to v2 if possible.
Args:
info (dict): Info of the input kitti data.
"""
"""
if
'image'
not
in
info
or
'calib'
not
in
info
or
'point_cloud'
not
in
info
:
if
'image'
not
in
info
or
'calib'
not
in
info
or
'point_cloud'
not
in
info
:
info
[
'image'
]
=
{
info
[
'image'
]
=
{
...
@@ -78,6 +81,16 @@ def create_kitti_info_file(data_path,
...
@@ -78,6 +81,16 @@ def create_kitti_info_file(data_path,
pkl_prefix
=
'kitti_'
,
pkl_prefix
=
'kitti_'
,
save_path
=
None
,
save_path
=
None
,
relative_path
=
True
):
relative_path
=
True
):
"""Create info file of KITTI dataset.
Given the raw data, generate its related info file in pkl format.
Args:
data_path (str): Path of the data root.
pkl_prefix (str): Prefix of the info file to be generated.
save_path (str): Path to save the info file.
relative_path (bool): Whether to use relative path.
"""
imageset_folder
=
Path
(
data_path
)
/
'ImageSets'
imageset_folder
=
Path
(
data_path
)
/
'ImageSets'
train_img_ids
=
_read_imageset_file
(
train_img_ids
=
_read_imageset_file
(
str
(
imageset_folder
/
'train_6014.txt'
))
str
(
imageset_folder
/
'train_6014.txt'
))
...
...
tools/data_converter/nuscenes_converter.py
View file @
b2c43ffd
...
@@ -20,6 +20,18 @@ def create_nuscenes_infos(root_path,
...
@@ -20,6 +20,18 @@ def create_nuscenes_infos(root_path,
info_prefix
,
info_prefix
,
version
=
'v1.0-trainval'
,
version
=
'v1.0-trainval'
,
max_sweeps
=
10
):
max_sweeps
=
10
):
"""Create info file of nuscene dataset.
Given the raw data, generate its related info file in pkl format.
Args:
root_path (str): Path of the data root.
info_prefix (str): Prefix of the info file to be generated.
version (str): Version of the data.
Default: 'v1.0-trainval'
max_sweeps (int): Max number of sweeps.
Default: 10
"""
from
nuscenes.nuscenes
import
NuScenes
from
nuscenes.nuscenes
import
NuScenes
nusc
=
NuScenes
(
version
=
version
,
dataroot
=
root_path
,
verbose
=
True
)
nusc
=
NuScenes
(
version
=
version
,
dataroot
=
root_path
,
verbose
=
True
)
from
nuscenes.utils
import
splits
from
nuscenes.utils
import
splits
...
...
Prev
1
2
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