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
ba492be7
Commit
ba492be7
authored
Apr 15, 2020
by
zhangwenwei
Browse files
Use MMDet API and pass CI
parent
9466dff7
Changes
68
Show whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
33 additions
and
763 deletions
+33
-763
.gitlab-ci.yml
.gitlab-ci.yml
+0
-1
.isort.cfg
.isort.cfg
+1
-1
configs/kitti/dv_mvx-v2_second_secfpn_fpn-fusion_adamw_2x8_80e_kitti-3d-3class.py
...second_secfpn_fpn-fusion_adamw_2x8_80e_kitti-3d-3class.py
+3
-3
configs/kitti/dv_pointpillars_secfpn_6x8_160e_kitti-3d-car.py
...igs/kitti/dv_pointpillars_secfpn_6x8_160e_kitti-3d-car.py
+1
-1
configs/kitti/dv_second_secfpn_2x8_cosine_80e_kitti-3d-3class.py
.../kitti/dv_second_secfpn_2x8_cosine_80e_kitti-3d-3class.py
+3
-3
configs/kitti/dv_second_secfpn_6x8_80e_kitti-3d-car.py
configs/kitti/dv_second_secfpn_6x8_80e_kitti-3d-car.py
+1
-1
configs/kitti/hv_pointpillars_secfpn_6x8_160e_kitti-3d-car.py
...igs/kitti/hv_pointpillars_secfpn_6x8_160e_kitti-3d-car.py
+1
-1
configs/kitti/hv_second_secfpn_6x8_80e_kitti-3d-car.py
configs/kitti/hv_second_secfpn_6x8_80e_kitti-3d-car.py
+1
-1
configs/nus/hv_pointpillars_secfpn_sbn-all_4x8_20e_nus-3d.py
configs/nus/hv_pointpillars_secfpn_sbn-all_4x8_20e_nus-3d.py
+1
-1
configs/nus/hv_pointpillars_secfpn_sbn-all_freeze_adamw_1x16_20e_nus-mm.py
...intpillars_secfpn_sbn-all_freeze_adamw_1x16_20e_nus-mm.py
+0
-267
mmdet3d/core/__init__.py
mmdet3d/core/__init__.py
+1
-2
mmdet3d/core/anchor/__init__.py
mmdet3d/core/anchor/__init__.py
+1
-2
mmdet3d/core/bbox/__init__.py
mmdet3d/core/bbox/__init__.py
+10
-31
mmdet3d/core/bbox/assigners/__init__.py
mmdet3d/core/bbox/assigners/__init__.py
+2
-7
mmdet3d/core/bbox/assigners/approx_max_iou_assigner.py
mmdet3d/core/bbox/assigners/approx_max_iou_assigner.py
+0
-114
mmdet3d/core/bbox/assigners/assign_result.py
mmdet3d/core/bbox/assigners/assign_result.py
+0
-19
mmdet3d/core/bbox/assigners/base_assigner.py
mmdet3d/core/bbox/assigners/base_assigner.py
+0
-8
mmdet3d/core/bbox/assigners/max_iou_assigner.py
mmdet3d/core/bbox/assigners/max_iou_assigner.py
+0
-169
mmdet3d/core/bbox/geometry.py
mmdet3d/core/bbox/geometry.py
+0
-131
mmdet3d/core/bbox/iou_calculators/__init__.py
mmdet3d/core/bbox/iou_calculators/__init__.py
+7
-0
No files found.
.gitlab-ci.yml
View file @
ba492be7
...
@@ -25,7 +25,6 @@ before_script:
...
@@ -25,7 +25,6 @@ before_script:
stage
:
test
stage
:
test
script
:
script
:
-
echo "Start building..."
-
echo "Start building..."
-
conda install av -c conda-forge -y
-
pip install git+https://github.com/open-mmlab/mmdetection.git@v2.0
-
pip install git+https://github.com/open-mmlab/mmdetection.git@v2.0
-
python -c "import mmdet; print(mmdet.__version__)"
-
python -c "import mmdet; print(mmdet.__version__)"
-
pip install -v -e .[all]
-
pip install -v -e .[all]
...
...
.isort.cfg
View file @
ba492be7
...
@@ -3,6 +3,6 @@ line_length = 79
...
@@ -3,6 +3,6 @@ line_length = 79
multi_line_output = 0
multi_line_output = 0
known_standard_library = setuptools
known_standard_library = setuptools
known_first_party = mmdet,mmdet3d
known_first_party = mmdet,mmdet3d
known_third_party = cv2,mmcv,numba,numpy,nuscenes,pycocotools,pyquaternion,
scipy,
shapely,six,skimage,
terminaltables,
torch,torchvision
known_third_party = cv2,mmcv,numba,numpy,nuscenes,pycocotools,pyquaternion,shapely,six,skimage,torch,torchvision
no_lines_before = STDLIB,LOCALFOLDER
no_lines_before = STDLIB,LOCALFOLDER
default_section = THIRDPARTY
default_section = THIRDPARTY
configs/kitti/dv_mvx-v2_second_secfpn_fpn-fusion_adamw_2x8_80e_kitti-3d-3class.py
View file @
ba492be7
...
@@ -100,21 +100,21 @@ train_cfg = dict(
...
@@ -100,21 +100,21 @@ train_cfg = dict(
assigner
=
[
assigner
=
[
dict
(
# for Pedestrian
dict
(
# for Pedestrian
type
=
'MaxIoUAssigner'
,
type
=
'MaxIoUAssigner'
,
iou_
type
=
'n
earest
_3d'
,
iou_
calculator
=
dict
(
type
=
'BboxOverlapsN
earest
3D'
)
,
pos_iou_thr
=
0.35
,
pos_iou_thr
=
0.35
,
neg_iou_thr
=
0.2
,
neg_iou_thr
=
0.2
,
min_pos_iou
=
0.2
,
min_pos_iou
=
0.2
,
ignore_iof_thr
=-
1
),
ignore_iof_thr
=-
1
),
dict
(
# for Cyclist
dict
(
# for Cyclist
type
=
'MaxIoUAssigner'
,
type
=
'MaxIoUAssigner'
,
iou_
type
=
'n
earest
_3d'
,
iou_
calculator
=
dict
(
type
=
'BboxOverlapsN
earest
3D'
)
,
pos_iou_thr
=
0.35
,
pos_iou_thr
=
0.35
,
neg_iou_thr
=
0.2
,
neg_iou_thr
=
0.2
,
min_pos_iou
=
0.2
,
min_pos_iou
=
0.2
,
ignore_iof_thr
=-
1
),
ignore_iof_thr
=-
1
),
dict
(
# for Car
dict
(
# for Car
type
=
'MaxIoUAssigner'
,
type
=
'MaxIoUAssigner'
,
iou_
type
=
'n
earest
_3d'
,
iou_
calculator
=
dict
(
type
=
'BboxOverlapsN
earest
3D'
)
,
pos_iou_thr
=
0.6
,
pos_iou_thr
=
0.6
,
neg_iou_thr
=
0.45
,
neg_iou_thr
=
0.45
,
min_pos_iou
=
0.45
,
min_pos_iou
=
0.45
,
...
...
configs/kitti/dv_pointpillars_secfpn_6x8_160e_kitti-3d-car.py
View file @
ba492be7
...
@@ -64,7 +64,7 @@ model = dict(
...
@@ -64,7 +64,7 @@ model = dict(
train_cfg
=
dict
(
train_cfg
=
dict
(
assigner
=
dict
(
assigner
=
dict
(
type
=
'MaxIoUAssigner'
,
type
=
'MaxIoUAssigner'
,
iou_
type
=
'n
earest
_3d'
,
iou_
calculator
=
dict
(
type
=
'BboxOverlapsN
earest
3D'
)
,
pos_iou_thr
=
0.6
,
pos_iou_thr
=
0.6
,
neg_iou_thr
=
0.45
,
neg_iou_thr
=
0.45
,
min_pos_iou
=
0.45
,
min_pos_iou
=
0.45
,
...
...
configs/kitti/dv_second_secfpn_2x8_cosine_80e_kitti-3d-3class.py
View file @
ba492be7
...
@@ -69,21 +69,21 @@ train_cfg = dict(
...
@@ -69,21 +69,21 @@ train_cfg = dict(
assigner
=
[
assigner
=
[
dict
(
# for Pedestrian
dict
(
# for Pedestrian
type
=
'MaxIoUAssigner'
,
type
=
'MaxIoUAssigner'
,
iou_
type
=
'n
earest
_3d'
,
iou_
calculator
=
dict
(
type
=
'BboxOverlapsN
earest
3D'
)
,
pos_iou_thr
=
0.35
,
pos_iou_thr
=
0.35
,
neg_iou_thr
=
0.2
,
neg_iou_thr
=
0.2
,
min_pos_iou
=
0.2
,
min_pos_iou
=
0.2
,
ignore_iof_thr
=-
1
),
ignore_iof_thr
=-
1
),
dict
(
# for Cyclist
dict
(
# for Cyclist
type
=
'MaxIoUAssigner'
,
type
=
'MaxIoUAssigner'
,
iou_
type
=
'n
earest
_3d'
,
iou_
calculator
=
dict
(
type
=
'BboxOverlapsN
earest
3D'
)
,
pos_iou_thr
=
0.35
,
pos_iou_thr
=
0.35
,
neg_iou_thr
=
0.2
,
neg_iou_thr
=
0.2
,
min_pos_iou
=
0.2
,
min_pos_iou
=
0.2
,
ignore_iof_thr
=-
1
),
ignore_iof_thr
=-
1
),
dict
(
# for Car
dict
(
# for Car
type
=
'MaxIoUAssigner'
,
type
=
'MaxIoUAssigner'
,
iou_
type
=
'n
earest
_3d'
,
iou_
calculator
=
dict
(
type
=
'BboxOverlapsN
earest
3D'
)
,
pos_iou_thr
=
0.6
,
pos_iou_thr
=
0.6
,
neg_iou_thr
=
0.45
,
neg_iou_thr
=
0.45
,
min_pos_iou
=
0.45
,
min_pos_iou
=
0.45
,
...
...
configs/kitti/dv_second_secfpn_6x8_80e_kitti-3d-car.py
View file @
ba492be7
...
@@ -62,7 +62,7 @@ model = dict(
...
@@ -62,7 +62,7 @@ model = dict(
train_cfg
=
dict
(
train_cfg
=
dict
(
assigner
=
dict
(
assigner
=
dict
(
type
=
'MaxIoUAssigner'
,
type
=
'MaxIoUAssigner'
,
iou_
type
=
'n
earest
_3d'
,
iou_
calculator
=
dict
(
type
=
'BboxOverlapsN
earest
3D'
)
,
pos_iou_thr
=
0.6
,
pos_iou_thr
=
0.6
,
neg_iou_thr
=
0.45
,
neg_iou_thr
=
0.45
,
min_pos_iou
=
0.45
,
min_pos_iou
=
0.45
,
...
...
configs/kitti/hv_pointpillars_secfpn_6x8_160e_kitti-3d-car.py
View file @
ba492be7
...
@@ -63,7 +63,7 @@ model = dict(
...
@@ -63,7 +63,7 @@ model = dict(
train_cfg
=
dict
(
train_cfg
=
dict
(
assigner
=
dict
(
assigner
=
dict
(
type
=
'MaxIoUAssigner'
,
type
=
'MaxIoUAssigner'
,
iou_
type
=
'n
earest
_3d'
,
iou_
calculator
=
dict
(
type
=
'BboxOverlapsN
earest
3D'
)
,
pos_iou_thr
=
0.6
,
pos_iou_thr
=
0.6
,
neg_iou_thr
=
0.45
,
neg_iou_thr
=
0.45
,
min_pos_iou
=
0.45
,
min_pos_iou
=
0.45
,
...
...
configs/kitti/hv_second_secfpn_6x8_80e_kitti-3d-car.py
View file @
ba492be7
...
@@ -62,7 +62,7 @@ model = dict(
...
@@ -62,7 +62,7 @@ model = dict(
train_cfg
=
dict
(
train_cfg
=
dict
(
assigner
=
dict
(
assigner
=
dict
(
type
=
'MaxIoUAssigner'
,
type
=
'MaxIoUAssigner'
,
iou_
type
=
'n
earest
_3d'
,
iou_
calculator
=
dict
(
type
=
'BboxOverlapsN
earest
3D'
)
,
pos_iou_thr
=
0.6
,
pos_iou_thr
=
0.6
,
neg_iou_thr
=
0.45
,
neg_iou_thr
=
0.45
,
min_pos_iou
=
0.45
,
min_pos_iou
=
0.45
,
...
...
configs/nus/hv_pointpillars_secfpn_sbn-all_4x8_20e_nus-3d.py
View file @
ba492be7
...
@@ -94,7 +94,7 @@ train_cfg = dict(
...
@@ -94,7 +94,7 @@ train_cfg = dict(
pts
=
dict
(
pts
=
dict
(
assigner
=
dict
(
# for Car
assigner
=
dict
(
# for Car
type
=
'MaxIoUAssigner'
,
type
=
'MaxIoUAssigner'
,
iou_
type
=
'n
earest
_3d'
,
iou_
calculator
=
dict
(
type
=
'BboxOverlapsN
earest
3D'
)
,
pos_iou_thr
=
0.6
,
pos_iou_thr
=
0.6
,
neg_iou_thr
=
0.3
,
neg_iou_thr
=
0.3
,
min_pos_iou
=
0.3
,
min_pos_iou
=
0.3
,
...
...
configs/nus/hv_pointpillars_secfpn_sbn-all_freeze_adamw_1x16_20e_nus-mm.py
deleted
100644 → 0
View file @
9466dff7
# model settings
voxel_size
=
[
0.25
,
0.25
,
8
]
point_cloud_range
=
[
-
50
,
-
50
,
-
5
,
50
,
50
,
3
]
class_names
=
[
'car'
,
'truck'
,
'trailer'
,
'bus'
,
'construction_vehicle'
,
'bicycle'
,
'motorcycle'
,
'pedestrian'
,
'traffic_cone'
,
'barrier'
]
model
=
dict
(
type
=
'MVXFasterRCNNV2'
,
pretrained
=
(
'./pretrain_detectron/'
'ImageNetPretrained/MSRA/resnet50_msra.pth'
),
img_backbone
=
dict
(
type
=
'ResNet'
,
depth
=
50
,
num_stages
=
4
,
out_indices
=
(
0
,
1
,
2
,
3
),
frozen_stages
=
4
,
norm_cfg
=
dict
(
type
=
'BN'
,
requires_grad
=
False
),
norm_eval
=
True
,
style
=
'caffe'
),
pts_voxel_layer
=
dict
(
max_num_points
=
64
,
# max_points_per_voxel
point_cloud_range
=
point_cloud_range
,
# velodyne coordinates, x, y, z
voxel_size
=
voxel_size
,
max_voxels
=
(
30000
,
40000
),
# (training, testing) max_coxels
),
pts_voxel_encoder
=
dict
(
type
=
'HardVFE'
,
num_input_features
=
4
,
num_filters
=
[
64
,
64
],
with_distance
=
False
,
voxel_size
=
voxel_size
,
with_cluster_center
=
True
,
with_voxel_center
=
True
,
point_cloud_range
=
point_cloud_range
,
norm_cfg
=
dict
(
type
=
'naiveSyncBN1d'
,
eps
=
1e-3
,
momentum
=
0.01
),
fusion_layer
=
dict
(
type
=
'MultiViewPointFusion'
,
img_channels
=
2048
,
pts_channels
=
64
,
mid_channels
=
128
,
out_channels
=
128
,
norm_cfg
=
dict
(
type
=
'naiveSyncBN1d'
,
eps
=
1e-3
,
momentum
=
0.01
),
img_levels
=
[
3
],
align_corners
=
False
,
activate_out
=
True
,
fuse_out
=
False
),
),
pts_middle_encoder
=
dict
(
type
=
'PointPillarsScatter'
,
in_channels
=
128
,
output_shape
=
[
400
,
400
],
# checked from PointCloud3D
),
pts_backbone
=
dict
(
type
=
'SECOND'
,
in_channels
=
128
,
norm_cfg
=
dict
(
type
=
'naiveSyncBN2d'
,
eps
=
1e-3
,
momentum
=
0.01
),
layer_nums
=
[
3
,
5
,
5
],
layer_strides
=
[
2
,
2
,
2
],
num_filters
=
[
64
,
128
,
256
],
),
pts_neck
=
dict
(
type
=
'SECONDFPN'
,
norm_cfg
=
dict
(
type
=
'naiveSyncBN2d'
,
eps
=
1e-3
,
momentum
=
0.01
),
in_channels
=
[
64
,
128
,
256
],
upsample_strides
=
[
1
,
2
,
4
],
num_upsample_filters
=
[
128
,
128
,
128
],
),
pts_bbox_head
=
dict
(
type
=
'Anchor3DVeloHead'
,
class_names
=
class_names
,
num_classes
=
10
,
in_channels
=
384
,
feat_channels
=
384
,
use_direction_classifier
=
True
,
encode_bg_as_zeros
=
True
,
anchor_generator
=
dict
(
type
=
'AlignedAnchorGeneratorRange'
,
),
anchor_range
=
[
[
-
50
,
-
50
,
-
1.80032795
,
50
,
50
,
-
1.80032795
],
# car
[
-
50
,
-
50
,
-
1.74440365
,
50
,
50
,
-
1.74440365
],
# truck
[
-
50
,
-
50
,
-
1.68526504
,
50
,
50
,
-
1.68526504
],
# trailer
[
-
50
,
-
50
,
-
1.67339111
,
50
,
50
,
-
1.67339111
],
# bicycle
[
-
50
,
-
50
,
-
1.61785072
,
50
,
50
,
-
1.61785072
],
# pedestrian
[
-
50
,
-
50
,
-
1.80984986
,
50
,
50
,
-
1.80984986
],
# traffic_cone
[
-
50
,
-
50
,
-
1.763965
,
50
,
50
,
-
1.763965
],
# barrier
],
anchor_strides
=
[
2
],
anchor_sizes
=
[
[
1.95017717
,
4.60718145
,
1.72270761
],
# car
[
2.4560939
,
6.73778078
,
2.73004906
],
# truck
[
2.87427237
,
12.01320693
,
3.81509561
],
# trailer
[
0.60058911
,
1.68452161
,
1.27192197
],
# bicycle
[
0.66344886
,
0.7256437
,
1.75748069
],
# pedestrian
[
0.39694519
,
0.40359262
,
1.06232151
],
# traffic_cone
[
2.49008838
,
0.48578221
,
0.98297065
],
# barrier
],
anchor_custom_values
=
[
0
,
0
],
anchor_rotations
=
[
0
,
1.57
],
assigner_per_size
=
False
,
assign_per_class
=
False
,
diff_rad_by_sin
=
True
,
dir_offset
=
0.7854
,
# pi/4
dir_limit_offset
=
0
,
bbox_coder
=
dict
(
type
=
'ResidualCoder'
,
),
loss_cls
=
dict
(
type
=
'FocalLoss'
,
use_sigmoid
=
True
,
gamma
=
2.0
,
alpha
=
0.25
,
loss_weight
=
1.0
),
loss_bbox
=
dict
(
type
=
'SmoothL1Loss'
,
beta
=
1.0
/
9.0
,
loss_weight
=
1.0
),
loss_dir
=
dict
(
type
=
'CrossEntropyLoss'
,
use_sigmoid
=
False
,
loss_weight
=
0.2
),
),
)
# model training and testing settings
train_cfg
=
dict
(
pts
=
dict
(
assigner
=
dict
(
# for Car
type
=
'MaxIoUAssigner'
,
iou_type
=
'nearest_3d'
,
pos_iou_thr
=
0.6
,
neg_iou_thr
=
0.3
,
min_pos_iou
=
0.3
,
ignore_iof_thr
=-
1
),
allowed_border
=
0
,
code_weight
=
[
1.0
,
1.0
,
1.0
,
1.0
,
1.0
,
1.0
,
1.0
,
0.2
,
0.2
],
pos_weight
=-
1
,
debug
=
False
))
test_cfg
=
dict
(
pts
=
dict
(
use_rotate_nms
=
True
,
nms_across_levels
=
False
,
nms_pre
=
1000
,
nms_thr
=
0.2
,
score_thr
=
0.05
,
min_bbox_size
=
0
,
max_per_img
=
500
,
post_center_limit_range
=
point_cloud_range
,
# TODO: check whether need to change this
# post_center_limit_range=[-59.6, -59.6, -6, 59.6, 59.6, 4],
# soft-nms is also supported for rcnn testing
# e.g., nms=dict(type='soft_nms', iou_thr=0.5, min_score=0.05)
))
# dataset settings
dataset_type
=
'NuScenesDataset'
data_root
=
'data/nuscenes/'
img_norm_cfg
=
dict
(
mean
=
[
103.530
,
116.280
,
123.675
],
std
=
[
1.0
,
1.0
,
1.0
],
to_rgb
=
False
)
input_modality
=
dict
(
use_lidar
=
True
,
use_radar
=
False
,
use_map
=
False
,
use_external
=
False
,
use_camera
=
True
,
)
db_sampler
=
dict
(
root_path
=
data_root
,
info_path
=
data_root
+
'nuscenes_dbinfos_train.pkl'
,
rate
=
1.0
,
use_road_plane
=
False
,
object_rot_range
=
[
0.0
,
0.0
],
prepare
=
dict
(),
sample_groups
=
dict
(
bus
=
4
,
trailer
=
4
,
truck
=
4
,
),
)
train_pipeline
=
[
dict
(
type
=
'Resize'
,
img_scale
=
(
1280
,
720
),
ratio_range
=
(
0.8
,
1.2
),
keep_ratio
=
True
),
dict
(
type
=
'GlobalRotScale'
,
rot_uniform_noise
=
[
-
0.3925
,
0.3925
],
scaling_uniform_noise
=
[
0.95
,
1.05
],
trans_normal_noise
=
[
0
,
0
,
0
]),
dict
(
type
=
'RandomFlip3D'
,
flip_ratio
=
0.5
),
dict
(
type
=
'PointsRangeFilter'
,
point_cloud_range
=
point_cloud_range
),
dict
(
type
=
'ObjectRangeFilter'
,
point_cloud_range
=
point_cloud_range
),
dict
(
type
=
'PointShuffle'
),
dict
(
type
=
'Normalize'
,
**
img_norm_cfg
),
dict
(
type
=
'Pad'
,
size_divisor
=
32
),
dict
(
type
=
'DefaultFormatBundle3D'
,
class_names
=
class_names
),
dict
(
type
=
'Collect3D'
,
keys
=
[
'img'
,
'points'
,
'gt_bboxes_3d'
,
'gt_labels_3d'
]),
]
test_pipeline
=
[
dict
(
type
=
'PointsRangeFilter'
,
point_cloud_range
=
point_cloud_range
),
dict
(
type
=
'Resize'
,
img_scale
=
[
(
1280
,
720
),
],
multiscale_mode
=
'value'
,
keep_ratio
=
True
),
dict
(
type
=
'Normalize'
,
**
img_norm_cfg
),
dict
(
type
=
'Pad'
,
size_divisor
=
32
),
dict
(
type
=
'DefaultFormatBundle3D'
,
class_names
=
class_names
,
with_label
=
False
),
dict
(
type
=
'Collect3D'
,
keys
=
[
'points'
,
'img'
]),
]
data
=
dict
(
samples_per_gpu
=
1
,
workers_per_gpu
=
2
,
train
=
dict
(
type
=
dataset_type
,
root_path
=
data_root
,
ann_file
=
data_root
+
'nuscenes_infos_train.pkl'
,
pipeline
=
train_pipeline
,
modality
=
input_modality
,
class_names
=
class_names
,
with_label
=
True
),
val
=
dict
(
type
=
dataset_type
,
root_path
=
data_root
,
ann_file
=
data_root
+
'nuscenes_infos_val.pkl'
,
pipeline
=
test_pipeline
,
modality
=
input_modality
,
class_names
=
class_names
,
with_label
=
True
),
test
=
dict
(
type
=
dataset_type
,
root_path
=
data_root
,
ann_file
=
data_root
+
'nuscenes_infos_test.pkl'
,
pipeline
=
test_pipeline
,
modality
=
input_modality
,
class_names
=
class_names
,
with_label
=
False
))
# optimizer
optimizer
=
dict
(
type
=
'AdamW'
,
lr
=
0.001
,
weight_decay
=
0.01
)
# max_norm=10 is better for SECOND
optimizer_config
=
dict
(
grad_clip
=
dict
(
max_norm
=
35
,
norm_type
=
2
))
lr_config
=
dict
(
policy
=
'step'
,
warmup
=
'linear'
,
warmup_iters
=
1000
,
warmup_ratio
=
1.0
/
1000
,
step
=
[
16
,
19
])
momentum_config
=
None
checkpoint_config
=
dict
(
interval
=
1
)
# yapf:disable
evaluation
=
dict
(
interval
=
20
)
log_config
=
dict
(
interval
=
50
,
hooks
=
[
dict
(
type
=
'TextLoggerHook'
),
dict
(
type
=
'TensorboardLoggerHook'
)
])
# yapf:enable
# runtime settings
total_epochs
=
20
dist_params
=
dict
(
backend
=
'nccl'
)
log_level
=
'INFO'
work_dir
=
'./work_dirs/pp_secfpn_80e'
load_from
=
'./pretrain_mmdet/mvx_faster_rcnn_r50_fpn_detectron2-caffe_freezeBN_l1-loss_roialign-v2_nus_1x_coco-3x-pre_ap-28.8-4e72d8c7.pth'
# noqa
resume_from
=
None
workflow
=
[(
'train'
,
1
)]
mmdet3d/core/__init__.py
View file @
ba492be7
...
@@ -4,5 +4,4 @@ from .evaluation import * # noqa: F401, F403
...
@@ -4,5 +4,4 @@ from .evaluation import * # noqa: F401, F403
from
.optimizer
import
*
# noqa: F401, F403
from
.optimizer
import
*
# noqa: F401, F403
from
.post_processing
import
*
# noqa: F401, F403
from
.post_processing
import
*
# noqa: F401, F403
from
.utils
import
*
# noqa: F401, F403
from
.utils
import
*
# noqa: F401, F403
from
.voxel
import
*
# noqa: F401, F403
# from .voxel import * # noqa: F401, F403
mmdet3d/core/anchor/__init__.py
View file @
ba492be7
...
@@ -2,8 +2,7 @@ from .anchor_generator import (AlignedAnchorGeneratorRange, AnchorGenerator,
...
@@ -2,8 +2,7 @@ from .anchor_generator import (AlignedAnchorGeneratorRange, AnchorGenerator,
AnchorGeneratorRange
)
AnchorGeneratorRange
)
__all__
=
[
__all__
=
[
'AnchorGenerator'
,
'anchor_inside_flags'
,
'images_to_levels'
,
'unmap'
,
'AnchorGenerator'
,
'AlignedAnchorGeneratorRange'
,
'AnchorGeneratorRange'
,
'AlignedAnchorGeneratorRange'
,
'AnchorGeneratorRange'
,
'build_anchor_generator'
'build_anchor_generator'
]
]
...
...
mmdet3d/core/bbox/__init__.py
View file @
ba492be7
...
@@ -2,8 +2,8 @@ from . import box_torch_ops
...
@@ -2,8 +2,8 @@ from . import box_torch_ops
from
.assigners
import
AssignResult
,
BaseAssigner
,
MaxIoUAssigner
from
.assigners
import
AssignResult
,
BaseAssigner
,
MaxIoUAssigner
from
.coders
import
ResidualCoder
from
.coders
import
ResidualCoder
# from .bbox_target import bbox_target
# from .bbox_target import bbox_target
from
.
geometry
import
(
b
box
_o
verlaps
_2d
,
b
box
_o
verlaps
_3d
,
from
.
iou_calculators
import
(
B
box
O
verlaps
3D
,
B
box
O
verlaps
Nearest3D
,
bbox_overlaps_nearest_3d
)
bbox_overlaps_3d
,
bbox_overlaps_nearest_3d
)
from
.samplers
import
(
BaseSampler
,
CombinedSampler
,
from
.samplers
import
(
BaseSampler
,
CombinedSampler
,
InstanceBalancedPosSampler
,
IoUBalancedNegSampler
,
InstanceBalancedPosSampler
,
IoUBalancedNegSampler
,
PseudoSampler
,
RandomSampler
,
SamplingResult
)
PseudoSampler
,
RandomSampler
,
SamplingResult
)
...
@@ -17,33 +17,12 @@ from .assign_sampling import ( # isort:skip, avoid recursive imports
...
@@ -17,33 +17,12 @@ from .assign_sampling import ( # isort:skip, avoid recursive imports
assign_and_sample
,
build_assigner
,
build_sampler
)
assign_and_sample
,
build_assigner
,
build_sampler
)
__all__
=
[
__all__
=
[
'BaseAssigner'
,
'BaseAssigner'
,
'MaxIoUAssigner'
,
'AssignResult'
,
'BaseSampler'
,
'MaxIoUAssigner'
,
'PseudoSampler'
,
'RandomSampler'
,
'InstanceBalancedPosSampler'
,
'AssignResult'
,
'IoUBalancedNegSampler'
,
'CombinedSampler'
,
'SamplingResult'
,
'bbox2delta'
,
'BaseSampler'
,
'delta2bbox'
,
'bbox_flip'
,
'bbox_mapping'
,
'bbox_mapping_back'
,
'bbox2roi'
,
'PseudoSampler'
,
'roi2bbox'
,
'bbox2result_coco'
,
'distance2bbox'
,
'build_assigner'
,
'RandomSampler'
,
'build_sampler'
,
'assign_and_sample'
,
'box_torch_ops'
,
'build_bbox_coder'
,
'InstanceBalancedPosSampler'
,
'ResidualCoder'
,
'boxes3d_to_bev_torch_lidar'
,
'BboxOverlapsNearest3D'
,
'IoUBalancedNegSampler'
,
'BboxOverlaps3D'
,
'bbox_overlaps_nearest_3d'
,
'bbox_overlaps_3d'
'CombinedSampler'
,
'SamplingResult'
,
'bbox2delta'
,
'delta2bbox'
,
'bbox_flip'
,
'bbox_mapping'
,
'bbox_mapping_back'
,
'bbox2roi'
,
'roi2bbox'
,
'bbox2result_coco'
,
'distance2bbox'
,
# 'bbox2result_kitti',
'build_assigner'
,
'build_sampler'
,
'assign_and_sample'
,
'bbox_overlaps_2d'
,
'bbox_overlaps_3d'
,
'bbox_overlaps_nearest_3d'
,
'box_torch_ops'
,
'build_bbox_coder'
,
'ResidualCoder'
,
'boxes3d_to_bev_torch_lidar'
]
]
mmdet3d/core/bbox/assigners/__init__.py
View file @
ba492be7
from
.approx_max_iou_assigner
import
ApproxMaxIoUAssigner
from
mmdet.core.bbox
import
AssignResult
,
BaseAssigner
,
MaxIoUAssigner
from
.assign_result
import
AssignResult
from
.base_assigner
import
BaseAssigner
from
.max_iou_assigner
import
MaxIoUAssigner
__all__
=
[
__all__
=
[
'BaseAssigner'
,
'MaxIoUAssigner'
,
'AssignResult'
]
'BaseAssigner'
,
'MaxIoUAssigner'
,
'ApproxMaxIoUAssigner'
,
'AssignResult'
]
mmdet3d/core/bbox/assigners/approx_max_iou_assigner.py
deleted
100644 → 0
View file @
9466dff7
import
torch
from
..geometry
import
bbox_overlaps_2d
from
.max_iou_assigner
import
MaxIoUAssigner
class
ApproxMaxIoUAssigner
(
MaxIoUAssigner
):
"""Assign a corresponding gt bbox or background to each bbox.
Each proposals will be assigned with `-1`, `0`, or a positive integer
indicating the ground truth index.
- -1: don't care
- 0: negative sample, no assigned gt
- positive integer: positive sample, index (1-based) of assigned gt
Args:
pos_iou_thr (float): IoU threshold for positive bboxes.
neg_iou_thr (float or tuple): IoU threshold for negative bboxes.
min_pos_iou (float): Minimum iou for a bbox to be considered as a
positive bbox. Positive samples can have smaller IoU than
pos_iou_thr due to the 4th step (assign max IoU sample to each gt).
gt_max_assign_all (bool): Whether to assign all bboxes with the same
highest overlap with some gt to that gt.
ignore_iof_thr (float): IoF threshold for ignoring bboxes (if
`gt_bboxes_ignore` is specified). Negative values mean not
ignoring any bboxes.
ignore_wrt_candidates (bool): Whether to compute the iof between
`bboxes` and `gt_bboxes_ignore`, or the contrary.
"""
def
__init__
(
self
,
pos_iou_thr
,
neg_iou_thr
,
min_pos_iou
=
.
0
,
gt_max_assign_all
=
True
,
ignore_iof_thr
=-
1
,
ignore_wrt_candidates
=
True
):
self
.
pos_iou_thr
=
pos_iou_thr
self
.
neg_iou_thr
=
neg_iou_thr
self
.
min_pos_iou
=
min_pos_iou
self
.
gt_max_assign_all
=
gt_max_assign_all
self
.
ignore_iof_thr
=
ignore_iof_thr
self
.
ignore_wrt_candidates
=
ignore_wrt_candidates
def
assign
(
self
,
approxs
,
squares
,
approxs_per_octave
,
gt_bboxes
,
gt_bboxes_ignore
=
None
,
gt_labels
=
None
):
"""Assign gt to approxs.
This method assign a gt bbox to each group of approxs (bboxes),
each group of approxs is represent by a base approx (bbox) and
will be assigned with -1, 0, or a positive number.
-1 means don't care, 0 means negative sample,
positive number is the index (1-based) of assigned gt.
The assignment is done in following steps, the order matters.
1. assign every bbox to -1
2. use the max IoU of each group of approxs to assign
2. assign proposals whose iou with all gts < neg_iou_thr to 0
3. for each bbox, if the iou with its nearest gt >= pos_iou_thr,
assign it to that bbox
4. for each gt bbox, assign its nearest proposals (may be more than
one) to itself
Args:
approxs (Tensor): Bounding boxes to be assigned,
shape(approxs_per_octave*n, 4).
squares (Tensor): Base Bounding boxes to be assigned,
shape(n, 4).
approxs_per_octave (int): number of approxs per octave
gt_bboxes (Tensor): Groundtruth boxes, shape (k, 4).
gt_bboxes_ignore (Tensor, optional): Ground truth bboxes that are
labelled as `ignored`, e.g., crowd boxes in COCO.
gt_labels (Tensor, optional): Label of gt_bboxes, shape (k, ).
Returns:
:obj:`AssignResult`: The assign result.
"""
if
squares
.
shape
[
0
]
==
0
or
gt_bboxes
.
shape
[
0
]
==
0
:
raise
ValueError
(
'No gt or approxs'
)
num_squares
=
squares
.
size
(
0
)
num_gts
=
gt_bboxes
.
size
(
0
)
# re-organize anchors by approxs_per_octave x num_squares
approxs
=
torch
.
transpose
(
approxs
.
view
(
num_squares
,
approxs_per_octave
,
4
),
0
,
1
).
contiguous
().
view
(
-
1
,
4
)
all_overlaps
=
bbox_overlaps_2d
(
approxs
,
gt_bboxes
)
overlaps
,
_
=
all_overlaps
.
view
(
approxs_per_octave
,
num_squares
,
num_gts
).
max
(
dim
=
0
)
overlaps
=
torch
.
transpose
(
overlaps
,
0
,
1
)
bboxes
=
squares
[:,
:
4
]
if
(
self
.
ignore_iof_thr
>
0
)
and
(
gt_bboxes_ignore
is
not
None
)
and
(
gt_bboxes_ignore
.
numel
()
>
0
):
if
self
.
ignore_wrt_candidates
:
ignore_overlaps
=
bbox_overlaps_2d
(
bboxes
,
gt_bboxes_ignore
,
mode
=
'iof'
)
ignore_max_overlaps
,
_
=
ignore_overlaps
.
max
(
dim
=
1
)
else
:
ignore_overlaps
=
bbox_overlaps_2d
(
gt_bboxes_ignore
,
bboxes
,
mode
=
'iof'
)
ignore_max_overlaps
,
_
=
ignore_overlaps
.
max
(
dim
=
0
)
overlaps
[:,
ignore_max_overlaps
>
self
.
ignore_iof_thr
]
=
-
1
assign_result
=
self
.
assign_wrt_overlaps
(
overlaps
,
gt_labels
)
return
assign_result
mmdet3d/core/bbox/assigners/assign_result.py
deleted
100644 → 0
View file @
9466dff7
import
torch
class
AssignResult
(
object
):
def
__init__
(
self
,
num_gts
,
gt_inds
,
max_overlaps
,
labels
=
None
):
self
.
num_gts
=
num_gts
self
.
gt_inds
=
gt_inds
self
.
max_overlaps
=
max_overlaps
self
.
labels
=
labels
def
add_gt_
(
self
,
gt_labels
):
self_inds
=
torch
.
arange
(
1
,
len
(
gt_labels
)
+
1
,
dtype
=
torch
.
long
,
device
=
gt_labels
.
device
)
self
.
gt_inds
=
torch
.
cat
([
self_inds
,
self
.
gt_inds
])
self
.
max_overlaps
=
torch
.
cat
(
[
self
.
max_overlaps
.
new_ones
(
self
.
num_gts
),
self
.
max_overlaps
])
if
self
.
labels
is
not
None
:
self
.
labels
=
torch
.
cat
([
gt_labels
,
self
.
labels
])
mmdet3d/core/bbox/assigners/base_assigner.py
deleted
100644 → 0
View file @
9466dff7
from
abc
import
ABCMeta
,
abstractmethod
class
BaseAssigner
(
metaclass
=
ABCMeta
):
@
abstractmethod
def
assign
(
self
,
bboxes
,
gt_bboxes
,
gt_bboxes_ignore
=
None
,
gt_labels
=
None
):
pass
mmdet3d/core/bbox/assigners/max_iou_assigner.py
deleted
100644 → 0
View file @
9466dff7
import
torch
from
..
import
geometry
from
.assign_result
import
AssignResult
from
.base_assigner
import
BaseAssigner
class
MaxIoUAssigner
(
BaseAssigner
):
"""Assign a corresponding gt bbox or background to each bbox.
Each proposals will be assigned with `-1`, `0`, or a positive integer
indicating the ground truth index.
- -1: don't care
- 0: negative sample, no assigned gt
- positive integer: positive sample, index (1-based) of assigned gt
Args:
pos_iou_thr (float): IoU threshold for positive bboxes.
neg_iou_thr (float or tuple): IoU threshold for negative bboxes.
min_pos_iou (float): Minimum iou for a bbox to be considered as a
positive bbox. Positive samples can have smaller IoU than
pos_iou_thr due to the 4th step (assign max IoU sample to each gt).
gt_max_assign_all (bool): Whether to assign all bboxes with the same
highest overlap with some gt to that gt.
ignore_iof_thr (float): IoF threshold for ignoring bboxes (if
`gt_bboxes_ignore` is specified). Negative values mean not
ignoring any bboxes.
ignore_wrt_candidates (bool): Whether to compute the iof between
`bboxes` and `gt_bboxes_ignore`, or the contrary.
"""
def
__init__
(
self
,
pos_iou_thr
,
neg_iou_thr
,
min_pos_iou
=
.
0
,
gt_max_assign_all
=
True
,
ignore_iof_thr
=-
1
,
iou_type
=
'2d'
,
ignore_wrt_candidates
=
True
):
self
.
pos_iou_thr
=
pos_iou_thr
self
.
neg_iou_thr
=
neg_iou_thr
self
.
min_pos_iou
=
min_pos_iou
self
.
gt_max_assign_all
=
gt_max_assign_all
self
.
ignore_iof_thr
=
ignore_iof_thr
self
.
ignore_wrt_candidates
=
ignore_wrt_candidates
# iou_type could be 2d, 3d, nearest_3d
self
.
iou_type
=
iou_type
self
.
bbox_overlaps
=
getattr
(
geometry
,
'bbox_overlaps_{}'
.
format
(
iou_type
))
def
assign
(
self
,
bboxes
,
gt_bboxes
,
gt_bboxes_ignore
=
None
,
gt_labels
=
None
):
"""Assign gt to bboxes.
This method assign a gt bbox to every bbox (proposal/anchor), each bbox
will be assigned with -1, 0, or a positive number. -1 means don't care,
0 means negative sample, positive number is the index (1-based) of
assigned gt.
The assignment is done in following steps, the order matters.
1. assign every bbox to -1
2. assign proposals whose iou with all gts < neg_iou_thr to 0
3. for each bbox, if the iou with its nearest gt >= pos_iou_thr,
assign it to that bbox
4. for each gt bbox, assign its nearest proposals (may be more than
one) to itself
Args:
bboxes (Tensor): Bounding boxes to be assigned, shape(n, 4).
gt_bboxes (Tensor): Groundtruth boxes, shape (k, 4).
gt_bboxes_ignore (Tensor, optional): Ground truth bboxes that are
labelled as `ignored`, e.g., crowd boxes in COCO.
gt_labels (Tensor, optional): Label of gt_bboxes, shape (k, ).
Returns:
:obj:`AssignResult`: The assign result.
"""
if
self
.
iou_type
==
'2d'
:
bboxes
=
bboxes
[:,
:
4
]
overlaps
=
self
.
bbox_overlaps
(
gt_bboxes
,
bboxes
)
if
(
self
.
ignore_iof_thr
>
0
)
and
(
gt_bboxes_ignore
is
not
None
)
and
(
gt_bboxes_ignore
.
numel
()
>
0
):
if
self
.
ignore_wrt_candidates
:
ignore_overlaps
=
self
.
bbox_overlaps
(
bboxes
,
gt_bboxes_ignore
,
mode
=
'iof'
)
ignore_max_overlaps
,
_
=
ignore_overlaps
.
max
(
dim
=
1
)
else
:
ignore_overlaps
=
self
.
bbox_overlaps
(
gt_bboxes_ignore
,
bboxes
,
mode
=
'iof'
)
ignore_max_overlaps
,
_
=
ignore_overlaps
.
max
(
dim
=
0
)
overlaps
[:,
ignore_max_overlaps
>
self
.
ignore_iof_thr
]
=
-
1
assign_result
=
self
.
assign_wrt_overlaps
(
overlaps
,
gt_labels
)
return
assign_result
def
assign_wrt_overlaps
(
self
,
overlaps
,
gt_labels
=
None
):
"""Assign w.r.t. the overlaps of bboxes with gts.
Args:
overlaps (Tensor): Overlaps between k gt_bboxes and n bboxes,
shape(k, n).
gt_labels (Tensor, optional): Labels of k gt_bboxes, shape (k, ).
Returns:
:obj:`AssignResult`: The assign result.
"""
num_gts
,
num_bboxes
=
overlaps
.
size
(
0
),
overlaps
.
size
(
1
)
# 1. assign -1 by default
assigned_gt_inds
=
overlaps
.
new_full
((
num_bboxes
,
),
-
1
,
dtype
=
torch
.
long
)
if
num_gts
==
0
or
num_bboxes
==
0
:
# No ground truth or boxes, return empty assignment
max_overlaps
=
overlaps
.
new_zeros
((
num_bboxes
,
))
if
num_gts
==
0
:
# No truth, assign everything to background
assigned_gt_inds
[:]
=
0
if
gt_labels
is
None
:
assigned_labels
=
None
else
:
assigned_labels
=
overlaps
.
new_zeros
((
num_bboxes
,
),
dtype
=
torch
.
long
)
return
AssignResult
(
num_gts
,
assigned_gt_inds
,
max_overlaps
,
labels
=
assigned_labels
)
# for each anchor, which gt best overlaps with it
# for each anchor, the max iou of all gts
max_overlaps
,
argmax_overlaps
=
overlaps
.
max
(
dim
=
0
)
# for each gt, which anchor best overlaps with it
# for each gt, the max iou of all proposals
gt_max_overlaps
,
gt_argmax_overlaps
=
overlaps
.
max
(
dim
=
1
)
# 2. assign negative: below
if
isinstance
(
self
.
neg_iou_thr
,
float
):
assigned_gt_inds
[(
max_overlaps
>=
0
)
&
(
max_overlaps
<
self
.
neg_iou_thr
)]
=
0
elif
isinstance
(
self
.
neg_iou_thr
,
tuple
):
assert
len
(
self
.
neg_iou_thr
)
==
2
assigned_gt_inds
[(
max_overlaps
>=
self
.
neg_iou_thr
[
0
])
&
(
max_overlaps
<
self
.
neg_iou_thr
[
1
])]
=
0
# 3. assign positive: above positive IoU threshold
pos_inds
=
max_overlaps
>=
self
.
pos_iou_thr
assigned_gt_inds
[
pos_inds
]
=
argmax_overlaps
[
pos_inds
]
+
1
# 4. assign fg: for each gt, proposals with highest IoU
for
i
in
range
(
num_gts
):
if
gt_max_overlaps
[
i
]
>=
self
.
min_pos_iou
:
if
self
.
gt_max_assign_all
:
max_iou_inds
=
overlaps
[
i
,
:]
==
gt_max_overlaps
[
i
]
assigned_gt_inds
[
max_iou_inds
]
=
i
+
1
else
:
assigned_gt_inds
[
gt_argmax_overlaps
[
i
]]
=
i
+
1
if
gt_labels
is
not
None
:
assigned_labels
=
assigned_gt_inds
.
new_zeros
((
num_bboxes
,
))
pos_inds
=
torch
.
nonzero
(
assigned_gt_inds
>
0
).
squeeze
()
if
pos_inds
.
numel
()
>
0
:
assigned_labels
[
pos_inds
]
=
gt_labels
[
assigned_gt_inds
[
pos_inds
]
-
1
]
else
:
assigned_labels
=
None
return
AssignResult
(
num_gts
,
assigned_gt_inds
,
max_overlaps
,
labels
=
assigned_labels
)
mmdet3d/core/bbox/geometry.py
deleted
100644 → 0
View file @
9466dff7
import
torch
from
mmdet3d.ops.iou3d
import
boxes_iou3d_gpu
from
.
import
box_torch_ops
def
bbox_overlaps_2d
(
bboxes1
,
bboxes2
,
mode
=
'iou'
,
is_aligned
=
False
):
"""Calculate overlap between two set of bboxes.
If ``is_aligned`` is ``False``, then calculate the ious between each bbox
of bboxes1 and bboxes2, otherwise the ious between each aligned pair of
bboxes1 and bboxes2.
Args:
bboxes1 (Tensor): shape (m, 4) in <x1, y1, x2, y2> format.
bboxes2 (Tensor): shape (n, 4) in <x1, y1, x2, y2> format.
If is_aligned is ``True``, then m and n must be equal.
mode (str): "iou" (intersection over union) or iof (intersection over
foreground).
Returns:
ious(Tensor): shape (m, n) if is_aligned == False else shape (m, 1)
Example:
>>> bboxes1 = torch.FloatTensor([
>>> [0, 0, 10, 10],
>>> [10, 10, 20, 20],
>>> [32, 32, 38, 42],
>>> ])
>>> bboxes2 = torch.FloatTensor([
>>> [0, 0, 10, 20],
>>> [0, 10, 10, 19],
>>> [10, 10, 20, 20],
>>> ])
>>> bbox_overlaps(bboxes1, bboxes2)
tensor([[0.5238, 0.0500, 0.0041],
[0.0323, 0.0452, 1.0000],
[0.0000, 0.0000, 0.0000]])
Example:
>>> empty = torch.FloatTensor([])
>>> nonempty = torch.FloatTensor([
>>> [0, 0, 10, 9],
>>> ])
>>> assert tuple(bbox_overlaps(empty, nonempty).shape) == (0, 1)
>>> assert tuple(bbox_overlaps(nonempty, empty).shape) == (1, 0)
>>> assert tuple(bbox_overlaps(empty, empty).shape) == (0, 0)
"""
assert
mode
in
[
'iou'
,
'iof'
]
rows
=
bboxes1
.
size
(
0
)
cols
=
bboxes2
.
size
(
0
)
if
is_aligned
:
assert
rows
==
cols
if
rows
*
cols
==
0
:
return
bboxes1
.
new
(
rows
,
1
)
if
is_aligned
else
bboxes1
.
new
(
rows
,
cols
)
if
is_aligned
:
lt
=
torch
.
max
(
bboxes1
[:,
:
2
],
bboxes2
[:,
:
2
])
# [rows, 2]
rb
=
torch
.
min
(
bboxes1
[:,
2
:],
bboxes2
[:,
2
:])
# [rows, 2]
wh
=
(
rb
-
lt
).
clamp
(
min
=
0
)
# [rows, 2]
overlap
=
wh
[:,
0
]
*
wh
[:,
1
]
area1
=
(
bboxes1
[:,
2
]
-
bboxes1
[:,
0
])
*
(
bboxes1
[:,
3
]
-
bboxes1
[:,
1
])
if
mode
==
'iou'
:
area2
=
(
bboxes2
[:,
2
]
-
bboxes2
[:,
0
])
*
(
bboxes2
[:,
3
]
-
bboxes2
[:,
1
])
ious
=
overlap
/
(
area1
+
area2
-
overlap
)
else
:
ious
=
overlap
/
area1
else
:
lt
=
torch
.
max
(
bboxes1
[:,
None
,
:
2
],
bboxes2
[:,
:
2
])
# [rows, cols, 2]
rb
=
torch
.
min
(
bboxes1
[:,
None
,
2
:],
bboxes2
[:,
2
:])
# [rows, cols, 2]
wh
=
(
rb
-
lt
).
clamp
(
min
=
0
)
# [rows, cols, 2]
overlap
=
wh
[:,
:,
0
]
*
wh
[:,
:,
1
]
area1
=
(
bboxes1
[:,
2
]
-
bboxes1
[:,
0
])
*
(
bboxes1
[:,
3
]
-
bboxes1
[:,
1
])
if
mode
==
'iou'
:
area2
=
(
bboxes2
[:,
2
]
-
bboxes2
[:,
0
])
*
(
bboxes2
[:,
3
]
-
bboxes2
[:,
1
])
ious
=
overlap
/
(
area1
[:,
None
]
+
area2
-
overlap
)
else
:
ious
=
overlap
/
(
area1
[:,
None
])
return
ious
def
bbox_overlaps_3d
(
bboxes1
,
bboxes2
,
mode
=
'iou'
):
'''
:param bboxes1: Tensor, shape (N, 7) [x, y, z, h, w, l, ry]
:param bboxes2: Tensor, shape (M, 7) [x, y, z, h, w, l, ry]
:param mode: mode (str): "iou" (intersection over union) or
iof (intersection over foreground).
:return: iou: (M, N) not support aligned mode currently
'''
# TODO: check the input dimension meanings,
# this is inconsistent with that in bbox_overlaps_nearest_3d
return
boxes_iou3d_gpu
(
bboxes1
,
bboxes2
,
mode
)
def
bbox_overlaps_nearest_3d
(
bboxes1
,
bboxes2
,
mode
=
'iou'
,
is_aligned
=
False
):
'''
:param bboxes1: Tensor, shape (N, 7) [x, y, z, h, w, l, ry]?
:param bboxes2: Tensor, shape (M, 7) [x, y, z, h, w, l, ry]?
:param mode: mode (str): "iou" (intersection over union) or iof
(intersection over foreground).
:return: iou: (M, N) not support aligned mode currently
rbboxes: [N, 5(x, y, xdim, ydim, rad)] rotated bboxes
'''
# TODO: check the input dimension meanings,
# this is inconsistent with that in bbox_overlaps_3d
rbboxes1_np
=
bboxes1
.
index_select
(
dim
=-
1
,
index
=
bboxes1
.
new_tensor
([
0
,
1
,
3
,
4
,
6
]).
long
())
rbboxes2_np
=
bboxes2
.
index_select
(
dim
=-
1
,
index
=
bboxes1
.
new_tensor
([
0
,
1
,
3
,
4
,
6
]).
long
())
# Change the bboxes to bev
# box conversion and iou calculation in torch version on CUDA
# is 10x faster than that in numpy version
bboxes1_bv
=
box_torch_ops
.
rbbox2d_to_near_bbox
(
rbboxes1_np
)
bboxes2_bv
=
box_torch_ops
.
rbbox2d_to_near_bbox
(
rbboxes2_np
)
ret
=
bbox_overlaps_2d
(
bboxes1_bv
,
bboxes2_bv
,
mode
=
mode
,
is_aligned
=
is_aligned
)
return
ret
mmdet3d/core/bbox/iou_calculators/__init__.py
0 → 100644
View file @
ba492be7
from
.iou3d_calculator
import
(
BboxOverlaps3D
,
BboxOverlapsNearest3D
,
bbox_overlaps_3d
,
bbox_overlaps_nearest_3d
)
__all__
=
[
'BboxOverlapsNearest3D'
,
'BboxOverlaps3D'
,
'bbox_overlaps_nearest_3d'
,
'bbox_overlaps_3d'
]
Prev
1
2
3
4
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