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
3c1eb23f
Commit
3c1eb23f
authored
Jul 09, 2020
by
zhangwenwei
Browse files
Merge branch 'update_docstrings' into 'master'
Refine docstrings See merge request open-mmlab/mmdet.3d!142
parents
cfc3f545
21cb2aa6
Changes
39
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
211 additions
and
194 deletions
+211
-194
mmdet3d/core/anchor/anchor_3d_generator.py
mmdet3d/core/anchor/anchor_3d_generator.py
+8
-8
mmdet3d/core/bbox/box_np_ops.py
mmdet3d/core/bbox/box_np_ops.py
+45
-34
mmdet3d/core/bbox/coders/delta_xyzwhlr_bbox_coder.py
mmdet3d/core/bbox/coders/delta_xyzwhlr_bbox_coder.py
+1
-1
mmdet3d/core/bbox/coders/partial_bin_based_bbox_coder.py
mmdet3d/core/bbox/coders/partial_bin_based_bbox_coder.py
+10
-8
mmdet3d/core/bbox/iou_calculators/iou3d_calculator.py
mmdet3d/core/bbox/iou_calculators/iou3d_calculator.py
+5
-5
mmdet3d/core/bbox/samplers/iou_neg_piecewise_sampler.py
mmdet3d/core/bbox/samplers/iou_neg_piecewise_sampler.py
+11
-10
mmdet3d/core/bbox/structures/base_box3d.py
mmdet3d/core/bbox/structures/base_box3d.py
+19
-19
mmdet3d/core/bbox/structures/cam_box3d.py
mmdet3d/core/bbox/structures/cam_box3d.py
+1
-2
mmdet3d/core/bbox/structures/depth_box3d.py
mmdet3d/core/bbox/structures/depth_box3d.py
+3
-3
mmdet3d/core/bbox/structures/lidar_box3d.py
mmdet3d/core/bbox/structures/lidar_box3d.py
+3
-3
mmdet3d/core/bbox/structures/utils.py
mmdet3d/core/bbox/structures/utils.py
+3
-3
mmdet3d/core/bbox/transforms.py
mmdet3d/core/bbox/transforms.py
+4
-4
mmdet3d/core/evaluation/indoor_eval.py
mmdet3d/core/evaluation/indoor_eval.py
+14
-11
mmdet3d/core/evaluation/lyft_eval.py
mmdet3d/core/evaluation/lyft_eval.py
+4
-3
mmdet3d/core/post_processing/merge_augs.py
mmdet3d/core/post_processing/merge_augs.py
+8
-8
mmdet3d/core/voxel/voxel_generator.py
mmdet3d/core/voxel/voxel_generator.py
+27
-27
mmdet3d/datasets/custom_3d.py
mmdet3d/datasets/custom_3d.py
+17
-17
mmdet3d/datasets/kitti2d_dataset.py
mmdet3d/datasets/kitti2d_dataset.py
+3
-3
mmdet3d/datasets/kitti_dataset.py
mmdet3d/datasets/kitti_dataset.py
+17
-17
mmdet3d/datasets/lyft_dataset.py
mmdet3d/datasets/lyft_dataset.py
+8
-8
No files found.
mmdet3d/core/anchor/anchor_3d_generator.py
View file @
3c1eb23f
...
@@ -20,10 +20,10 @@ class Anchor3DRangeGenerator(object):
...
@@ -20,10 +20,10 @@ class Anchor3DRangeGenerator(object):
vary for different anchor sizes if size_per_range is True.
vary for different anchor sizes if size_per_range is True.
sizes (list[list[float]]): 3D sizes of anchors.
sizes (list[list[float]]): 3D sizes of anchors.
scales (list[int]): Scales of anchors in different feature levels.
scales (list[int]): Scales of anchors in different feature levels.
rotations (list
(
float
)
): Rotations of anchors in a feature grid.
rotations (list
[
float
]
): Rotations of anchors in a feature grid.
custom_values (tuple
(
float
)
): Customized values of that anchor. For
custom_values (tuple
[
float
]
): Customized values of that anchor. For
example, in nuScenes the anchors have velocities.
example, in nuScenes the anchors have velocities.
reshape_out (bool): Whether to reshape the output into (N
x
4)
reshape_out (bool): Whether to reshape the output into (N
x
4)
.
size_per_range: Whether to use separate ranges for different sizes.
size_per_range: Whether to use separate ranges for different sizes.
If size_per_range is True, the ranges should have the same length
If size_per_range is True, the ranges should have the same length
as the sizes, if not, it will be duplicated.
as the sizes, if not, it will be duplicated.
...
@@ -69,14 +69,14 @@ class Anchor3DRangeGenerator(object):
...
@@ -69,14 +69,14 @@ class Anchor3DRangeGenerator(object):
@
property
@
property
def
num_base_anchors
(
self
):
def
num_base_anchors
(
self
):
"""list[int]:
t
otal number of base anchors in a feature grid"""
"""list[int]:
T
otal number of base anchors in a feature grid
.
"""
num_rot
=
len
(
self
.
rotations
)
num_rot
=
len
(
self
.
rotations
)
num_size
=
torch
.
tensor
(
self
.
sizes
).
reshape
(
-
1
,
3
).
size
(
0
)
num_size
=
torch
.
tensor
(
self
.
sizes
).
reshape
(
-
1
,
3
).
size
(
0
)
return
num_rot
*
num_size
return
num_rot
*
num_size
@
property
@
property
def
num_levels
(
self
):
def
num_levels
(
self
):
"""int:
n
umber of feature levels that the generator
will be
applied"""
"""int:
N
umber of feature levels that the generator
is
applied
.
"""
return
len
(
self
.
scales
)
return
len
(
self
.
scales
)
def
grid_anchors
(
self
,
featmap_sizes
,
device
=
'cuda'
):
def
grid_anchors
(
self
,
featmap_sizes
,
device
=
'cuda'
):
...
@@ -168,7 +168,7 @@ class Anchor3DRangeGenerator(object):
...
@@ -168,7 +168,7 @@ class Anchor3DRangeGenerator(object):
device (str): Devices that the anchors will be put on.
device (str): Devices that the anchors will be put on.
Returns:
Returns:
torch.Tensor:
a
nchors with shape
\
torch.Tensor:
A
nchors with shape
\
[*feature_size, num_sizes, num_rots, 7].
[*feature_size, num_sizes, num_rots, 7].
"""
"""
if
len
(
feature_size
)
==
2
:
if
len
(
feature_size
)
==
2
:
...
@@ -226,7 +226,7 @@ class AlignedAnchor3DRangeGenerator(Anchor3DRangeGenerator):
...
@@ -226,7 +226,7 @@ class AlignedAnchor3DRangeGenerator(Anchor3DRangeGenerator):
according to the feature map sizes.
according to the feature map sizes.
However, this makes the anchors center does not match the feature grid.
However, this makes the anchors center does not match the feature grid.
The AlignedAnchor3DRangeGenerator add + 1 when using the feature map sizes
The AlignedAnchor3DRangeGenerator add + 1 when using the feature map sizes
to obtain the corners of the voxel grid. Then it shift the coordinates to
to obtain the corners of the voxel grid. Then it shift
s
the coordinates to
the center of voxel grid of use the left up corner to distribute anchors.
the center of voxel grid of use the left up corner to distribute anchors.
Args:
Args:
...
@@ -263,7 +263,7 @@ class AlignedAnchor3DRangeGenerator(Anchor3DRangeGenerator):
...
@@ -263,7 +263,7 @@ class AlignedAnchor3DRangeGenerator(Anchor3DRangeGenerator):
device (str): Devices that the anchors will be put on.
device (str): Devices that the anchors will be put on.
Returns:
Returns:
torch.Tensor:
a
nchors with shape
\
torch.Tensor:
A
nchors with shape
\
[*feature_size, num_sizes, num_rots, 7].
[*feature_size, num_sizes, num_rots, 7].
"""
"""
if
len
(
feature_size
)
==
2
:
if
len
(
feature_size
)
==
2
:
...
...
mmdet3d/core/bbox/box_np_ops.py
View file @
3c1eb23f
...
@@ -58,8 +58,9 @@ def rotation_2d(points, angles):
...
@@ -58,8 +58,9 @@ def rotation_2d(points, angles):
"""Rotation 2d points based on origin point clockwise when angle positive.
"""Rotation 2d points based on origin point clockwise when angle positive.
Args:
Args:
points (np.ndarray, shape=[N, point_size, 2]): points to be rotated.
points (np.ndarray): Points to be rotated with shape
\
angles (np.ndarray, shape=[N]): rotation angle.
(N, point_size, 2).
angles (np.ndarray): Rotation angle with shape (N).
Returns:
Returns:
np.ndarray: Same shape as points.
np.ndarray: Same shape as points.
...
@@ -75,12 +76,12 @@ def center_to_corner_box2d(centers, dims, angles=None, origin=0.5):
...
@@ -75,12 +76,12 @@ def center_to_corner_box2d(centers, dims, angles=None, origin=0.5):
format: center(xy), dims(xy), angles(clockwise when positive)
format: center(xy), dims(xy), angles(clockwise when positive)
Args:
Args:
centers (np.ndarray
, shape=[N, 2]
):
l
ocations in kitti label file.
centers (np.ndarray):
L
ocations in kitti label file
with shape (N, 2)
.
dims (np.ndarray
, shape=[N, 2]
):
d
imensions in kitti label file.
dims (np.ndarray):
D
imensions in kitti label file
with shape (N, 2)
.
angles (np.ndarray
, shape=[N]
):
r
otation_y in kitti label file.
angles (np.ndarray):
R
otation_y in kitti label file
with shape (N)
.
Returns:
Returns:
np.ndarray: Corners with the shape of
[
N, 4, 2
]
.
np.ndarray: Corners with the shape of
(
N, 4, 2
)
.
"""
"""
# 'length' in kitti format is in x axis.
# 'length' in kitti format is in x axis.
# xyz(hwl)(kitti label file)<->xyz(lhw)(camera)<->z(-x)(-y)(wlh)(lidar)
# xyz(hwl)(kitti label file)<->xyz(lhw)(camera)<->z(-x)(-y)(wlh)(lidar)
...
@@ -146,15 +147,15 @@ def center_to_corner_box3d(centers,
...
@@ -146,15 +147,15 @@ def center_to_corner_box3d(centers,
"""Convert kitti locations, dimensions and angles to corners.
"""Convert kitti locations, dimensions and angles to corners.
Args:
Args:
centers (np.ndarray
, shape=[N, 3]
): Locations in kitti label file.
centers (np.ndarray): Locations in kitti label file
with shape (N, 3)
.
dims (np.ndarray
, shape=[N, 3]
): Dimensions in kitti label file.
dims (np.ndarray): Dimensions in kitti label file
with shape (N, 3)
.
angles (np.ndarray
, shape=[N]
): Rotation_y in kitti label file.
angles (np.ndarray): Rotation_y in kitti label file
with shape (N)
.
origin (list or array or float): Origin point relate to smallest point.
origin (list or array or float): Origin point relate to smallest point.
use (0.5, 1.0, 0.5) in camera and (0.5, 0.5, 0) in lidar.
use (0.5, 1.0, 0.5) in camera and (0.5, 0.5, 0) in lidar.
axis (int): Rotation axis. 1 for camera and 2 for lidar.
axis (int): Rotation axis. 1 for camera and 2 for lidar.
Returns:
Returns:
np.ndarray: Corners with the shape of
[
N, 8, 3
]
.
np.ndarray: Corners with the shape of
(
N, 8, 3
)
.
"""
"""
# 'length' in kitti format is in x axis.
# 'length' in kitti format is in x axis.
# yzx(hwl)(kitti label file)<->xyz(lhw)(camera)<->z(-x)(-y)(wlh)(lidar)
# yzx(hwl)(kitti label file)<->xyz(lhw)(camera)<->z(-x)(-y)(wlh)(lidar)
...
@@ -209,11 +210,10 @@ def corner_to_surfaces_3d_jit(corners):
...
@@ -209,11 +210,10 @@ def corner_to_surfaces_3d_jit(corners):
normal vectors all direct to internal.
normal vectors all direct to internal.
Args:
Args:
corners (np.ndarray, [N, 8, 3]): 3d box corners
corners (np.ndarray): 3d box corners with the shape of (N, 8, 3).
with the shape of [N, 8, 3].
Returns:
Returns:
np.ndarray: Surfaces with the shape of
[
N, 6, 4, 3
]
.
np.ndarray: Surfaces with the shape of
(
N, 6, 4, 3
)
.
"""
"""
# box_corners: [N, 8, 3], must from corner functions in this module
# box_corners: [N, 8, 3], must from corner functions in this module
num_boxes
=
corners
.
shape
[
0
]
num_boxes
=
corners
.
shape
[
0
]
...
@@ -275,10 +275,10 @@ def corner_to_surfaces_3d(corners):
...
@@ -275,10 +275,10 @@ def corner_to_surfaces_3d(corners):
normal vectors all direct to internal.
normal vectors all direct to internal.
Args:
Args:
corners (np.ndarray
, [N, 8, 3]
): 3
d
box corners.
corners (np.ndarray): 3
D
box corners
with shape of (N, 8, 3)
.
Returns:
Returns:
np.ndarray: Surfaces with the shape of
[
N, 6, 4, 3
]
.
np.ndarray: Surfaces with the shape of
(
N, 6, 4, 3
)
.
"""
"""
# box_corners: [N, 8, 3], must from corner functions in this module
# box_corners: [N, 8, 3], must from corner functions in this module
surfaces
=
np
.
array
([
surfaces
=
np
.
array
([
...
@@ -320,11 +320,20 @@ def create_anchors_3d_range(feature_size,
...
@@ -320,11 +320,20 @@ def create_anchors_3d_range(feature_size,
dtype
=
np
.
float32
):
dtype
=
np
.
float32
):
"""
"""
Args:
Args:
feature_size: list [D, H, W](zyx)
feature_size (list[float] | tuple[float]): Feature map size. It is
sizes: [N, 3] list of list or array, size of anchors, xyz
either a list of a tuple of [D, H, W](in order of z, y, and x).
anchor_range (torch.Tensor | list[float]): Range of anchors with
shape [6]. The order is consistent with that of anchors, i.e.,
(x_min, y_min, z_min, x_max, y_max, z_max).
sizes (list[list] | np.ndarray | torch.Tensor): Anchor size with
shape [N, 3], in order of x, y, z.
rotations (list[float] | np.ndarray | torch.Tensor): Rotations of
anchors in a single feature grid.
dtype (type): Data type. Default to np.float32.
Returns:
Returns:
np.ndarray: [*feature_size, num_sizes, num_rots, 7].
np.ndarray: Range based anchors with shape of
\
(*feature_size, num_sizes, num_rots, 7).
"""
"""
anchor_range
=
np
.
array
(
anchor_range
,
dtype
)
anchor_range
=
np
.
array
(
anchor_range
,
dtype
)
z_centers
=
np
.
linspace
(
z_centers
=
np
.
linspace
(
...
@@ -366,11 +375,12 @@ def rbbox2d_to_near_bbox(rbboxes):
...
@@ -366,11 +375,12 @@ def rbbox2d_to_near_bbox(rbboxes):
"""convert rotated bbox to nearest 'standing' or 'lying' bbox.
"""convert rotated bbox to nearest 'standing' or 'lying' bbox.
Args:
Args:
rbboxes (np.ndarray): [N, 5(x, y, xdim, ydim, rad)] rotated bboxes.
rbboxes (np.ndarray): Rotated bboxes with shape of
\
(N, 5(x, y, xdim, ydim, rad)).
Returns:
Returns:
np.ndarray: Bboxes with the shpae of
np.ndarray: B
ounding
boxes with the shpae of
[
N, 4(xmin, ymin, xmax, ymax)
]
.
(
N, 4(xmin, ymin, xmax, ymax)
)
.
"""
"""
rots
=
rbboxes
[...,
-
1
]
rots
=
rbboxes
[...,
-
1
]
rots_0_pi_div_2
=
np
.
abs
(
limit_period
(
rots
,
0.5
,
np
.
pi
))
rots_0_pi_div_2
=
np
.
abs
(
limit_period
(
rots
,
0.5
,
np
.
pi
))
...
@@ -382,12 +392,12 @@ def rbbox2d_to_near_bbox(rbboxes):
...
@@ -382,12 +392,12 @@ def rbbox2d_to_near_bbox(rbboxes):
@
numba
.
jit
(
nopython
=
True
)
@
numba
.
jit
(
nopython
=
True
)
def
iou_jit
(
boxes
,
query_boxes
,
mode
=
'iou'
,
eps
=
0.0
):
def
iou_jit
(
boxes
,
query_boxes
,
mode
=
'iou'
,
eps
=
0.0
):
"""Calculate box iou.
n
ote that jit version runs ~10x faster than the
"""Calculate box iou.
N
ote that jit version runs ~10x faster than the
box_overlaps function in mmdet3d.core.evaluation.
box_overlaps function in mmdet3d.core.evaluation.
Args:
Args:
boxes (np.ndarray):
(N, 4) ndarray of float
boxes (np.ndarray):
Input bounding boxes with shape of (N, 4).
query_boxes (np.ndarray):
(K, 4) ndarray of float
query_boxes (np.ndarray):
Query boxes with shape of (K, 4).
Returns:
Returns:
np.ndarray: Overlap between boxes and query_boxes
np.ndarray: Overlap between boxes and query_boxes
...
@@ -515,13 +525,13 @@ def points_in_convex_polygon_3d_jit(points,
...
@@ -515,13 +525,13 @@ def points_in_convex_polygon_3d_jit(points,
"""Check points is in 3d convex polygons.
"""Check points is in 3d convex polygons.
Args:
Args:
points (np.ndarray):
[
num_points, 3
] array
.
points (np.ndarray):
Input points with shape of (
num_points, 3
)
.
polygon_surfaces (np.ndarray):
[num_polygon, max_num_surfaces,
polygon_surfaces (np.ndarray):
Polygon surfaces with shape of
\
max_num_points_of_surface, 3
]
(num_polygon, max_num_surfaces,
max_num_points_of_surface, 3
).
\
array. a
ll surfaces' normal vector must direct to internal.
A
ll surfaces' normal vector must direct to internal.
\
m
ax_num_points_of_surface must at least 3.
M
ax_num_points_of_surface must at least 3.
num_surfaces (np.ndarray):
[num_polygon] array.
num_surfaces (np.ndarray):
Number of surfaces a polygon contains
\
indicate how many surfaces a polygon contain
shape of (num_polygon).
Returns:
Returns:
np.ndarray: Result matrix with the shape of [num_points, num_polygon].
np.ndarray: Result matrix with the shape of [num_points, num_polygon].
...
@@ -595,9 +605,10 @@ def boxes3d_to_corners3d_lidar(boxes3d, bottom_center=True):
...
@@ -595,9 +605,10 @@ def boxes3d_to_corners3d_lidar(boxes3d, bottom_center=True):
2 -------- 1
2 -------- 1
Args:
Args:
boxes3d (np.ndarray): (N, 7) [x, y, z, w, l, h, ry] in LiDAR coords,
boxes3d (np.ndarray): Boxes with shape of (N, 7)
\
see the definition of ry in KITTI dataset
[x, y, z, w, l, h, ry] in LiDAR coords, see the definition of ry
\
bottom_center (bool): whether z is on the bottom center of object.
in KITTI dataset.
bottom_center (bool): Whether z is on the bottom center of object.
Returns:
Returns:
np.ndarray: Box corners with the shape of [N, 8, 3].
np.ndarray: Box corners with the shape of [N, 8, 3].
...
...
mmdet3d/core/bbox/coders/delta_xyzwhlr_bbox_coder.py
View file @
3c1eb23f
...
@@ -28,7 +28,7 @@ class DeltaXYZWLHRBBoxCoder(BaseBBoxCoder):
...
@@ -28,7 +28,7 @@ class DeltaXYZWLHRBBoxCoder(BaseBBoxCoder):
ground-truth boxes.
ground-truth boxes.
Returns:
Returns:
torch.Tensor: Box transformation deltas
torch.Tensor: Box transformation deltas
.
"""
"""
box_ndim
=
src_boxes
.
shape
[
-
1
]
box_ndim
=
src_boxes
.
shape
[
-
1
]
cas
,
cgs
,
cts
=
[],
[],
[]
cas
,
cgs
,
cts
=
[],
[],
[]
...
...
mmdet3d/core/bbox/coders/partial_bin_based_bbox_coder.py
View file @
3c1eb23f
...
@@ -28,8 +28,9 @@ class PartialBinBasedBBoxCoder(BaseBBoxCoder):
...
@@ -28,8 +28,9 @@ class PartialBinBasedBBoxCoder(BaseBBoxCoder):
"""Encode ground truth to prediction targets.
"""Encode ground truth to prediction targets.
Args:
Args:
gt_bboxes_3d (BaseInstance3DBoxes): gt bboxes with shape (n, 7).
gt_bboxes_3d (BaseInstance3DBoxes): Ground truth bboxes
\
gt_labels_3d (torch.Tensor): gt classes.
with shape (n, 7).
gt_labels_3d (torch.Tensor): Ground truth classes.
Returns:
Returns:
tuple: Targets of center, size and direction.
tuple: Targets of center, size and direction.
...
@@ -58,7 +59,8 @@ class PartialBinBasedBBoxCoder(BaseBBoxCoder):
...
@@ -58,7 +59,8 @@ class PartialBinBasedBBoxCoder(BaseBBoxCoder):
"""Decode predicted parts to bbox3d.
"""Decode predicted parts to bbox3d.
Args:
Args:
bbox_out (dict): predictions from model, should contain keys below
bbox_out (dict): Predictions from model, should contain keys below.
- center: predicted bottom center of bboxes.
- center: predicted bottom center of bboxes.
- dir_class: predicted bbox direction class.
- dir_class: predicted bbox direction class.
- dir_res: predicted bbox direction residual.
- dir_res: predicted bbox direction residual.
...
@@ -66,7 +68,7 @@ class PartialBinBasedBBoxCoder(BaseBBoxCoder):
...
@@ -66,7 +68,7 @@ class PartialBinBasedBBoxCoder(BaseBBoxCoder):
- size_res: predicted bbox size residual.
- size_res: predicted bbox size residual.
Returns:
Returns:
torch.Tensor:
d
ecoded bbox3d with shape (batch, n, 7)
torch.Tensor:
D
ecoded bbox3d with shape (batch, n, 7)
.
"""
"""
center
=
bbox_out
[
'center'
]
center
=
bbox_out
[
'center'
]
batch_size
,
num_proposal
=
center
.
shape
[:
2
]
batch_size
,
num_proposal
=
center
.
shape
[:
2
]
...
@@ -98,11 +100,11 @@ class PartialBinBasedBBoxCoder(BaseBBoxCoder):
...
@@ -98,11 +100,11 @@ class PartialBinBasedBBoxCoder(BaseBBoxCoder):
"""Split predicted features to specific parts.
"""Split predicted features to specific parts.
Args:
Args:
preds (torch.Tensor):
p
redicted features to split.
preds (torch.Tensor):
P
redicted features to split.
base_xyz (torch.Tensor):
c
oordinates of points.
base_xyz (torch.Tensor):
C
oordinates of points.
Returns:
Returns:
dict[str, torch.Tensor]:
s
plit results.
dict[str, torch.Tensor]:
S
plit results.
"""
"""
results
=
{}
results
=
{}
start
,
end
=
0
,
0
start
,
end
=
0
,
0
...
@@ -183,7 +185,7 @@ class PartialBinBasedBBoxCoder(BaseBBoxCoder):
...
@@ -183,7 +185,7 @@ class PartialBinBasedBBoxCoder(BaseBBoxCoder):
limit_period (bool): Whether to limit angle to [-pi, pi].
limit_period (bool): Whether to limit angle to [-pi, pi].
Returns:
Returns:
torch.Tensor:
a
ngle decoded from angle_cls and angle_res.
torch.Tensor:
A
ngle decoded from angle_cls and angle_res.
"""
"""
angle_per_class
=
2
*
np
.
pi
/
float
(
self
.
num_dir_bins
)
angle_per_class
=
2
*
np
.
pi
/
float
(
self
.
num_dir_bins
)
angle_center
=
angle_cls
.
float
()
*
angle_per_class
angle_center
=
angle_cls
.
float
()
*
angle_per_class
...
...
mmdet3d/core/bbox/iou_calculators/iou3d_calculator.py
View file @
3c1eb23f
...
@@ -12,7 +12,7 @@ class BboxOverlapsNearest3D(object):
...
@@ -12,7 +12,7 @@ class BboxOverlapsNearest3D(object):
(BEV), and then calculate the 2D IoU using :meth:`bbox_overlaps`.
(BEV), and then calculate the 2D IoU using :meth:`bbox_overlaps`.
Args:
Args:
coordinate (str): 'camera', 'lidar', or 'depth' coordinate system
coordinate (str): 'camera', 'lidar', or 'depth' coordinate system
.
"""
"""
def
__init__
(
self
,
coordinate
=
'lidar'
):
def
__init__
(
self
,
coordinate
=
'lidar'
):
...
@@ -32,7 +32,7 @@ class BboxOverlapsNearest3D(object):
...
@@ -32,7 +32,7 @@ class BboxOverlapsNearest3D(object):
bboxes2 (torch.Tensor): shape (M, 7+N) [x, y, z, h, w, l, ry, v].
bboxes2 (torch.Tensor): shape (M, 7+N) [x, y, z, h, w, l, ry, v].
mode (str): "iou" (intersection over union) or iof
mode (str): "iou" (intersection over union) or iof
(intersection over foreground).
(intersection over foreground).
is_aligned (bool): Whether the calculation is aligned
is_aligned (bool): Whether the calculation is aligned
.
Return:
Return:
torch.Tensor: If ``is_aligned`` is ``True``, return ious between
\
torch.Tensor: If ``is_aligned`` is ``True``, return ious between
\
...
@@ -43,7 +43,7 @@ class BboxOverlapsNearest3D(object):
...
@@ -43,7 +43,7 @@ class BboxOverlapsNearest3D(object):
self
.
coordinate
)
self
.
coordinate
)
def
__repr__
(
self
):
def
__repr__
(
self
):
"""str:
r
eturn a string that describes the module"""
"""str:
R
eturn a string that describes the module
.
"""
repr_str
=
self
.
__class__
.
__name__
repr_str
=
self
.
__class__
.
__name__
repr_str
+=
f
'(coordinate=
{
self
.
coordinate
}
'
repr_str
+=
f
'(coordinate=
{
self
.
coordinate
}
'
return
repr_str
return
repr_str
...
@@ -98,8 +98,8 @@ def bbox_overlaps_nearest_3d(bboxes1,
...
@@ -98,8 +98,8 @@ def bbox_overlaps_nearest_3d(bboxes1,
Note:
Note:
This function first finds the nearest 2D boxes in bird eye view
This function first finds the nearest 2D boxes in bird eye view
(BEV), and then calculate the 2D IoU using
``
:meth:bbox_overlaps`
`
.
(BEV), and then calculate
s
the 2D IoU using :meth:
`
bbox_overlaps`.
Ths IoU calculator
``
:class:BboxOverlapsNearest3D`
`
uses this
Ths IoU calculator :class:
`
BboxOverlapsNearest3D` uses this
function to calculate IoUs of boxes.
function to calculate IoUs of boxes.
If ``is_aligned`` is ``False``, then it calculates the ious between
If ``is_aligned`` is ``False``, then it calculates the ious between
...
...
mmdet3d/core/bbox/samplers/iou_neg_piecewise_sampler.py
View file @
3c1eb23f
...
@@ -14,15 +14,15 @@ class IoUNegPiecewiseSampler(RandomSampler):
...
@@ -14,15 +14,15 @@ class IoUNegPiecewiseSampler(RandomSampler):
by `neg_piece_fractions`.
by `neg_piece_fractions`.
Args:
Args:
num (int):
n
umber of proposals.
num (int):
N
umber of proposals.
pos_fraction (float):
t
he fraction of positive proposals.
pos_fraction (float):
T
he fraction of positive proposals.
neg_piece_fractions (list):
a
list contains fractions that indicates
neg_piece_fractions (list):
A
list contains fractions that indicates
the ratio of each piece of total negtive samplers.
the ratio of each piece of total negtive samplers.
neg_iou_piece_thrs (list):
a
list contains IoU thresholds that
neg_iou_piece_thrs (list):
A
list contains IoU thresholds that
indicate the upper bound of this piece.
indicate the upper bound of this piece.
neg_pos_ub (float):
t
he total ratio to limit the upper bound
neg_pos_ub (float):
T
he total ratio to limit the upper bound
number of negtive samples
number of negtive samples
.
add_gt_as_proposals (bool):
w
hether to add gt as proposals.
add_gt_as_proposals (bool):
W
hether to add gt as proposals.
"""
"""
def
__init__
(
self
,
def
__init__
(
self
,
...
@@ -107,9 +107,10 @@ class IoUNegPiecewiseSampler(RandomSampler):
...
@@ -107,9 +107,10 @@ class IoUNegPiecewiseSampler(RandomSampler):
Args:
Args:
assign_result (:obj:`AssignResult`): Bbox assigning results.
assign_result (:obj:`AssignResult`): Bbox assigning results.
bboxes (Tensor): Boxes to be sampled from.
bboxes (torch.Tensor): Boxes to be sampled from.
gt_bboxes (Tensor): Ground truth bboxes.
gt_bboxes (torch.Tensor): Ground truth bboxes.
gt_labels (Tensor, optional): Class labels of ground truth bboxes.
gt_labels (torch.Tensor, optional): Class labels of ground truth
\
bboxes.
Returns:
Returns:
:obj:`SamplingResult`: Sampling result.
:obj:`SamplingResult`: Sampling result.
...
...
mmdet3d/core/bbox/structures/base_box3d.py
View file @
3c1eb23f
...
@@ -15,7 +15,7 @@ class BaseInstance3DBoxes(object):
...
@@ -15,7 +15,7 @@ class BaseInstance3DBoxes(object):
Args:
Args:
tensor (torch.Tensor | np.ndarray | list): a N x box_dim matrix.
tensor (torch.Tensor | np.ndarray | list): a N x box_dim matrix.
box_dim (int):
n
umber of the dimension of a box
box_dim (int):
N
umber of the dimension of a box
Each row is (x, y, z, x_size, y_size, z_size, yaw).
Each row is (x, y, z, x_size, y_size, z_size, yaw).
Default to 7.
Default to 7.
with_yaw (bool): Whether the box is with yaw rotation.
with_yaw (bool): Whether the box is with yaw rotation.
...
@@ -59,10 +59,10 @@ class BaseInstance3DBoxes(object):
...
@@ -59,10 +59,10 @@ class BaseInstance3DBoxes(object):
@
property
@
property
def
volume
(
self
):
def
volume
(
self
):
"""Compute
s
the volume of all the boxes.
"""Compute the volume of all the boxes.
Returns:
Returns:
torch.Tensor:
a
vector with volume of each box.
torch.Tensor:
A
vector with volume of each box.
"""
"""
return
self
.
tensor
[:,
3
]
*
self
.
tensor
[:,
4
]
*
self
.
tensor
[:,
5
]
return
self
.
tensor
[:,
3
]
*
self
.
tensor
[:,
4
]
*
self
.
tensor
[:,
5
]
...
@@ -70,10 +70,10 @@ class BaseInstance3DBoxes(object):
...
@@ -70,10 +70,10 @@ class BaseInstance3DBoxes(object):
def
dims
(
self
):
def
dims
(
self
):
"""Calculate the length in each dimension of all the boxes.
"""Calculate the length in each dimension of all the boxes.
Convert the boxes to the form of (x_size, y_size, z_size)
Convert the boxes to the form of (x_size, y_size, z_size)
.
Returns:
Returns:
torch.Tensor:
c
orners of each box with size (N, 8, 3)
torch.Tensor:
C
orners of each box with size (N, 8, 3)
.
"""
"""
return
self
.
tensor
[:,
3
:
6
]
return
self
.
tensor
[:,
3
:
6
]
...
@@ -82,7 +82,7 @@ class BaseInstance3DBoxes(object):
...
@@ -82,7 +82,7 @@ class BaseInstance3DBoxes(object):
"""Obtain the rotation of all the boxes.
"""Obtain the rotation of all the boxes.
Returns:
Returns:
torch.Tensor:
a
vector with yaw of each box.
torch.Tensor:
A
vector with yaw of each box.
"""
"""
return
self
.
tensor
[:,
6
]
return
self
.
tensor
[:,
6
]
...
@@ -91,7 +91,7 @@ class BaseInstance3DBoxes(object):
...
@@ -91,7 +91,7 @@ class BaseInstance3DBoxes(object):
"""Obtain the height of all the boxes.
"""Obtain the height of all the boxes.
Returns:
Returns:
torch.Tensor:
a
vector with height of each box.
torch.Tensor:
A
vector with height of each box.
"""
"""
return
self
.
tensor
[:,
5
]
return
self
.
tensor
[:,
5
]
...
@@ -100,7 +100,7 @@ class BaseInstance3DBoxes(object):
...
@@ -100,7 +100,7 @@ class BaseInstance3DBoxes(object):
"""Obtain the top height of all the boxes.
"""Obtain the top height of all the boxes.
Returns:
Returns:
torch.Tensor:
a
vector with the top height of each box.
torch.Tensor:
A
vector with the top height of each box.
"""
"""
return
self
.
bottom_height
+
self
.
height
return
self
.
bottom_height
+
self
.
height
...
@@ -109,7 +109,7 @@ class BaseInstance3DBoxes(object):
...
@@ -109,7 +109,7 @@ class BaseInstance3DBoxes(object):
"""Obtain the bottom's height of all the boxes.
"""Obtain the bottom's height of all the boxes.
Returns:
Returns:
torch.Tensor:
a
vector with bottom's height of each box.
torch.Tensor:
A
vector with bottom's height of each box.
"""
"""
return
self
.
tensor
[:,
2
]
return
self
.
tensor
[:,
2
]
...
@@ -128,7 +128,7 @@ class BaseInstance3DBoxes(object):
...
@@ -128,7 +128,7 @@ class BaseInstance3DBoxes(object):
for more clear usage.
for more clear usage.
Returns:
Returns:
torch.Tensor:
a
tensor with center of each box.
torch.Tensor:
A
tensor with center of each box.
"""
"""
return
self
.
bottom_center
return
self
.
bottom_center
...
@@ -137,7 +137,7 @@ class BaseInstance3DBoxes(object):
...
@@ -137,7 +137,7 @@ class BaseInstance3DBoxes(object):
"""Calculate the bottom center of all the boxes.
"""Calculate the bottom center of all the boxes.
Returns:
Returns:
torch.Tensor:
a
tensor with center of each box.
torch.Tensor:
A
tensor with center of each box.
"""
"""
return
self
.
tensor
[:,
:
3
]
return
self
.
tensor
[:,
:
3
]
...
@@ -146,7 +146,7 @@ class BaseInstance3DBoxes(object):
...
@@ -146,7 +146,7 @@ class BaseInstance3DBoxes(object):
"""Calculate the gravity center of all the boxes.
"""Calculate the gravity center of all the boxes.
Returns:
Returns:
torch.Tensor:
a
tensor with center of each box.
torch.Tensor:
A
tensor with center of each box.
"""
"""
pass
pass
...
@@ -164,8 +164,8 @@ class BaseInstance3DBoxes(object):
...
@@ -164,8 +164,8 @@ class BaseInstance3DBoxes(object):
"""Calculate whether the points is in any of the boxes.
"""Calculate whether the points is in any of the boxes.
Args:
Args:
angles (float):
r
otation angles
angles (float):
R
otation angles
axis (int):
t
he axis to rotate the boxes
axis (int):
T
he axis to rotate the boxes
"""
"""
pass
pass
...
@@ -178,7 +178,7 @@ class BaseInstance3DBoxes(object):
...
@@ -178,7 +178,7 @@ class BaseInstance3DBoxes(object):
"""Calculate whether the points is in any of the boxes.
"""Calculate whether the points is in any of the boxes.
Args:
Args:
trans_vector (torch.Tensor):
t
ranslation vector of size 1x3
trans_vector (torch.Tensor):
T
ranslation vector of size 1x3
.
"""
"""
if
not
isinstance
(
trans_vector
,
torch
.
Tensor
):
if
not
isinstance
(
trans_vector
,
torch
.
Tensor
):
trans_vector
=
self
.
tensor
.
new_tensor
(
trans_vector
)
trans_vector
=
self
.
tensor
.
new_tensor
(
trans_vector
)
...
@@ -194,7 +194,7 @@ class BaseInstance3DBoxes(object):
...
@@ -194,7 +194,7 @@ class BaseInstance3DBoxes(object):
Note:
Note:
In the original implementation of SECOND, checking whether
In the original implementation of SECOND, checking whether
a box in the range checks whether the points are in a convex
a box in the range checks whether the points are in a convex
polygon, we try to reduce the burd
u
n for simpler cases.
polygon, we try to reduce the burd
e
n for simpler cases.
Returns:
Returns:
torch.Tensor: A binary vector indicating whether each box is
\
torch.Tensor: A binary vector indicating whether each box is
\
...
@@ -227,7 +227,7 @@ class BaseInstance3DBoxes(object):
...
@@ -227,7 +227,7 @@ class BaseInstance3DBoxes(object):
"""Convert self to `dst` mode.
"""Convert self to `dst` mode.
Args:
Args:
dst (:obj:`BoxMode`):
t
he target Box mode
dst (:obj:`BoxMode`):
T
he target Box mode
。
rt_mat (np.ndarray | torch.Tensor): The rotation and translation
rt_mat (np.ndarray | torch.Tensor): The rotation and translation
matrix between different coordinates. Defaults to None.
matrix between different coordinates. Defaults to None.
The conversion from `src` coordinates to `dst` coordinates
The conversion from `src` coordinates to `dst` coordinates
...
@@ -308,11 +308,11 @@ class BaseInstance3DBoxes(object):
...
@@ -308,11 +308,11 @@ class BaseInstance3DBoxes(object):
return
original_type
(
b
,
box_dim
=
self
.
box_dim
,
with_yaw
=
self
.
with_yaw
)
return
original_type
(
b
,
box_dim
=
self
.
box_dim
,
with_yaw
=
self
.
with_yaw
)
def
__len__
(
self
):
def
__len__
(
self
):
"""int: Number of boxes in the current object"""
"""int: Number of boxes in the current object
.
"""
return
self
.
tensor
.
shape
[
0
]
return
self
.
tensor
.
shape
[
0
]
def
__repr__
(
self
):
def
__repr__
(
self
):
"""str: Return a strings that describes the object"""
"""str: Return a strings that describes the object
.
"""
return
self
.
__class__
.
__name__
+
'(
\n
'
+
str
(
self
.
tensor
)
+
')'
return
self
.
__class__
.
__name__
+
'(
\n
'
+
str
(
self
.
tensor
)
+
')'
@
classmethod
@
classmethod
...
...
mmdet3d/core/bbox/structures/cam_box3d.py
View file @
3c1eb23f
...
@@ -228,8 +228,7 @@ class CameraInstance3DBoxes(BaseInstance3DBoxes):
...
@@ -228,8 +228,7 @@ class CameraInstance3DBoxes(BaseInstance3DBoxes):
Note:
Note:
In the original implementation of SECOND, checking whether
In the original implementation of SECOND, checking whether
a box in the range checks whether the points are in a convex
a box in the range checks whether the points are in a convex
polygon, we try to reduce the burdun for simpler cases.
polygon, we try to reduce the burden for simpler cases.
TODO: check whether this will effect the performance
Returns:
Returns:
torch.Tensor: Indicating whether each box is inside
torch.Tensor: Indicating whether each box is inside
...
...
mmdet3d/core/bbox/structures/depth_box3d.py
View file @
3c1eb23f
...
@@ -37,7 +37,7 @@ class DepthInstance3DBoxes(BaseInstance3DBoxes):
...
@@ -37,7 +37,7 @@ class DepthInstance3DBoxes(BaseInstance3DBoxes):
"""Calculate the gravity center of all the boxes.
"""Calculate the gravity center of all the boxes.
Returns:
Returns:
torch.Tensor:
a
tensor with center of each box.
torch.Tensor:
A
tensor with center of each box.
"""
"""
bottom_center
=
self
.
bottom_center
bottom_center
=
self
.
bottom_center
gravity_center
=
torch
.
zeros_like
(
bottom_center
)
gravity_center
=
torch
.
zeros_like
(
bottom_center
)
...
@@ -68,7 +68,7 @@ class DepthInstance3DBoxes(BaseInstance3DBoxes):
...
@@ -68,7 +68,7 @@ class DepthInstance3DBoxes(BaseInstance3DBoxes):
(x1, y0, z0)
(x1, y0, z0)
Returns:
Returns:
torch.Tensor:
c
orners of each box with size (N, 8, 3)
torch.Tensor:
C
orners of each box with size (N, 8, 3)
.
"""
"""
# TODO: rotation_3d_in_axis function do not support
# TODO: rotation_3d_in_axis function do not support
# empty tensor currently.
# empty tensor currently.
...
@@ -103,7 +103,7 @@ class DepthInstance3DBoxes(BaseInstance3DBoxes):
...
@@ -103,7 +103,7 @@ class DepthInstance3DBoxes(BaseInstance3DBoxes):
"""Calculate the 2D bounding boxes in BEV without rotation.
"""Calculate the 2D bounding boxes in BEV without rotation.
Returns:
Returns:
torch.Tensor:
a
tensor of 2D BEV box of each box.
torch.Tensor:
A
tensor of 2D BEV box of each box.
"""
"""
# Obtain BEV boxes with rotation in XYWHR format
# Obtain BEV boxes with rotation in XYWHR format
bev_rotated_boxes
=
self
.
bev
bev_rotated_boxes
=
self
.
bev
...
...
mmdet3d/core/bbox/structures/lidar_box3d.py
View file @
3c1eb23f
...
@@ -68,7 +68,7 @@ class LiDARInstance3DBoxes(BaseInstance3DBoxes):
...
@@ -68,7 +68,7 @@ class LiDARInstance3DBoxes(BaseInstance3DBoxes):
(x0, y0, z0)
(x0, y0, z0)
Returns:
Returns:
torch.Tensor:
c
orners of each box with size (N, 8, 3)
torch.Tensor:
C
orners of each box with size (N, 8, 3)
.
"""
"""
# TODO: rotation_3d_in_axis function do not support
# TODO: rotation_3d_in_axis function do not support
# empty tensor currently.
# empty tensor currently.
...
@@ -93,8 +93,8 @@ class LiDARInstance3DBoxes(BaseInstance3DBoxes):
...
@@ -93,8 +93,8 @@ class LiDARInstance3DBoxes(BaseInstance3DBoxes):
"""Calculate the 2D bounding boxes in BEV with rotation.
"""Calculate the 2D bounding boxes in BEV with rotation.
Returns:
Returns:
torch.Tensor: A nx5 tensor of 2D BEV box of each box.
torch.Tensor: A nx5 tensor of 2D BEV box of each box.
\
The box is in XYWHR format
The box is in XYWHR format
.
"""
"""
return
self
.
tensor
[:,
[
0
,
1
,
3
,
4
,
6
]]
return
self
.
tensor
[:,
[
0
,
1
,
3
,
4
,
6
]]
...
...
mmdet3d/core/bbox/structures/utils.py
View file @
3c1eb23f
...
@@ -7,12 +7,12 @@ def limit_period(val, offset=0.5, period=np.pi):
...
@@ -7,12 +7,12 @@ def limit_period(val, offset=0.5, period=np.pi):
Args:
Args:
val (torch.Tensor): The value to be converted.
val (torch.Tensor): The value to be converted.
offset (float, optional): Offset to set the value range.
offset (float, optional): Offset to set the value range.
\
Defaults to 0.5.
Defaults to 0.5.
period ([type], optional): Period of the value. Defaults to np.pi.
period ([type], optional): Period of the value. Defaults to np.pi.
Returns:
Returns:
torch.Tensor:
v
alue in the range of
\
torch.Tensor:
V
alue in the range of
\
[-offset * period, (1-offset) * period]
[-offset * period, (1-offset) * period]
"""
"""
return
val
-
torch
.
floor
(
val
/
period
+
offset
)
*
period
return
val
-
torch
.
floor
(
val
/
period
+
offset
)
*
period
...
@@ -90,7 +90,7 @@ def get_box_type(box_type):
...
@@ -90,7 +90,7 @@ def get_box_type(box_type):
The valid value are "LiDAR", "Camera", or "Depth".
The valid value are "LiDAR", "Camera", or "Depth".
Returns:
Returns:
tuple:
b
ox type and box mode.
tuple:
B
ox type and box mode.
"""
"""
from
.box_3d_mode
import
(
Box3DMode
,
CameraInstance3DBoxes
,
from
.box_3d_mode
import
(
Box3DMode
,
CameraInstance3DBoxes
,
DepthInstance3DBoxes
,
LiDARInstance3DBoxes
)
DepthInstance3DBoxes
,
LiDARInstance3DBoxes
)
...
...
mmdet3d/core/bbox/transforms.py
View file @
3c1eb23f
...
@@ -27,7 +27,7 @@ def bbox3d2roi(bbox_list):
...
@@ -27,7 +27,7 @@ def bbox3d2roi(bbox_list):
"""Convert a list of bboxes to roi format.
"""Convert a list of bboxes to roi format.
Args:
Args:
bbox_list (list[torch.Tensor]):
a
list of bboxes
bbox_list (list[torch.Tensor]):
A
list of bboxes
corresponding to a batch of images.
corresponding to a batch of images.
Returns:
Returns:
...
@@ -49,9 +49,9 @@ def bbox3d2result(bboxes, scores, labels):
...
@@ -49,9 +49,9 @@ def bbox3d2result(bboxes, scores, labels):
"""Convert detection results to a list of numpy arrays.
"""Convert detection results to a list of numpy arrays.
Args:
Args:
bboxes (torch.Tensor): shape (n, 5)
bboxes (torch.Tensor):
Bounding boxes with
shape
of
(n, 5)
.
labels (torch.Tensor): shape (n, )
labels (torch.Tensor):
Labels with
shape
of
(n, )
.
scores (torch.Tensor): shape (n, )
scores (torch.Tensor):
Scores with
shape
of
(n, )
.
Returns:
Returns:
dict[str, torch.Tensor]: Bbox results in cpu mode.
dict[str, torch.Tensor]: Bbox results in cpu mode.
...
...
mmdet3d/core/evaluation/indoor_eval.py
View file @
3c1eb23f
...
@@ -8,14 +8,16 @@ def average_precision(recalls, precisions, mode='area'):
...
@@ -8,14 +8,16 @@ def average_precision(recalls, precisions, mode='area'):
"""Calculate average precision (for single or multiple scales).
"""Calculate average precision (for single or multiple scales).
Args:
Args:
recalls (np.ndarray): shape (num_scales, num_dets) or (num_dets, )
recalls (np.ndarray): Recalls with shape of (num_scales, num_dets)
\
precisions (np.ndarray): shape (num_scales, num_dets) or (num_dets, )
or (num_dets, ).
precisions (np.ndarray): Precisions with shape of
\
(num_scales, num_dets) or (num_dets, ).
mode (str): 'area' or '11points', 'area' means calculating the area
mode (str): 'area' or '11points', 'area' means calculating the area
under precision-recall curve, '11points' means calculating
under precision-recall curve, '11points' means calculating
the average precision of recalls at [0, 0.1, ..., 1]
the average precision of recalls at [0, 0.1, ..., 1]
Returns:
Returns:
float or np.ndarray:
c
alculated average precision
float or np.ndarray:
C
alculated average precision
.
"""
"""
if
recalls
.
ndim
==
1
:
if
recalls
.
ndim
==
1
:
recalls
=
recalls
[
np
.
newaxis
,
:]
recalls
=
recalls
[
np
.
newaxis
,
:]
...
@@ -55,14 +57,14 @@ def eval_det_cls(pred, gt, iou_thr=None):
...
@@ -55,14 +57,14 @@ def eval_det_cls(pred, gt, iou_thr=None):
single class.
single class.
Args:
Args:
pred (dict): {img_id: [(bbox, score)]} where bbox is numpy array.
pred (dict): Predictions mapping from image id to bounding boxes
\
gt (dict): {img_id: [bbox]}.
and scores.
iou_thr (list[float]): a list, iou threshold.
gt (dict): Ground truths mapping from image id to bounding boxes.
iou_thr (list[float]): A list of iou thresholds.
Return:
Return:
np.ndarray: numpy array of length nd.
tuple (np.ndarray, np.ndarray, float): Recalls, precisions and
\
np.ndarray: numpy array of length nd.
average precision.
float: scalar, average precision.
"""
"""
# {img_id: {'bbox': box structure, 'det': matched list}}
# {img_id: {'bbox': box structure, 'det': matched list}}
...
@@ -167,7 +169,8 @@ def eval_map_recall(pred, gt, ovthresh=None):
...
@@ -167,7 +169,8 @@ def eval_map_recall(pred, gt, ovthresh=None):
Args:
Args:
pred (dict): Information of detection results,
pred (dict): Information of detection results,
which maps class_id and predictions.
which maps class_id and predictions.
gt (dict): information of gt results, which maps class_id and gt.
gt (dict): Information of ground truths, which maps class_id and
\
ground truths.
ovthresh (list[float]): iou threshold.
ovthresh (list[float]): iou threshold.
Default: None.
Default: None.
...
@@ -213,7 +216,7 @@ def indoor_eval(gt_annos,
...
@@ -213,7 +216,7 @@ def indoor_eval(gt_annos,
dt_annos (list[dict]): Detection annotations. the dict
dt_annos (list[dict]): Detection annotations. the dict
includes the following keys
includes the following keys
- labels_3d (torch.Tensor): Labels of boxes.
- labels_3d (torch.Tensor): Labels of boxes.
- boxes_3d (BaseInstance3DBoxes): 3
d
bboxes in Depth coordinate.
- boxes_3d (BaseInstance3DBoxes): 3
D
bboxes in Depth coordinate.
- scores_3d (torch.Tensor): Scores of boxes.
- scores_3d (torch.Tensor): Scores of boxes.
metric (list[float]): AP IoU thresholds.
metric (list[float]): AP IoU thresholds.
label2cat (dict): {label: cat}.
label2cat (dict): {label: cat}.
...
...
mmdet3d/core/evaluation/lyft_eval.py
View file @
3c1eb23f
...
@@ -142,6 +142,7 @@ def get_classwise_aps(gt, predictions, class_names, iou_thresholds):
...
@@ -142,6 +142,7 @@ def get_classwise_aps(gt, predictions, class_names, iou_thresholds):
"""Returns an array with an average precision per class.
"""Returns an array with an average precision per class.
Note: Ground truth and predictions should have the following format.
Note: Ground truth and predictions should have the following format.
.. code-block::
.. code-block::
gt = [{
gt = [{
...
@@ -200,13 +201,13 @@ def get_single_class_aps(gt, predictions, iou_thresholds):
...
@@ -200,13 +201,13 @@ def get_single_class_aps(gt, predictions, iou_thresholds):
Args:
Args:
gt (list[dict]): list of dictionaries in the format described above.
gt (list[dict]): list of dictionaries in the format described above.
predictions (list[dict]): list of dictionaries in the format
predictions (list[dict]): list of dictionaries in the format
\
described below.
described below.
iou_thresholds (list[float]): IOU thresholds used to calculate
iou_thresholds (list[float]): IOU thresholds used to calculate
\
TP / FN
TP / FN
Returns:
Returns:
tuple[np.ndarray]:
r
eturns (recalls, precisions, average precisions)
tuple[np.ndarray]:
R
eturns (recalls, precisions, average precisions)
for each class.
for each class.
"""
"""
num_gts
=
len
(
gt
)
num_gts
=
len
(
gt
)
...
...
mmdet3d/core/post_processing/merge_augs.py
View file @
3c1eb23f
...
@@ -10,18 +10,18 @@ def merge_aug_bboxes_3d(aug_results, img_metas, test_cfg):
...
@@ -10,18 +10,18 @@ def merge_aug_bboxes_3d(aug_results, img_metas, test_cfg):
Args:
Args:
aug_results (list[dict]): The dict of detection results.
aug_results (list[dict]): The dict of detection results.
The dict contains the following keys
The dict contains the following keys
- boxes_3d (:obj:`BaseInstance3DBoxes`):
d
etection bbox
- boxes_3d (:obj:`BaseInstance3DBoxes`):
D
etection bbox
.
- scores_3d (torch.Tensor):
d
etection scores
- scores_3d (torch.Tensor):
D
etection scores
.
- labels_3d (torch.Tensor):
p
redicted box labels
- labels_3d (torch.Tensor):
P
redicted box labels
.
img_metas (list[dict]): Meta information of each sample
img_metas (list[dict]): Meta information of each sample
.
test_cfg (dict): Test config.
test_cfg (dict): Test config.
Returns:
Returns:
dict:
b
box results in cpu mode, containing
the
merged results
dict:
Bounding
box
es
results in cpu mode, containing merged results
.
- boxes_3d (:obj:`BaseInstance3DBoxes`):
m
erged detection bbox
- boxes_3d (:obj:`BaseInstance3DBoxes`):
M
erged detection bbox
.
- scores_3d (torch.Tensor):
m
erged detection scores
- scores_3d (torch.Tensor):
M
erged detection scores
.
- labels_3d (torch.Tensor):
m
erged predicted box labels
- labels_3d (torch.Tensor):
M
erged predicted box labels
.
"""
"""
assert
len
(
aug_results
)
==
len
(
img_metas
),
\
assert
len
(
aug_results
)
==
len
(
img_metas
),
\
...
...
mmdet3d/core/voxel/voxel_generator.py
View file @
3c1eb23f
...
@@ -40,22 +40,22 @@ class VoxelGenerator(object):
...
@@ -40,22 +40,22 @@ class VoxelGenerator(object):
@
property
@
property
def
voxel_size
(
self
):
def
voxel_size
(
self
):
"""list[float]:
s
ize of a single voxel"""
"""list[float]:
S
ize of a single voxel
.
"""
return
self
.
_voxel_size
return
self
.
_voxel_size
@
property
@
property
def
max_num_points_per_voxel
(
self
):
def
max_num_points_per_voxel
(
self
):
"""int:
m
aximum number of points per voxel"""
"""int:
M
aximum number of points per voxel
.
"""
return
self
.
_max_num_points
return
self
.
_max_num_points
@
property
@
property
def
point_cloud_range
(
self
):
def
point_cloud_range
(
self
):
"""list[float]:
r
ange of point cloud"""
"""list[float]:
R
ange of point cloud
.
"""
return
self
.
_point_cloud_range
return
self
.
_point_cloud_range
@
property
@
property
def
grid_size
(
self
):
def
grid_size
(
self
):
"""np.ndarray: The size of grids"""
"""np.ndarray: The size of grids
.
"""
return
self
.
_grid_size
return
self
.
_grid_size
...
@@ -68,18 +68,18 @@ def points_to_voxel(points,
...
@@ -68,18 +68,18 @@ def points_to_voxel(points,
"""convert kitti points(N, >=3) to voxels.
"""convert kitti points(N, >=3) to voxels.
Args:
Args:
points (np.ndarray): [N, ndim]. points[:, :3] contain xyz points and
points (np.ndarray): [N, ndim]. points[:, :3] contain xyz points and
\
points[:, 3:] contain other information such as reflectivity.
points[:, 3:] contain other information such as reflectivity.
voxel_size (list, tuple, np.ndarray): [3] xyz, indicate voxel size
voxel_size (list, tuple, np.ndarray): [3] xyz, indicate voxel size
coors_range (list[float | tuple[float] | ndarray]): Voxel range.
coors_range (list[float | tuple[float] | ndarray]): Voxel range.
\
format: xyzxyz, minmax
format: xyzxyz, minmax
max_points (int): Indicate maximum points contained in a voxel.
max_points (int): Indicate maximum points contained in a voxel.
reverse_index (bool): Whether return reversed coordinates.
reverse_index (bool): Whether return reversed coordinates.
\
if points has xyz format and reverse_index is True, output
if points has xyz format and reverse_index is True, output
\
coordinates will be zyx format, but points in features always
coordinates will be zyx format, but points in features always
\
xyz format.
xyz format.
max_voxels (int): Maximum number of voxels this function create
.
max_voxels (int): Maximum number of voxels this function create
s.
\
f
or second, 20000 is a good choice. Points should be shuffled for
F
or second, 20000 is a good choice. Points should be shuffled for
\
randomness before this function because max_voxels drops points.
randomness before this function because max_voxels drops points.
Returns:
Returns:
...
@@ -133,20 +133,20 @@ def _points_to_voxel_reverse_kernel(points,
...
@@ -133,20 +133,20 @@ def _points_to_voxel_reverse_kernel(points,
"""convert kitti points(N, >=3) to voxels.
"""convert kitti points(N, >=3) to voxels.
Args:
Args:
points (np.ndarray): [N, ndim]. points[:, :3] contain xyz points and
points (np.ndarray): [N, ndim]. points[:, :3] contain xyz points and
\
points[:, 3:] contain other information such as reflectivity.
points[:, 3:] contain other information such as reflectivity.
voxel_size (list, tuple, np.ndarray): [3] xyz, indicate voxel size
voxel_size (list, tuple, np.ndarray): [3] xyz, indicate voxel size
\
coors_range (list[float | tuple[float] | ndarray]): Range of voxels.
coors_range (list[float | tuple[float] | ndarray]): Range of voxels.
\
format: xyzxyz, minmax
format: xyzxyz, minmax
num_points_per_voxel (int): Number of points per voxel.
num_points_per_voxel (int): Number of points per voxel.
coor_to_voxel_idx (np.ndarray): A voxel grid of shape (D, H, W),
which
coor_to_voxel_idx (np.ndarray): A voxel grid of shape (D, H, W),
\
has the same shape as the complete voxel map. It indicates
the
which
has the same shape as the complete voxel map. It indicates
\
index of each corresponding voxel.
the
index of each corresponding voxel.
voxels (np.ndarray): Created empty voxels.
voxels (np.ndarray): Created empty voxels.
coors (np.ndarray): Created coordinates of each voxel.
coors (np.ndarray): Created coordinates of each voxel.
max_points (int): Indicate maximum points contained in a voxel.
max_points (int): Indicate maximum points contained in a voxel.
max_voxels (int): Maximum number of voxels this function create.
max_voxels (int): Maximum number of voxels this function create.
\
for second, 20000 is a good choice. Points should be shuffled for
for second, 20000 is a good choice. Points should be shuffled for
\
randomness before this function because max_voxels drops points.
randomness before this function because max_voxels drops points.
Returns:
Returns:
...
@@ -207,20 +207,20 @@ def _points_to_voxel_kernel(points,
...
@@ -207,20 +207,20 @@ def _points_to_voxel_kernel(points,
"""convert kitti points(N, >=3) to voxels.
"""convert kitti points(N, >=3) to voxels.
Args:
Args:
points (np.ndarray): [N, ndim]. points[:, :3] contain xyz points and
points (np.ndarray): [N, ndim]. points[:, :3] contain xyz points and
\
points[:, 3:] contain other information such as reflectivity.
points[:, 3:] contain other information such as reflectivity.
voxel_size (list, tuple, np.ndarray): [3] xyz, indicate voxel size
voxel_size (list, tuple, np.ndarray): [3] xyz, indicate voxel size
.
coors_range (list[float | tuple[float] | ndarray]): Range of voxels.
coors_range (list[float | tuple[float] | ndarray]): Range of voxels.
\
format: xyzxyz, minmax
format: xyzxyz, minmax
num_points_per_voxel (int): Number of points per voxel.
num_points_per_voxel (int): Number of points per voxel.
coor_to_voxel_idx (np.ndarray): A voxel grid of shape (D, H, W),
which
coor_to_voxel_idx (np.ndarray): A voxel grid of shape (D, H, W),
\
has the same shape as the complete voxel map. It indicates
the
which
has the same shape as the complete voxel map. It indicates
\
index of each corresponding voxel.
the
index of each corresponding voxel.
voxels (np.ndarray): Created empty voxels.
voxels (np.ndarray): Created empty voxels.
coors (np.ndarray): Created coordinates of each voxel.
coors (np.ndarray): Created coordinates of each voxel.
max_points (int): Indicate maximum points contained in a voxel.
max_points (int): Indicate maximum points contained in a voxel.
max_voxels (int): Maximum number of voxels this function create.
max_voxels (int): Maximum number of voxels this function create.
\
for second, 20000 is a good choice. Points should be shuffled for
for second, 20000 is a good choice. Points should be shuffled for
\
randomness before this function because max_voxels drops points.
randomness before this function because max_voxels drops points.
Returns:
Returns:
...
...
mmdet3d/datasets/custom_3d.py
View file @
3c1eb23f
...
@@ -30,9 +30,9 @@ class Custom3DDataset(Dataset):
...
@@ -30,9 +30,9 @@ class Custom3DDataset(Dataset):
to its original format then converted them to `box_type_3d`.
to its original format then converted them to `box_type_3d`.
Defaults to 'LiDAR'. Available options includes
Defaults to 'LiDAR'. Available options includes
- 'LiDAR':
b
ox in LiDAR coordinates
- 'LiDAR':
B
ox in LiDAR coordinates
.
- 'Depth':
b
ox in depth coordinates, usually for indoor dataset
- 'Depth':
B
ox in depth coordinates, usually for indoor dataset
.
- 'Camera':
b
ox in camera coordinates
- 'Camera':
B
ox in camera coordinates
.
filter_empty_gt (bool, optional): Whether to filter empty GT.
filter_empty_gt (bool, optional): Whether to filter empty GT.
Defaults to True.
Defaults to True.
test_mode (bool, optional): Whether the dataset is in test mode.
test_mode (bool, optional): Whether the dataset is in test mode.
...
@@ -87,10 +87,10 @@ class Custom3DDataset(Dataset):
...
@@ -87,10 +87,10 @@ class Custom3DDataset(Dataset):
dict: Data information that will be passed to the data
\
dict: Data information that will be passed to the data
\
preprocessing pipelines. It includes the following keys:
preprocessing pipelines. It includes the following keys:
- sample_idx (str):
s
ample index
- sample_idx (str):
S
ample index
.
- pts_filename (str):
f
ilename of point clouds
- pts_filename (str):
F
ilename of point clouds
.
- file_name (str):
f
ilename of point clouds
- file_name (str):
F
ilename of point clouds
.
- ann_info (dict):
a
nnotation info
- ann_info (dict):
A
nnotation info
.
"""
"""
info
=
self
.
data_infos
[
index
]
info
=
self
.
data_infos
[
index
]
sample_idx
=
info
[
'point_cloud'
][
'lidar_idx'
]
sample_idx
=
info
[
'point_cloud'
][
'lidar_idx'
]
...
@@ -114,15 +114,15 @@ class Custom3DDataset(Dataset):
...
@@ -114,15 +114,15 @@ class Custom3DDataset(Dataset):
Args:
Args:
results (dict): Dict before data preprocessing.
results (dict): Dict before data preprocessing.
- img_fields (list):
i
mage fields
- img_fields (list):
I
mage fields
.
- bbox3d_fields (list): 3D bounding boxes fields
- bbox3d_fields (list): 3D bounding boxes fields
.
- pts_mask_fields (list):
m
ask fields of points
- pts_mask_fields (list):
M
ask fields of points
.
- pts_seg_fields (list):
m
ask fields of point segments
- pts_seg_fields (list):
M
ask fields of point segments
.
- bbox_fields (list):
f
ields of bounding boxes
- bbox_fields (list):
F
ields of bounding boxes
.
- mask_fields (list):
f
ields of masks
- mask_fields (list):
F
ields of masks
.
- seg_fields (list):
s
egment fields
- seg_fields (list):
S
egment fields
.
- box_type_3d (str): 3D box type
- box_type_3d (str): 3D box type
.
- box_mode_3d (str): 3D box mode
- box_mode_3d (str): 3D box mode
.
"""
"""
results
[
'img_fields'
]
=
[]
results
[
'img_fields'
]
=
[]
results
[
'bbox3d_fields'
]
=
[]
results
[
'bbox3d_fields'
]
=
[]
...
@@ -179,7 +179,7 @@ class Custom3DDataset(Dataset):
...
@@ -179,7 +179,7 @@ class Custom3DDataset(Dataset):
a tuple or list, override the CLASSES defined by the dataset.
a tuple or list, override the CLASSES defined by the dataset.
Return:
Return:
list[str]:
return the
list of class names
list[str]:
A
list of class names
.
"""
"""
if
classes
is
None
:
if
classes
is
None
:
return
cls
.
CLASSES
return
cls
.
CLASSES
...
...
mmdet3d/datasets/kitti2d_dataset.py
View file @
3c1eb23f
...
@@ -80,10 +80,10 @@ class Kitti2DDataset(CustomDataset):
...
@@ -80,10 +80,10 @@ class Kitti2DDataset(CustomDataset):
index (int): Index of the annotation data to get.
index (int): Index of the annotation data to get.
Returns:
Returns:
dict:
a
nnotation information consists of the following keys:
dict:
A
nnotation information consists of the following keys:
- bboxes (np.ndarray):
g
round truth bboxes
- bboxes (np.ndarray):
G
round truth bboxes
.
- labels (np.ndarray):
l
abels of ground truths
- labels (np.ndarray):
L
abels of ground truths
.
"""
"""
# Use index to get the annos, thus the evalhook could also use this api
# Use index to get the annos, thus the evalhook could also use this api
info
=
self
.
data_infos
[
index
]
info
=
self
.
data_infos
[
index
]
...
...
mmdet3d/datasets/kitti_dataset.py
View file @
3c1eb23f
...
@@ -37,9 +37,9 @@ class KittiDataset(Custom3DDataset):
...
@@ -37,9 +37,9 @@ class KittiDataset(Custom3DDataset):
to its original format then converted them to `box_type_3d`.
to its original format then converted them to `box_type_3d`.
Defaults to 'LiDAR' in this dataset. Available options includes
Defaults to 'LiDAR' in this dataset. Available options includes
- 'LiDAR':
b
ox in LiDAR coordinates
- 'LiDAR':
B
ox in LiDAR coordinates
.
- 'Depth':
b
ox in depth coordinates, usually for indoor dataset
- 'Depth':
B
ox in depth coordinates, usually for indoor dataset
.
- 'Camera':
b
ox in camera coordinates
- 'Camera':
B
ox in camera coordinates
.
filter_empty_gt (bool, optional): Whether to filter empty GT.
filter_empty_gt (bool, optional): Whether to filter empty GT.
Defaults to True.
Defaults to True.
test_mode (bool, optional): Whether the dataset is in test mode.
test_mode (bool, optional): Whether the dataset is in test mode.
...
@@ -88,13 +88,13 @@ class KittiDataset(Custom3DDataset):
...
@@ -88,13 +88,13 @@ class KittiDataset(Custom3DDataset):
dict: Data information that will be passed to the data
\
dict: Data information that will be passed to the data
\
preprocessing pipelines. It includes the following keys:
preprocessing pipelines. It includes the following keys:
- sample_idx (str):
s
ample index
- sample_idx (str):
S
ample index
.
- pts_filename (str):
f
ilename of point clouds
- pts_filename (str):
F
ilename of point clouds
.
- img_prefix (str | None):
p
refix of image files
- img_prefix (str | None):
P
refix of image files
.
- img_info (dict):
i
mage info
- img_info (dict):
I
mage info
.
- lidar2img (list[np.ndarray], optional):
t
ransformations
\
- lidar2img (list[np.ndarray], optional):
T
ransformations
\
from lidar to different cameras
from lidar to different cameras
.
- ann_info (dict):
a
nnotation info
- ann_info (dict):
A
nnotation info
.
"""
"""
info
=
self
.
data_infos
[
index
]
info
=
self
.
data_infos
[
index
]
sample_idx
=
info
[
'image'
][
'image_idx'
]
sample_idx
=
info
[
'image'
][
'image_idx'
]
...
@@ -131,11 +131,11 @@ class KittiDataset(Custom3DDataset):
...
@@ -131,11 +131,11 @@ class KittiDataset(Custom3DDataset):
dict: annotation information consists of the following keys:
dict: annotation information consists of the following keys:
- gt_bboxes_3d (:obj:`LiDARInstance3DBoxes`):
\
- gt_bboxes_3d (:obj:`LiDARInstance3DBoxes`):
\
3D ground truth bboxes
3D ground truth bboxes
.
- gt_labels_3d (np.ndarray):
l
abels of ground truths
- gt_labels_3d (np.ndarray):
L
abels of ground truths
.
- gt_bboxes (np.ndarray): 2D ground truth bboxes
- gt_bboxes (np.ndarray): 2D ground truth bboxes
.
- gt_labels (np.ndarray):
l
abels of ground truths
- gt_labels (np.ndarray):
L
abels of ground truths
.
- gt_names (list[str]):
c
lass names of ground truths
- gt_names (list[str]):
C
lass names of ground truths
.
"""
"""
# Use index to get the annos, thus the evalhook could also use this api
# Use index to get the annos, thus the evalhook could also use this api
info
=
self
.
data_infos
[
index
]
info
=
self
.
data_infos
[
index
]
...
@@ -308,7 +308,7 @@ class KittiDataset(Custom3DDataset):
...
@@ -308,7 +308,7 @@ class KittiDataset(Custom3DDataset):
Default: None.
Default: None.
Returns:
Returns:
dict[str, float]:
r
esults of each evaluation metric
dict[str, float]:
R
esults of each evaluation metric
.
"""
"""
result_files
,
tmp_dir
=
self
.
format_results
(
results
,
pklfile_prefix
)
result_files
,
tmp_dir
=
self
.
format_results
(
results
,
pklfile_prefix
)
from
mmdet3d.core.evaluation
import
kitti_eval
from
mmdet3d.core.evaluation
import
kitti_eval
...
@@ -629,7 +629,7 @@ class KittiDataset(Custom3DDataset):
...
@@ -629,7 +629,7 @@ class KittiDataset(Custom3DDataset):
"""Results visualization.
"""Results visualization.
Args:
Args:
results (list[dict]):
l
ist of bounding boxes results.
results (list[dict]):
L
ist of bounding boxes results.
out_dir (str): Output directory of visualization result.
out_dir (str): Output directory of visualization result.
"""
"""
assert
out_dir
is
not
None
,
'Expect out_dir, got none.'
assert
out_dir
is
not
None
,
'Expect out_dir, got none.'
...
...
mmdet3d/datasets/lyft_dataset.py
View file @
3c1eb23f
...
@@ -16,7 +16,7 @@ from .custom_3d import Custom3DDataset
...
@@ -16,7 +16,7 @@ from .custom_3d import Custom3DDataset
@
DATASETS
.
register_module
()
@
DATASETS
.
register_module
()
class
LyftDataset
(
Custom3DDataset
):
class
LyftDataset
(
Custom3DDataset
):
"""Lyft Dataset.
r
"""Lyft Dataset.
This class serves as the API for experiments on the Lyft Dataset.
This class serves as the API for experiments on the Lyft Dataset.
...
@@ -40,9 +40,9 @@ class LyftDataset(Custom3DDataset):
...
@@ -40,9 +40,9 @@ class LyftDataset(Custom3DDataset):
to its original format then converted them to `box_type_3d`.
to its original format then converted them to `box_type_3d`.
Defaults to 'LiDAR' in this dataset. Available options includes
Defaults to 'LiDAR' in this dataset. Available options includes
- 'LiDAR':
b
ox in LiDAR coordinates
- 'LiDAR':
B
ox in LiDAR coordinates
.
- 'Depth':
b
ox in depth coordinates, usually for indoor dataset
- 'Depth':
B
ox in depth coordinates, usually for indoor dataset
.
- 'Camera':
b
ox in camera coordinates
- 'Camera':
B
ox in camera coordinates
.
filter_empty_gt (bool, optional): Whether to filter empty GT.
filter_empty_gt (bool, optional): Whether to filter empty GT.
Defaults to True.
Defaults to True.
test_mode (bool, optional): Whether the dataset is in test mode.
test_mode (bool, optional): Whether the dataset is in test mode.
...
@@ -185,12 +185,12 @@ class LyftDataset(Custom3DDataset):
...
@@ -185,12 +185,12 @@ class LyftDataset(Custom3DDataset):
index (int): Index of the annotation data to get.
index (int): Index of the annotation data to get.
Returns:
Returns:
dict:
a
nnotation information consists of the following keys:
dict:
A
nnotation information consists of the following keys:
- gt_bboxes_3d (:obj:`LiDARInstance3DBoxes`):
\
- gt_bboxes_3d (:obj:`LiDARInstance3DBoxes`):
\
3D ground truth bboxes
3D ground truth bboxes
.
- gt_labels_3d (np.ndarray):
l
abels of ground truths
- gt_labels_3d (np.ndarray):
L
abels of ground truths
.
- gt_names (list[str]):
c
lass names of ground truths
- gt_names (list[str]):
C
lass names of ground truths
.
"""
"""
info
=
self
.
data_infos
[
index
]
info
=
self
.
data_infos
[
index
]
gt_bboxes_3d
=
info
[
'gt_boxes'
]
gt_bboxes_3d
=
info
[
'gt_boxes'
]
...
...
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