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
92ae69fb
"docs/vscode:/vscode.git/clone" did not exist on "76bb54044eb387e9e3009bc169e93d66aa004a74"
Commit
92ae69fb
authored
Jun 20, 2020
by
wuyuefeng
Committed by
zhangwenwei
Jun 20, 2020
Browse files
Merge rot scale
parent
5a1575a0
Changes
38
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
171 additions
and
63 deletions
+171
-63
configs/_base_/datasets/kitti-3d-3class.py
configs/_base_/datasets/kitti-3d-3class.py
+1
-2
configs/_base_/datasets/kitti-3d-car.py
configs/_base_/datasets/kitti-3d-car.py
+1
-2
configs/_base_/datasets/nus-3d.py
configs/_base_/datasets/nus-3d.py
+1
-1
configs/_base_/datasets/scannet-3d-18class.py
configs/_base_/datasets/scannet-3d-18class.py
+14
-6
configs/_base_/datasets/sunrgbd-3d-10class.py
configs/_base_/datasets/sunrgbd-3d-10class.py
+14
-6
configs/_base_/schedules/schedule_3x.py
configs/_base_/schedules/schedule_3x.py
+1
-1
configs/benchmark/hv_pointpillars_secfpn_3x8_100e_det3d_kitti-3d-car.py
...ark/hv_pointpillars_secfpn_3x8_100e_det3d_kitti-3d-car.py
+1
-2
configs/benchmark/hv_pointpillars_secfpn_6x8_160e_pcdet_kitti-3d-3class.py
.../hv_pointpillars_secfpn_6x8_160e_pcdet_kitti-3d-3class.py
+1
-2
configs/benchmark/hv_second_secfpn_6x8_80e_pcdet_kitti-3d-3class.py
...nchmark/hv_second_secfpn_6x8_80e_pcdet_kitti-3d-3class.py
+1
-2
configs/mvxnet/dv_mvx-fpn_second_secfpn_adamw_2x8_80e_kitti-3d-3class.py
...dv_mvx-fpn_second_secfpn_adamw_2x8_80e_kitti-3d-3class.py
+1
-1
configs/parta2/hv_PartA2_secfpn_2x8_cyclic_80e_kitti-3d-3class.py
...parta2/hv_PartA2_secfpn_2x8_cyclic_80e_kitti-3d-3class.py
+1
-2
configs/parta2/hv_PartA2_secfpn_2x8_cyclic_80e_kitti-3d-car.py
...gs/parta2/hv_PartA2_secfpn_2x8_cyclic_80e_kitti-3d-car.py
+1
-2
configs/pointpillars/hv_pointpillars_secfpn_6x8_160e_kitti-3d-3class.py
...illars/hv_pointpillars_secfpn_6x8_160e_kitti-3d-3class.py
+1
-2
configs/pointpillars/hv_pointpillars_secfpn_6x8_160e_kitti-3d-car.py
...ntpillars/hv_pointpillars_secfpn_6x8_160e_kitti-3d-car.py
+1
-2
mmdet3d/core/bbox/structures/cam_box3d.py
mmdet3d/core/bbox/structures/cam_box3d.py
+37
-4
mmdet3d/core/bbox/structures/depth_box3d.py
mmdet3d/core/bbox/structures/depth_box3d.py
+42
-8
mmdet3d/core/bbox/structures/lidar_box3d.py
mmdet3d/core/bbox/structures/lidar_box3d.py
+37
-4
mmdet3d/core/bbox/transforms.py
mmdet3d/core/bbox/transforms.py
+5
-3
mmdet3d/core/post_processing/merge_augs.py
mmdet3d/core/post_processing/merge_augs.py
+4
-2
mmdet3d/datasets/__init__.py
mmdet3d/datasets/__init__.py
+6
-9
No files found.
configs/_base_/datasets/kitti-3d-3class.py
View file @
92ae69fb
...
...
@@ -8,7 +8,6 @@ db_sampler = dict(
data_root
=
data_root
,
info_path
=
data_root
+
'kitti_dbinfos_train.pkl'
,
rate
=
1.0
,
object_rot_range
=
[
0.0
,
0.0
],
prepare
=
dict
(
filter_by_difficulty
=
[
-
1
],
filter_by_min_points
=
dict
(
Car
=
5
,
Pedestrian
=
10
,
Cyclist
=
10
)),
...
...
@@ -40,7 +39,7 @@ train_pipeline = [
translation_std
=
[
1.0
,
1.0
,
0.5
],
global_rot_range
=
[
0.0
,
0.0
],
rot_range
=
[
-
0.78539816
,
0.78539816
]),
dict
(
type
=
'RandomFlip3D'
,
flip_ratio
=
0.5
),
dict
(
type
=
'RandomFlip3D'
,
flip_ratio
_bev_horizontal
=
0.5
),
dict
(
type
=
'GlobalRotScaleTrans'
,
rot_range
=
[
-
0.78539816
,
0.78539816
],
...
...
configs/_base_/datasets/kitti-3d-car.py
View file @
92ae69fb
...
...
@@ -8,7 +8,6 @@ db_sampler = dict(
data_root
=
data_root
,
info_path
=
data_root
+
'kitti_dbinfos_train.pkl'
,
rate
=
1.0
,
object_rot_range
=
[
0.0
,
0.0
],
prepare
=
dict
(
filter_by_difficulty
=
[
-
1
],
filter_by_min_points
=
dict
(
Car
=
5
)),
classes
=
class_names
,
sample_groups
=
dict
(
Car
=
15
))
...
...
@@ -38,7 +37,7 @@ train_pipeline = [
translation_std
=
[
1.0
,
1.0
,
0.5
],
global_rot_range
=
[
0.0
,
0.0
],
rot_range
=
[
-
0.78539816
,
0.78539816
]),
dict
(
type
=
'RandomFlip3D'
,
flip_ratio
=
0.5
),
dict
(
type
=
'RandomFlip3D'
,
flip_ratio
_bev_horizontal
=
0.5
),
dict
(
type
=
'GlobalRotScaleTrans'
,
rot_range
=
[
-
0.78539816
,
0.78539816
],
...
...
configs/_base_/datasets/nus-3d.py
View file @
92ae69fb
...
...
@@ -42,7 +42,7 @@ train_pipeline = [
rot_range
=
[
-
0.3925
,
0.3925
],
scale_ratio_range
=
[
0.95
,
1.05
],
translation_std
=
[
0
,
0
,
0
]),
dict
(
type
=
'RandomFlip3D'
,
flip_ratio
=
0.5
),
dict
(
type
=
'RandomFlip3D'
,
flip_ratio
_bev_horizontal
=
0.5
),
dict
(
type
=
'PointsRangeFilter'
,
point_cloud_range
=
point_cloud_range
),
dict
(
type
=
'ObjectRangeFilter'
,
point_cloud_range
=
point_cloud_range
),
dict
(
type
=
'PointShuffle'
),
...
...
configs/_base_/datasets/scannet-3d-18class.py
View file @
92ae69fb
...
...
@@ -22,12 +22,16 @@ train_pipeline = [
valid_cat_ids
=
(
3
,
4
,
5
,
6
,
7
,
8
,
9
,
10
,
11
,
12
,
14
,
16
,
24
,
28
,
33
,
34
,
36
,
39
)),
dict
(
type
=
'IndoorPointSample'
,
num_points
=
40000
),
dict
(
type
=
'IndoorFlipData'
,
flip_ratio_yz
=
0.5
,
flip_ratio_xz
=
0.5
),
dict
(
type
=
'IndoorGlobalRotScaleTrans'
,
shift_height
=
True
,
rot_range
=
[
-
1
/
36
,
1
/
36
],
scale_range
=
None
),
type
=
'RandomFlip3D'
,
sync_2d
=
False
,
flip_ratio_bev_horizontal
=
0.5
,
flip_ratio_bev_vertical
=
0.5
),
dict
(
type
=
'GlobalRotScaleTrans'
,
rot_range
=
[
-
0.087266
,
0.087266
],
scale_ratio_range
=
[
1.0
,
1.0
],
shift_height
=
True
),
dict
(
type
=
'DefaultFormatBundle3D'
,
class_names
=
class_names
),
dict
(
type
=
'Collect3D'
,
...
...
@@ -53,7 +57,11 @@ test_pipeline = [
rot_range
=
[
0
,
0
],
scale_ratio_range
=
[
1.
,
1.
],
translation_std
=
[
0
,
0
,
0
]),
dict
(
type
=
'RandomFlip3D'
),
dict
(
type
=
'RandomFlip3D'
,
sync_2d
=
False
,
flip_ratio_bev_horizontal
=
0.5
,
flip_ratio_bev_vertical
=
0.5
),
dict
(
type
=
'IndoorPointSample'
,
num_points
=
40000
),
dict
(
type
=
'DefaultFormatBundle3D'
,
...
...
configs/_base_/datasets/sunrgbd-3d-10class.py
View file @
92ae69fb
...
...
@@ -9,12 +9,16 @@ train_pipeline = [
load_dim
=
6
,
use_dim
=
[
0
,
1
,
2
]),
dict
(
type
=
'LoadAnnotations3D'
),
dict
(
type
=
'IndoorFlipData'
,
flip_ratio_yz
=
0.5
),
dict
(
type
=
'IndoorGlobalRotScaleTrans'
,
shift_height
=
True
,
rot_range
=
[
-
1
/
6
,
1
/
6
],
scale_range
=
[
0.85
,
1.15
]),
type
=
'RandomFlip3D'
,
sync_2d
=
False
,
flip_ratio_bev_horizontal
=
0.5
,
),
dict
(
type
=
'GlobalRotScaleTrans'
,
rot_range
=
[
-
0.523599
,
0.523599
],
scale_ratio_range
=
[
0.85
,
1.15
],
shift_height
=
True
),
dict
(
type
=
'IndoorPointSample'
,
num_points
=
20000
),
dict
(
type
=
'DefaultFormatBundle3D'
,
class_names
=
class_names
),
dict
(
type
=
'Collect3D'
,
keys
=
[
'points'
,
'gt_bboxes_3d'
,
'gt_labels_3d'
])
...
...
@@ -36,7 +40,11 @@ test_pipeline = [
rot_range
=
[
0
,
0
],
scale_ratio_range
=
[
1.
,
1.
],
translation_std
=
[
0
,
0
,
0
]),
dict
(
type
=
'RandomFlip3D'
),
dict
(
type
=
'RandomFlip3D'
,
sync_2d
=
False
,
flip_ratio_bev_horizontal
=
0.5
,
),
dict
(
type
=
'IndoorPointSample'
,
num_points
=
20000
),
dict
(
type
=
'DefaultFormatBundle3D'
,
...
...
configs/_base_/schedules/schedule_3x.py
View file @
92ae69fb
...
...
@@ -2,7 +2,7 @@
# This schedule is mainly used by models on indoor dataset,
# e.g., VoteNet on SUNRGBD and ScanNet
lr
=
0.008
# max learning rate
optimizer
=
dict
(
type
=
'Adam'
,
lr
=
lr
)
optimizer
=
dict
(
type
=
'Adam
W
'
,
lr
=
lr
,
weight_decay
=
0.01
)
optimizer_config
=
dict
(
grad_clip
=
dict
(
max_norm
=
10
,
norm_type
=
2
))
lr_config
=
dict
(
policy
=
'step'
,
warmup
=
None
,
step
=
[
24
,
32
])
# runtime settings
...
...
configs/benchmark/hv_pointpillars_secfpn_3x8_100e_det3d_kitti-3d-car.py
View file @
92ae69fb
...
...
@@ -81,7 +81,6 @@ db_sampler = dict(
data_root
=
data_root
,
info_path
=
data_root
+
'kitti_dbinfos_train.pkl'
,
rate
=
1.0
,
object_rot_range
=
[
0.0
,
0.0
],
prepare
=
dict
(
filter_by_difficulty
=
[
-
1
],
filter_by_min_points
=
dict
(
Car
=
5
)),
sample_groups
=
dict
(
Car
=
15
),
classes
=
class_names
)
...
...
@@ -96,7 +95,7 @@ train_pipeline = [
loc_noise_std
=
[
0.25
,
0.25
,
0.25
],
global_rot_range
=
[
0.0
,
0.0
],
rot_uniform_noise
=
[
-
0.15707963267
,
0.15707963267
]),
dict
(
type
=
'RandomFlip3D'
,
flip_ratio
=
0.5
),
dict
(
type
=
'RandomFlip3D'
,
flip_ratio
_bev_horizontal
=
0.5
),
dict
(
type
=
'GlobalRotScale'
,
rot_uniform_noise
=
[
-
0.78539816
,
0.78539816
],
...
...
configs/benchmark/hv_pointpillars_secfpn_6x8_160e_pcdet_kitti-3d-3class.py
View file @
92ae69fb
...
...
@@ -110,7 +110,6 @@ db_sampler = dict(
data_root
=
data_root
,
info_path
=
data_root
+
'kitti_dbinfos_train.pkl'
,
rate
=
1.0
,
object_rot_range
=
[
0.0
,
0.0
],
prepare
=
dict
(
filter_by_difficulty
=
[
-
1
],
filter_by_min_points
=
dict
(
...
...
@@ -135,7 +134,7 @@ train_pipeline = [
translation_std
=
[
1.0
,
1.0
,
0.1
],
global_rot_range
=
[
0.0
,
0.0
],
rot_range
=
[
-
0.78539816
,
0.78539816
]),
dict
(
type
=
'RandomFlip3D'
,
flip_ratio
=
0.5
),
dict
(
type
=
'RandomFlip3D'
,
flip_ratio
_bev_horizontal
=
0.5
),
dict
(
type
=
'GlobalRotScaleTrans'
,
rot_range
=
[
-
0.78539816
,
0.78539816
],
...
...
configs/benchmark/hv_second_secfpn_6x8_80e_pcdet_kitti-3d-3class.py
View file @
92ae69fb
...
...
@@ -99,7 +99,6 @@ db_sampler = dict(
data_root
=
data_root
,
info_path
=
data_root
+
'kitti_dbinfos_train.pkl'
,
rate
=
1.0
,
object_rot_range
=
[
0.0
,
0.0
],
prepare
=
dict
(
filter_by_difficulty
=
[
-
1
],
filter_by_min_points
=
dict
(
...
...
@@ -135,7 +134,7 @@ train_pipeline = [
translation_std
=
[
1.0
,
1.0
,
0.1
],
global_rot_range
=
[
0.0
,
0.0
],
rot_range
=
[
-
0.78539816
,
0.78539816
]),
dict
(
type
=
'RandomFlip3D'
,
flip_ratio
=
0.5
),
dict
(
type
=
'RandomFlip3D'
,
flip_ratio
_bev_horizontal
=
0.5
),
dict
(
type
=
'GlobalRotScaleTrans'
,
rot_range
=
[
-
0.78539816
,
0.78539816
],
...
...
configs/mvxnet/dv_mvx-fpn_second_secfpn_adamw_2x8_80e_kitti-3d-3class.py
View file @
92ae69fb
...
...
@@ -148,7 +148,7 @@ train_pipeline = [
rot_range
=
[
-
0.78539816
,
0.78539816
],
scale_ratio_range
=
[
0.95
,
1.05
],
translation_std
=
[
0.2
,
0.2
,
0.2
]),
dict
(
type
=
'RandomFlip3D'
,
flip_ratio
=
0.5
),
dict
(
type
=
'RandomFlip3D'
,
flip_ratio
_bev_horizontal
=
0.5
),
dict
(
type
=
'PointsRangeFilter'
,
point_cloud_range
=
point_cloud_range
),
dict
(
type
=
'ObjectRangeFilter'
,
point_cloud_range
=
point_cloud_range
),
dict
(
type
=
'PointShuffle'
),
...
...
configs/parta2/hv_PartA2_secfpn_2x8_cyclic_80e_kitti-3d-3class.py
View file @
92ae69fb
...
...
@@ -204,7 +204,6 @@ db_sampler = dict(
data_root
=
data_root
,
info_path
=
data_root
+
'kitti_dbinfos_train.pkl'
,
rate
=
1.0
,
object_rot_range
=
[
0.0
,
0.0
],
prepare
=
dict
(
filter_by_difficulty
=
[
-
1
],
filter_by_min_points
=
dict
(
Car
=
5
,
Pedestrian
=
10
,
Cyclist
=
10
)),
...
...
@@ -220,7 +219,7 @@ train_pipeline = [
translation_std
=
[
1.0
,
1.0
,
0.5
],
global_rot_range
=
[
0.0
,
0.0
],
rot_range
=
[
-
0.78539816
,
0.78539816
]),
dict
(
type
=
'RandomFlip3D'
,
flip_ratio
=
0.5
),
dict
(
type
=
'RandomFlip3D'
,
flip_ratio
_bev_horizontal
=
0.5
),
dict
(
type
=
'GlobalRotScaleTrans'
,
rot_range
=
[
-
0.78539816
,
0.78539816
],
...
...
configs/parta2/hv_PartA2_secfpn_2x8_cyclic_80e_kitti-3d-car.py
View file @
92ae69fb
...
...
@@ -78,7 +78,6 @@ db_sampler = dict(
data_root
=
data_root
,
info_path
=
data_root
+
'kitti_dbinfos_train.pkl'
,
rate
=
1.0
,
object_rot_range
=
[
0.0
,
0.0
],
prepare
=
dict
(
filter_by_difficulty
=
[
-
1
],
filter_by_min_points
=
dict
(
Car
=
5
)),
classes
=
class_names
,
sample_groups
=
dict
(
Car
=
15
))
...
...
@@ -92,7 +91,7 @@ train_pipeline = [
translation_std
=
[
1.0
,
1.0
,
0.5
],
global_rot_range
=
[
0.0
,
0.0
],
rot_range
=
[
-
0.78539816
,
0.78539816
]),
dict
(
type
=
'RandomFlip3D'
,
flip_ratio
=
0.5
),
dict
(
type
=
'RandomFlip3D'
,
flip_ratio
_bev_horizontal
=
0.5
),
dict
(
type
=
'GlobalRotScaleTrans'
,
rot_range
=
[
-
0.78539816
,
0.78539816
],
...
...
configs/pointpillars/hv_pointpillars_secfpn_6x8_160e_kitti-3d-3class.py
View file @
92ae69fb
...
...
@@ -13,7 +13,6 @@ db_sampler = dict(
data_root
=
data_root
,
info_path
=
data_root
+
'kitti_dbinfos_train.pkl'
,
rate
=
1.0
,
object_rot_range
=
[
0.0
,
0.0
],
prepare
=
dict
(
filter_by_difficulty
=
[
-
1
],
filter_by_min_points
=
dict
(
Car
=
5
,
Pedestrian
=
10
,
Cyclist
=
10
)),
...
...
@@ -31,7 +30,7 @@ train_pipeline = [
translation_std
=
[
0.25
,
0.25
,
0.25
],
global_rot_range
=
[
0.0
,
0.0
],
rot_range
=
[
-
0.15707963267
,
0.15707963267
]),
dict
(
type
=
'RandomFlip3D'
,
flip_ratio
=
0.5
),
dict
(
type
=
'RandomFlip3D'
,
flip_ratio
_bev_horizontal
=
0.5
),
dict
(
type
=
'GlobalRotScaleTrans'
,
rot_range
=
[
-
0.78539816
,
0.78539816
],
...
...
configs/pointpillars/hv_pointpillars_secfpn_6x8_160e_kitti-3d-car.py
View file @
92ae69fb
...
...
@@ -35,7 +35,6 @@ db_sampler = dict(
data_root
=
data_root
,
info_path
=
data_root
+
'kitti_dbinfos_train.pkl'
,
rate
=
1.0
,
object_rot_range
=
[
0.0
,
0.0
],
prepare
=
dict
(
filter_by_difficulty
=
[
-
1
],
filter_by_min_points
=
dict
(
Car
=
5
)),
sample_groups
=
dict
(
Car
=
15
),
classes
=
class_names
)
...
...
@@ -50,7 +49,7 @@ train_pipeline = [
translation_std
=
[
0.25
,
0.25
,
0.25
],
global_rot_range
=
[
0.0
,
0.0
],
rot_range
=
[
-
0.15707963267
,
0.15707963267
]),
dict
(
type
=
'RandomFlip3D'
,
flip_ratio
=
0.5
),
dict
(
type
=
'RandomFlip3D'
,
flip_ratio
_bev_horizontal
=
0.5
),
dict
(
type
=
'GlobalRotScaleTrans'
,
rot_range
=
[
-
0.78539816
,
0.78539816
],
...
...
mmdet3d/core/bbox/structures/cam_box3d.py
View file @
92ae69fb
...
...
@@ -101,6 +101,9 @@ class CameraInstance3DBoxes(BaseInstance3DBoxes):
Returns:
torch.Tensor: corners of each box with size (N, 8, 3)
"""
# TODO: rotation_3d_in_axis function do not support
# empty tensor currently.
assert
len
(
self
.
tensor
)
!=
0
dims
=
self
.
dims
corners_norm
=
torch
.
from_numpy
(
np
.
stack
(
np
.
unravel_index
(
np
.
arange
(
8
),
[
2
]
*
3
),
axis
=
1
)).
to
(
...
...
@@ -150,11 +153,18 @@ class CameraInstance3DBoxes(BaseInstance3DBoxes):
bev_boxes
=
torch
.
cat
([
centers
-
dims
/
2
,
centers
+
dims
/
2
],
dim
=-
1
)
return
bev_boxes
def
rotate
(
self
,
angle
):
"""
Calculate whether
th
e
points
is in any of the boxes
def
rotate
(
self
,
angle
,
points
=
None
):
"""
Rotate boxes wi
th points
(optional) with the given angle.
Args:
angle (float | torch.Tensor): rotation angle
angle (float, torch.Tensor): Rotation angle.
points (torch.Tensor, numpy.ndarray, optional): Points to rotate.
Defaults to None.
Returns:
tuple or None: When ``points`` is None, the function returns None,
otherwise it returns the rotated points and the
rotation matrix ``rot_mat_T``.
"""
if
not
isinstance
(
angle
,
torch
.
Tensor
):
angle
=
self
.
tensor
.
new_tensor
(
angle
)
...
...
@@ -166,13 +176,28 @@ class CameraInstance3DBoxes(BaseInstance3DBoxes):
self
.
tensor
[:,
:
3
]
=
self
.
tensor
[:,
:
3
]
@
rot_mat_T
self
.
tensor
[:,
6
]
+=
angle
def
flip
(
self
,
bev_direction
=
'horizontal'
):
if
points
is
not
None
:
if
isinstance
(
points
,
torch
.
Tensor
):
points
[:,
:
3
]
=
points
[:,
:
3
]
@
rot_mat_T
elif
isinstance
(
points
,
np
.
ndarray
):
rot_mat_T
=
rot_mat_T
.
numpy
()
points
[:,
:
3
]
=
np
.
dot
(
points
[:,
:
3
],
rot_mat_T
)
else
:
raise
ValueError
return
points
,
rot_mat_T
def
flip
(
self
,
bev_direction
=
'horizontal'
,
points
=
None
):
"""Flip the boxes in BEV along given BEV direction
In CAM coordinates, it flips the x (horizontal) or z (vertical) axis.
Args:
bev_direction (str): Flip direction (horizontal or vertical).
points (torch.Tensor, numpy.ndarray, None): Points to flip.
Defaults to None.
Returns:
torch.Tensor, numpy.ndarray or None: Flipped points.
"""
assert
bev_direction
in
(
'horizontal'
,
'vertical'
)
if
bev_direction
==
'horizontal'
:
...
...
@@ -184,6 +209,14 @@ class CameraInstance3DBoxes(BaseInstance3DBoxes):
if
self
.
with_yaw
:
self
.
tensor
[:,
6
]
=
-
self
.
tensor
[:,
6
]
if
points
is
not
None
:
assert
isinstance
(
points
,
(
torch
.
Tensor
,
np
.
ndarray
))
if
bev_direction
==
'horizontal'
:
points
[:,
0
]
=
-
points
[:,
0
]
elif
bev_direction
==
'vertical'
:
points
[:,
2
]
=
-
points
[:,
2
]
return
points
def
in_range_bev
(
self
,
box_range
):
"""Check whether the boxes are in the given range
...
...
mmdet3d/core/bbox/structures/depth_box3d.py
View file @
92ae69fb
...
...
@@ -69,6 +69,9 @@ class DepthInstance3DBoxes(BaseInstance3DBoxes):
Returns:
torch.Tensor: corners of each box with size (N, 8, 3)
"""
# TODO: rotation_3d_in_axis function do not support
# empty tensor currently.
assert
len
(
self
.
tensor
)
!=
0
dims
=
self
.
dims
corners_norm
=
torch
.
from_numpy
(
np
.
stack
(
np
.
unravel_index
(
np
.
arange
(
8
),
[
2
]
*
3
),
axis
=
1
)).
to
(
...
...
@@ -118,23 +121,31 @@ class DepthInstance3DBoxes(BaseInstance3DBoxes):
bev_boxes
=
torch
.
cat
([
centers
-
dims
/
2
,
centers
+
dims
/
2
],
dim
=-
1
)
return
bev_boxes
def
rotate
(
self
,
angle
):
"""
Calculate whether
th
e
points
is in any of the boxes
def
rotate
(
self
,
angle
,
points
=
None
):
"""
Rotate boxes wi
th points
(optional) with the given angle.
Args:
angle (float | torch.Tensor): rotation angle
angle (float, torch.Tensor): Rotation angle.
points (torch.Tensor, numpy.ndarray, optional): Points to rotate.
Defaults to None.
Returns:
tuple or None: When ``points`` is None, the function returns None,
otherwise it returns the rotated points and the
rotation matrix ``rot_mat_T``.
"""
if
not
isinstance
(
angle
,
torch
.
Tensor
):
angle
=
self
.
tensor
.
new_tensor
(
angle
)
rot_sin
=
torch
.
sin
(
angle
)
rot_cos
=
torch
.
cos
(
angle
)
rot_mat
=
self
.
tensor
.
new_tensor
([[
rot_cos
,
-
rot_sin
,
0
],
[
rot_sin
,
rot_cos
,
0
],
[
0
,
0
,
1
]])
self
.
tensor
[:,
0
:
3
]
=
self
.
tensor
[:,
0
:
3
]
@
rot_mat
.
T
rot_mat_T
=
self
.
tensor
.
new_tensor
([[
rot_cos
,
-
rot_sin
,
0
],
[
rot_sin
,
rot_cos
,
0
],
[
0
,
0
,
1
]]).
T
self
.
tensor
[:,
0
:
3
]
=
self
.
tensor
[:,
0
:
3
]
@
rot_mat_T
if
self
.
with_yaw
:
self
.
tensor
[:,
6
]
-=
angle
else
:
corners_rot
=
self
.
corners
@
rot_mat
.
T
corners_rot
=
self
.
corners
@
rot_mat
_
T
new_x_size
=
corners_rot
[...,
0
].
max
(
dim
=
1
,
keepdim
=
True
)[
0
]
-
corners_rot
[...,
0
].
min
(
dim
=
1
,
keepdim
=
True
)[
0
]
...
...
@@ -143,13 +154,28 @@ class DepthInstance3DBoxes(BaseInstance3DBoxes):
dim
=
1
,
keepdim
=
True
)[
0
]
self
.
tensor
[:,
3
:
5
]
=
torch
.
cat
((
new_x_size
,
new_y_size
),
dim
=-
1
)
def
flip
(
self
,
bev_direction
=
'horizontal'
):
if
points
is
not
None
:
if
isinstance
(
points
,
torch
.
Tensor
):
points
[:,
:
3
]
=
points
[:,
:
3
]
@
rot_mat_T
elif
isinstance
(
points
,
np
.
ndarray
):
rot_mat_T
=
rot_mat_T
.
numpy
()
points
[:,
:
3
]
=
np
.
dot
(
points
[:,
:
3
],
rot_mat_T
)
else
:
raise
ValueError
return
points
,
rot_mat_T
def
flip
(
self
,
bev_direction
=
'horizontal'
,
points
=
None
):
"""Flip the boxes in BEV along given BEV direction
In Depth coordinates, it flips x (horizontal) or y (vertical) axis.
Args:
bev_direction (str): Flip direction (horizontal or vertical).
points (torch.Tensor, numpy.ndarray, None): Points to flip.
Defaults to None.
Returns:
torch.Tensor, numpy.ndarray or None: Flipped points.
"""
assert
bev_direction
in
(
'horizontal'
,
'vertical'
)
if
bev_direction
==
'horizontal'
:
...
...
@@ -161,6 +187,14 @@ class DepthInstance3DBoxes(BaseInstance3DBoxes):
if
self
.
with_yaw
:
self
.
tensor
[:,
6
]
=
-
self
.
tensor
[:,
6
]
if
points
is
not
None
:
assert
isinstance
(
points
,
(
torch
.
Tensor
,
np
.
ndarray
))
if
bev_direction
==
'horizontal'
:
points
[:,
0
]
=
-
points
[:,
0
]
elif
bev_direction
==
'vertical'
:
points
[:,
1
]
=
-
points
[:,
1
]
return
points
def
in_range_bev
(
self
,
box_range
):
"""Check whether the boxes are in the given range
...
...
mmdet3d/core/bbox/structures/lidar_box3d.py
View file @
92ae69fb
...
...
@@ -69,6 +69,9 @@ class LiDARInstance3DBoxes(BaseInstance3DBoxes):
Returns:
torch.Tensor: corners of each box with size (N, 8, 3)
"""
# TODO: rotation_3d_in_axis function do not support
# empty tensor currently.
assert
len
(
self
.
tensor
)
!=
0
dims
=
self
.
dims
corners_norm
=
torch
.
from_numpy
(
np
.
stack
(
np
.
unravel_index
(
np
.
arange
(
8
),
[
2
]
*
3
),
axis
=
1
)).
to
(
...
...
@@ -118,11 +121,18 @@ class LiDARInstance3DBoxes(BaseInstance3DBoxes):
bev_boxes
=
torch
.
cat
([
centers
-
dims
/
2
,
centers
+
dims
/
2
],
dim
=-
1
)
return
bev_boxes
def
rotate
(
self
,
angle
):
"""
Calculate whether
th
e
points
is in any of the boxes
def
rotate
(
self
,
angle
,
points
=
None
):
"""
Rotate boxes wi
th points
(optional) with the given angle.
Args:
angle (float | torch.Tensor): rotation angle
angle (float | torch.Tensor): Rotation angle.
points (torch.Tensor, numpy.ndarray, optional): Points to rotate.
Defaults to None.
Returns:
tuple or None: When ``points`` is None, the function returns None,
otherwise it returns the rotated points and the
rotation matrix ``rot_mat_T``.
"""
if
not
isinstance
(
angle
,
torch
.
Tensor
):
angle
=
self
.
tensor
.
new_tensor
(
angle
)
...
...
@@ -138,13 +148,28 @@ class LiDARInstance3DBoxes(BaseInstance3DBoxes):
# rotate velo vector
self
.
tensor
[:,
7
:
9
]
=
self
.
tensor
[:,
7
:
9
]
@
rot_mat_T
[:
2
,
:
2
]
def
flip
(
self
,
bev_direction
=
'horizontal'
):
if
points
is
not
None
:
if
isinstance
(
points
,
torch
.
Tensor
):
points
[:,
:
3
]
=
points
[:,
:
3
]
@
rot_mat_T
elif
isinstance
(
points
,
np
.
ndarray
):
rot_mat_T
=
rot_mat_T
.
numpy
()
points
[:,
:
3
]
=
np
.
dot
(
points
[:,
:
3
],
rot_mat_T
)
else
:
raise
ValueError
return
points
,
rot_mat_T
def
flip
(
self
,
bev_direction
=
'horizontal'
,
points
=
None
):
"""Flip the boxes in BEV along given BEV direction
In LIDAR coordinates, it flips the y (horizontal) or x (vertical) axis.
Args:
bev_direction (str): Flip direction (horizontal or vertical).
points (torch.Tensor, numpy.ndarray, None): Points to flip.
Defaults to None.
Returns:
torch.Tensor, numpy.ndarray or None: Flipped points.
"""
assert
bev_direction
in
(
'horizontal'
,
'vertical'
)
if
bev_direction
==
'horizontal'
:
...
...
@@ -156,6 +181,14 @@ class LiDARInstance3DBoxes(BaseInstance3DBoxes):
if
self
.
with_yaw
:
self
.
tensor
[:,
6
]
=
-
self
.
tensor
[:,
6
]
if
points
is
not
None
:
assert
isinstance
(
points
,
(
torch
.
Tensor
,
np
.
ndarray
))
if
bev_direction
==
'horizontal'
:
points
[:,
1
]
=
-
points
[:,
1
]
elif
bev_direction
==
'vertical'
:
points
[:,
0
]
=
-
points
[:,
0
]
return
points
def
in_range_bev
(
self
,
box_range
):
"""Check whether the boxes are in the given range
...
...
mmdet3d/core/bbox/transforms.py
View file @
92ae69fb
import
torch
def
bbox3d_mapping_back
(
bboxes
,
scale_factor
,
flip
):
def
bbox3d_mapping_back
(
bboxes
,
scale_factor
,
flip
_horizontal
,
flip_vertical
):
"""Map bboxes from testing scale to original image scale"""
new_bboxes
=
bboxes
.
clone
()
if
flip
:
new_bboxes
.
flip
()
if
flip_horizontal
:
new_bboxes
.
flip
(
'horizontal'
)
if
flip_vertical
:
new_bboxes
.
flip
(
'vertical'
)
new_bboxes
.
scale
(
1
/
scale_factor
)
return
new_bboxes
...
...
mmdet3d/core/post_processing/merge_augs.py
View file @
92ae69fb
...
...
@@ -33,10 +33,12 @@ def merge_aug_bboxes_3d(aug_results, img_metas, test_cfg):
for
bboxes
,
img_info
in
zip
(
aug_results
,
img_metas
):
scale_factor
=
img_info
[
0
][
'pcd_scale_factor'
]
flip
=
img_info
[
0
][
'pcd_flip'
]
pcd_horizontal_flip
=
img_info
[
0
][
'pcd_horizontal_flip'
]
pcd_vertical_flip
=
img_info
[
0
][
'pcd_vertical_flip'
]
recovered_scores
.
append
(
bboxes
[
'scores_3d'
])
recovered_labels
.
append
(
bboxes
[
'labels_3d'
])
bboxes
=
bbox3d_mapping_back
(
bboxes
[
'boxes_3d'
],
scale_factor
,
flip
)
bboxes
=
bbox3d_mapping_back
(
bboxes
[
'boxes_3d'
],
scale_factor
,
pcd_horizontal_flip
,
pcd_vertical_flip
)
recovered_bboxes
.
append
(
bboxes
)
aug_bboxes
=
recovered_bboxes
[
0
].
cat
(
recovered_bboxes
)
...
...
mmdet3d/datasets/__init__.py
View file @
92ae69fb
...
...
@@ -3,12 +3,11 @@ from .custom_3d import Custom3DDataset
from
.kitti2d_dataset
import
Kitti2DDataset
from
.kitti_dataset
import
KittiDataset
from
.nuscenes_dataset
import
NuScenesDataset
from
.pipelines
import
(
GlobalRotScaleTrans
,
IndoorFlipData
,
IndoorGlobalRotScaleTrans
,
IndoorPointSample
,
IndoorPointsColorJitter
,
LoadAnnotations3D
,
LoadPointsFromFile
,
NormalizePointsColor
,
ObjectNoise
,
ObjectRangeFilter
,
ObjectSample
,
PointShuffle
,
PointsRangeFilter
,
RandomFlip3D
)
from
.pipelines
import
(
GlobalRotScaleTrans
,
IndoorPointSample
,
LoadAnnotations3D
,
LoadPointsFromFile
,
NormalizePointsColor
,
ObjectNoise
,
ObjectRangeFilter
,
ObjectSample
,
PointShuffle
,
PointsRangeFilter
,
RandomFlip3D
)
from
.scannet_dataset
import
ScanNetDataset
from
.sunrgbd_dataset
import
SUNRGBDDataset
...
...
@@ -20,7 +19,5 @@ __all__ = [
'RandomFlip3D'
,
'ObjectNoise'
,
'GlobalRotScaleTrans'
,
'PointShuffle'
,
'ObjectRangeFilter'
,
'PointsRangeFilter'
,
'Collect3D'
,
'LoadPointsFromFile'
,
'NormalizePointsColor'
,
'IndoorPointSample'
,
'LoadAnnotations3D'
,
'IndoorPointsColorJitter'
,
'IndoorGlobalRotScaleTrans'
,
'IndoorFlipData'
,
'SUNRGBDDataset'
,
'ScanNetDataset'
,
'Custom3DDataset'
'LoadAnnotations3D'
,
'SUNRGBDDataset'
,
'ScanNetDataset'
,
'Custom3DDataset'
]
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