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
bdb3c14d
Commit
bdb3c14d
authored
May 19, 2020
by
zhangwenwei
Browse files
Refactor pipeline
parent
db986fa4
Changes
30
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
126 additions
and
101 deletions
+126
-101
mmdet3d/datasets/scannet_dataset.py
mmdet3d/datasets/scannet_dataset.py
+13
-15
mmdet3d/datasets/sunrgbd_dataset.py
mmdet3d/datasets/sunrgbd_dataset.py
+11
-13
mmdet3d/models/detectors/parta2.py
mmdet3d/models/detectors/parta2.py
+1
-6
mmdet3d/models/roi_heads/bbox_heads/parta2_bbox_head.py
mmdet3d/models/roi_heads/bbox_heads/parta2_bbox_head.py
+1
-2
tests/data/kitti/a.bin
tests/data/kitti/a.bin
+0
-0
tests/test_anchor.py
tests/test_anchor.py
+1
-1
tests/test_dataset/test_scannet_dataset.py
tests/test_dataset/test_scannet_dataset.py
+12
-6
tests/test_dataset/test_sunrgbd_dataset.py
tests/test_dataset/test_sunrgbd_dataset.py
+8
-6
tests/test_pipeline/test_indoor_pipeline.py
tests/test_pipeline/test_indoor_pipeline.py
+31
-22
tests/test_pipeline/test_loading.py
tests/test_pipeline/test_loading.py
+48
-30
No files found.
mmdet3d/datasets/scannet_dataset.py
View file @
bdb3c14d
...
@@ -3,11 +3,11 @@ import os.path as osp
...
@@ -3,11 +3,11 @@ import os.path as osp
import
numpy
as
np
import
numpy
as
np
from
mmdet.datasets
import
DATASETS
from
mmdet.datasets
import
DATASETS
from
.
indoor_base_dataset
import
IndoorBase
Dataset
from
.
custom_3d
import
Custom3D
Dataset
@
DATASETS
.
register_module
()
@
DATASETS
.
register_module
()
class
ScanNetDataset
(
IndoorBase
Dataset
):
class
ScanNetDataset
(
Custom3D
Dataset
):
CLASSES
=
(
'cabinet'
,
'bed'
,
'chair'
,
'sofa'
,
'table'
,
'door'
,
'window'
,
CLASSES
=
(
'cabinet'
,
'bed'
,
'chair'
,
'sofa'
,
'table'
,
'door'
,
'window'
,
'bookshelf'
,
'picture'
,
'counter'
,
'desk'
,
'curtain'
,
'bookshelf'
,
'picture'
,
'counter'
,
'desk'
,
'curtain'
,
...
@@ -15,38 +15,36 @@ class ScanNetDataset(IndoorBaseDataset):
...
@@ -15,38 +15,36 @@ class ScanNetDataset(IndoorBaseDataset):
'garbagebin'
)
'garbagebin'
)
def
__init__
(
self
,
def
__init__
(
self
,
root_path
,
data_root
,
ann_file
,
ann_file
,
pipeline
=
None
,
pipeline
=
None
,
classes
=
None
,
classes
=
None
,
test_mode
=
False
,
test_mode
=
False
):
with_label
=
True
):
super
().
__init__
(
data_root
,
ann_file
,
pipeline
,
classes
,
test_mode
)
super
().
__init__
(
root_path
,
ann_file
,
pipeline
,
classes
,
test_mode
,
with_label
)
def
_get_pts_filename
(
self
,
sample_idx
):
def
_get_pts_filename
(
self
,
sample_idx
):
pts_filename
=
osp
.
join
(
self
.
root_path
,
f
'
{
sample_idx
}
_vert.npy'
)
pts_filename
=
osp
.
join
(
self
.
data_root
,
f
'
{
sample_idx
}
_vert.npy'
)
return
pts_filename
return
pts_filename
def
_
get_ann_info
(
self
,
index
,
sample_idx
):
def
get_ann_info
(
self
,
index
,
sample_idx
):
# 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
]
if
info
[
'annos'
][
'gt_num'
]
!=
0
:
if
info
[
'annos'
][
'gt_num'
]
!=
0
:
gt_bboxes_3d
=
info
[
'annos'
][
'gt_boxes_upright_depth'
]
# k, 6
gt_bboxes_3d
=
info
[
'annos'
][
'gt_boxes_upright_depth'
]
# k, 6
gt_labels
=
info
[
'annos'
][
'class'
]
gt_labels
_3d
=
info
[
'annos'
][
'class'
]
gt_bboxes_3d_mask
=
np
.
ones_like
(
gt_labels
,
dtype
=
np
.
bool
)
gt_bboxes_3d_mask
=
np
.
ones_like
(
gt_labels
_3d
,
dtype
=
np
.
bool
)
else
:
else
:
gt_bboxes_3d
=
np
.
zeros
((
1
,
6
),
dtype
=
np
.
float32
)
gt_bboxes_3d
=
np
.
zeros
((
1
,
6
),
dtype
=
np
.
float32
)
gt_labels
=
np
.
zeros
(
1
,
dtype
=
np
.
bool
)
gt_labels
_3d
=
np
.
zeros
(
1
,
dtype
=
np
.
bool
)
gt_bboxes_3d_mask
=
np
.
zeros
(
1
,
dtype
=
np
.
bool
)
gt_bboxes_3d_mask
=
np
.
zeros
(
1
,
dtype
=
np
.
bool
)
pts_instance_mask_path
=
osp
.
join
(
self
.
root_path
,
pts_instance_mask_path
=
osp
.
join
(
self
.
data_root
,
f
'
{
sample_idx
}
_ins_label.npy'
)
f
'
{
sample_idx
}
_ins_label.npy'
)
pts_semantic_mask_path
=
osp
.
join
(
self
.
root_path
,
pts_semantic_mask_path
=
osp
.
join
(
self
.
data_root
,
f
'
{
sample_idx
}
_sem_label.npy'
)
f
'
{
sample_idx
}
_sem_label.npy'
)
anns_results
=
dict
(
anns_results
=
dict
(
gt_bboxes_3d
=
gt_bboxes_3d
,
gt_bboxes_3d
=
gt_bboxes_3d
,
gt_labels
=
gt_labels
,
gt_labels
_3d
=
gt_labels
_3d
,
gt_bboxes_3d_mask
=
gt_bboxes_3d_mask
,
gt_bboxes_3d_mask
=
gt_bboxes_3d_mask
,
pts_instance_mask_path
=
pts_instance_mask_path
,
pts_instance_mask_path
=
pts_instance_mask_path
,
pts_semantic_mask_path
=
pts_semantic_mask_path
)
pts_semantic_mask_path
=
pts_semantic_mask_path
)
...
...
mmdet3d/datasets/sunrgbd_dataset.py
View file @
bdb3c14d
...
@@ -3,44 +3,42 @@ import os.path as osp
...
@@ -3,44 +3,42 @@ import os.path as osp
import
numpy
as
np
import
numpy
as
np
from
mmdet.datasets
import
DATASETS
from
mmdet.datasets
import
DATASETS
from
.
indoor_base_dataset
import
IndoorBase
Dataset
from
.
custom_3d
import
Custom3D
Dataset
@
DATASETS
.
register_module
()
@
DATASETS
.
register_module
()
class
SUNRGBDDataset
(
IndoorBase
Dataset
):
class
SUNRGBDDataset
(
Custom3D
Dataset
):
CLASSES
=
(
'bed'
,
'table'
,
'sofa'
,
'chair'
,
'toilet'
,
'desk'
,
'dresser'
,
CLASSES
=
(
'bed'
,
'table'
,
'sofa'
,
'chair'
,
'toilet'
,
'desk'
,
'dresser'
,
'night_stand'
,
'bookshelf'
,
'bathtub'
)
'night_stand'
,
'bookshelf'
,
'bathtub'
)
def
__init__
(
self
,
def
__init__
(
self
,
root_path
,
data_root
,
ann_file
,
ann_file
,
pipeline
=
None
,
pipeline
=
None
,
classes
=
None
,
classes
=
None
,
test_mode
=
False
,
test_mode
=
False
):
with_label
=
True
):
super
().
__init__
(
data_root
,
ann_file
,
pipeline
,
classes
,
test_mode
)
super
().
__init__
(
root_path
,
ann_file
,
pipeline
,
classes
,
test_mode
,
with_label
)
def
_get_pts_filename
(
self
,
sample_idx
):
def
_get_pts_filename
(
self
,
sample_idx
):
pts_filename
=
osp
.
join
(
self
.
root_path
,
'lidar'
,
pts_filename
=
osp
.
join
(
self
.
data_root
,
'lidar'
,
f
'
{
sample_idx
:
06
d
}
.npy'
)
f
'
{
sample_idx
:
06
d
}
.npy'
)
return
pts_filename
return
pts_filename
def
_
get_ann_info
(
self
,
index
,
sample_idx
):
def
get_ann_info
(
self
,
index
,
sample_idx
):
# 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
]
if
info
[
'annos'
][
'gt_num'
]
!=
0
:
if
info
[
'annos'
][
'gt_num'
]
!=
0
:
gt_bboxes_3d
=
info
[
'annos'
][
'gt_boxes_upright_depth'
]
# k, 6
gt_bboxes_3d
=
info
[
'annos'
][
'gt_boxes_upright_depth'
]
# k, 6
gt_labels
=
info
[
'annos'
][
'class'
]
gt_labels
_3d
=
info
[
'annos'
][
'class'
]
gt_bboxes_3d_mask
=
np
.
ones_like
(
gt_labels
,
dtype
=
np
.
bool
)
gt_bboxes_3d_mask
=
np
.
ones_like
(
gt_labels
_3d
,
dtype
=
np
.
bool
)
else
:
else
:
gt_bboxes_3d
=
np
.
zeros
((
1
,
6
),
dtype
=
np
.
float32
)
gt_bboxes_3d
=
np
.
zeros
((
1
,
6
),
dtype
=
np
.
float32
)
gt_labels
=
np
.
zeros
(
1
,
dtype
=
np
.
bool
)
gt_labels
_3d
=
np
.
zeros
(
1
,
dtype
=
np
.
bool
)
gt_bboxes_3d_mask
=
np
.
zeros
(
1
,
dtype
=
np
.
bool
)
gt_bboxes_3d_mask
=
np
.
zeros
(
1
,
dtype
=
np
.
bool
)
anns_results
=
dict
(
anns_results
=
dict
(
gt_bboxes_3d
=
gt_bboxes_3d
,
gt_bboxes_3d
=
gt_bboxes_3d
,
gt_labels
=
gt_labels
,
gt_labels
_3d
=
gt_labels
_3d
,
gt_bboxes_3d_mask
=
gt_bboxes_3d_mask
)
gt_bboxes_3d_mask
=
gt_bboxes_3d_mask
)
return
anns_results
return
anns_results
mmdet3d/models/detectors/parta2.py
View file @
bdb3c14d
...
@@ -119,12 +119,7 @@ class PartA2(TwoStageDetector):
...
@@ -119,12 +119,7 @@ class PartA2(TwoStageDetector):
else
:
else
:
return
self
.
forward_test
(
**
kwargs
)
return
self
.
forward_test
(
**
kwargs
)
def
simple_test
(
self
,
def
simple_test
(
self
,
points
,
img_meta
,
proposals
=
None
,
rescale
=
False
):
points
,
img_meta
,
gt_bboxes_3d
,
proposals
=
None
,
rescale
=
False
):
feats_dict
,
voxels_dict
=
self
.
extract_feat
(
points
,
img_meta
)
feats_dict
,
voxels_dict
=
self
.
extract_feat
(
points
,
img_meta
)
if
self
.
with_rpn
:
if
self
.
with_rpn
:
...
...
mmdet3d/models/roi_heads/bbox_heads/parta2_bbox_head.py
View file @
bdb3c14d
...
@@ -545,7 +545,6 @@ class PartA2BboxHead(nn.Module):
...
@@ -545,7 +545,6 @@ class PartA2BboxHead(nn.Module):
score_thr
,
score_thr
,
nms_thr
,
nms_thr
,
use_rotate_nms
=
True
):
use_rotate_nms
=
True
):
normalized_scores
=
torch
.
sigmoid
(
box_probs
)
if
use_rotate_nms
:
if
use_rotate_nms
:
nms_func
=
nms_gpu
nms_func
=
nms_gpu
else
:
else
:
...
@@ -562,7 +561,7 @@ class PartA2BboxHead(nn.Module):
...
@@ -562,7 +561,7 @@ class PartA2BboxHead(nn.Module):
nms_thresh
=
nms_thr
if
isinstance
(
nms_thresh
=
nms_thr
if
isinstance
(
nms_thr
,
list
)
else
[
nms_thr
for
x
in
range
(
self
.
num_classes
)]
nms_thr
,
list
)
else
[
nms_thr
for
x
in
range
(
self
.
num_classes
)]
for
k
in
range
(
0
,
self
.
num_classes
):
for
k
in
range
(
0
,
self
.
num_classes
):
class_scores_keep
=
normalized_score
s
[:,
k
]
>=
score_thresh
[
k
]
class_scores_keep
=
box_prob
s
[:,
k
]
>=
score_thresh
[
k
]
if
class_scores_keep
.
int
().
sum
()
>
0
:
if
class_scores_keep
.
int
().
sum
()
>
0
:
original_idxs
=
class_scores_keep
.
nonzero
().
view
(
-
1
)
original_idxs
=
class_scores_keep
.
nonzero
().
view
(
-
1
)
...
...
tests/data/kitti/a.bin
0 → 100644
View file @
bdb3c14d
File added
tests/test_anchor.py
View file @
bdb3c14d
...
@@ -17,7 +17,7 @@ def test_aligned_anchor_generator():
...
@@ -17,7 +17,7 @@ def test_aligned_anchor_generator():
anchor_generator_cfg
=
dict
(
anchor_generator_cfg
=
dict
(
type
=
'AlignedAnchor3DRangeGenerator'
,
type
=
'AlignedAnchor3DRangeGenerator'
,
ranges
=
[[
-
51.2
,
-
51.2
,
-
1.80
,
51.2
,
51.2
,
-
1.80
]],
ranges
=
[[
-
51.2
,
-
51.2
,
-
1.80
,
51.2
,
51.2
,
-
1.80
]],
s
trid
es
=
[
1
,
2
,
4
],
s
cal
es
=
[
1
,
2
,
4
],
sizes
=
[
sizes
=
[
[
0.8660
,
2.5981
,
1.
],
# 1.5/sqrt(3)
[
0.8660
,
2.5981
,
1.
],
# 1.5/sqrt(3)
[
0.5774
,
1.7321
,
1.
],
# 1/sqrt(3)
[
0.5774
,
1.7321
,
1.
],
# 1/sqrt(3)
...
...
tests/test_dataset/test_scannet_dataset.py
View file @
bdb3c14d
...
@@ -15,23 +15,28 @@ def test_getitem():
...
@@ -15,23 +15,28 @@ def test_getitem():
'sink'
,
'bathtub'
,
'garbagebin'
)
'sink'
,
'bathtub'
,
'garbagebin'
)
pipelines
=
[
pipelines
=
[
dict
(
dict
(
type
=
'
Indoor
LoadPointsFromFile'
,
type
=
'LoadPointsFromFile'
,
use
_height
=
True
,
shift
_height
=
True
,
load_dim
=
6
,
load_dim
=
6
,
use_dim
=
[
0
,
1
,
2
]),
use_dim
=
[
0
,
1
,
2
]),
dict
(
type
=
'IndoorLoadAnnotations3D'
),
dict
(
type
=
'LoadAnnotations3D'
,
with_bbox_3d
=
True
,
with_label_3d
=
True
,
with_mask_3d
=
True
,
with_seg_3d
=
True
),
dict
(
type
=
'IndoorPointSample'
,
num_points
=
5
),
dict
(
type
=
'IndoorPointSample'
,
num_points
=
5
),
dict
(
type
=
'IndoorFlipData'
,
flip_ratio_yz
=
1.0
,
flip_ratio_xz
=
1.0
),
dict
(
type
=
'IndoorFlipData'
,
flip_ratio_yz
=
1.0
,
flip_ratio_xz
=
1.0
),
dict
(
dict
(
type
=
'IndoorGlobalRotScale'
,
type
=
'IndoorGlobalRotScale'
,
use
_height
=
True
,
shift
_height
=
True
,
rot_range
=
[
-
1
/
36
,
1
/
36
],
rot_range
=
[
-
1
/
36
,
1
/
36
],
scale_range
=
None
),
scale_range
=
None
),
dict
(
type
=
'DefaultFormatBundle3D'
,
class_names
=
class_names
),
dict
(
type
=
'DefaultFormatBundle3D'
,
class_names
=
class_names
),
dict
(
dict
(
type
=
'Collect3D'
,
type
=
'Collect3D'
,
keys
=
[
keys
=
[
'points'
,
'gt_bboxes_3d'
,
'gt_labels'
,
'pts_semantic_mask'
,
'points'
,
'gt_bboxes_3d'
,
'gt_labels
_3d
'
,
'pts_semantic_mask'
,
'pts_instance_mask'
'pts_instance_mask'
]),
]),
]
]
...
@@ -40,7 +45,7 @@ def test_getitem():
...
@@ -40,7 +45,7 @@ def test_getitem():
data
=
scannet_dataset
[
0
]
data
=
scannet_dataset
[
0
]
points
=
data
[
'points'
].
_data
points
=
data
[
'points'
].
_data
gt_bboxes_3d
=
data
[
'gt_bboxes_3d'
].
_data
gt_bboxes_3d
=
data
[
'gt_bboxes_3d'
].
_data
gt_labels
=
data
[
'gt_labels'
].
_data
gt_labels
=
data
[
'gt_labels
_3d
'
].
_data
pts_semantic_mask
=
data
[
'pts_semantic_mask'
].
_data
pts_semantic_mask
=
data
[
'pts_semantic_mask'
].
_data
pts_instance_mask
=
data
[
'pts_instance_mask'
].
_data
pts_instance_mask
=
data
[
'pts_instance_mask'
].
_data
...
@@ -84,6 +89,7 @@ def test_getitem():
...
@@ -84,6 +89,7 @@ def test_getitem():
assert
scannet_dataset
.
CLASSES
!=
original_classes
assert
scannet_dataset
.
CLASSES
!=
original_classes
assert
scannet_dataset
.
CLASSES
==
(
'cabinet'
,
'bed'
)
assert
scannet_dataset
.
CLASSES
==
(
'cabinet'
,
'bed'
)
# Test load classes from file
import
tempfile
import
tempfile
tmp_file
=
tempfile
.
NamedTemporaryFile
()
tmp_file
=
tempfile
.
NamedTemporaryFile
()
with
open
(
tmp_file
.
name
,
'w'
)
as
f
:
with
open
(
tmp_file
.
name
,
'w'
)
as
f
:
...
...
tests/test_dataset/test_sunrgbd_dataset.py
View file @
bdb3c14d
...
@@ -13,26 +13,28 @@ def test_getitem():
...
@@ -13,26 +13,28 @@ def test_getitem():
'dresser'
,
'night_stand'
,
'bookshelf'
,
'bathtub'
)
'dresser'
,
'night_stand'
,
'bookshelf'
,
'bathtub'
)
pipelines
=
[
pipelines
=
[
dict
(
dict
(
type
=
'
Indoor
LoadPointsFromFile'
,
type
=
'LoadPointsFromFile'
,
use
_height
=
True
,
shift
_height
=
True
,
load_dim
=
6
,
load_dim
=
6
,
use_dim
=
[
0
,
1
,
2
]),
use_dim
=
[
0
,
1
,
2
]),
dict
(
type
=
'LoadAnnotations3D'
),
dict
(
type
=
'IndoorFlipData'
,
flip_ratio_yz
=
1.0
),
dict
(
type
=
'IndoorFlipData'
,
flip_ratio_yz
=
1.0
),
dict
(
dict
(
type
=
'IndoorGlobalRotScale'
,
type
=
'IndoorGlobalRotScale'
,
use
_height
=
True
,
shift
_height
=
True
,
rot_range
=
[
-
1
/
6
,
1
/
6
],
rot_range
=
[
-
1
/
6
,
1
/
6
],
scale_range
=
[
0.85
,
1.15
]),
scale_range
=
[
0.85
,
1.15
]),
dict
(
type
=
'IndoorPointSample'
,
num_points
=
5
),
dict
(
type
=
'IndoorPointSample'
,
num_points
=
5
),
dict
(
type
=
'DefaultFormatBundle3D'
,
class_names
=
class_names
),
dict
(
type
=
'DefaultFormatBundle3D'
,
class_names
=
class_names
),
dict
(
type
=
'Collect3D'
,
keys
=
[
'points'
,
'gt_bboxes_3d'
,
'gt_labels'
]),
dict
(
type
=
'Collect3D'
,
keys
=
[
'points'
,
'gt_bboxes_3d'
,
'gt_labels_3d'
]),
]
]
sunrgbd_dataset
=
SUNRGBDDataset
(
root_path
,
ann_file
,
pipelines
)
sunrgbd_dataset
=
SUNRGBDDataset
(
root_path
,
ann_file
,
pipelines
)
data
=
sunrgbd_dataset
[
0
]
data
=
sunrgbd_dataset
[
0
]
points
=
data
[
'points'
].
_data
points
=
data
[
'points'
].
_data
gt_bboxes_3d
=
data
[
'gt_bboxes_3d'
].
_data
gt_bboxes_3d
=
data
[
'gt_bboxes_3d'
].
_data
gt_labels
=
data
[
'gt_labels'
].
_data
gt_labels
_3d
=
data
[
'gt_labels
_3d
'
].
_data
expected_points
=
np
.
array
(
expected_points
=
np
.
array
(
[[
0.6570105
,
1.5538014
,
0.24514851
,
1.0165423
],
[[
0.6570105
,
1.5538014
,
0.24514851
,
1.0165423
],
...
@@ -59,7 +61,7 @@ def test_getitem():
...
@@ -59,7 +61,7 @@ def test_getitem():
assert
np
.
allclose
(
points
,
expected_points
)
assert
np
.
allclose
(
points
,
expected_points
)
assert
np
.
allclose
(
gt_bboxes_3d
,
expected_gt_bboxes_3d
)
assert
np
.
allclose
(
gt_bboxes_3d
,
expected_gt_bboxes_3d
)
assert
np
.
all
(
gt_labels
.
numpy
()
==
expected_gt_labels
)
assert
np
.
all
(
gt_labels
_3d
.
numpy
()
==
expected_gt_labels
)
assert
original_classes
==
class_names
assert
original_classes
==
class_names
SUNRGBD_dataset
=
SUNRGBDDataset
(
SUNRGBD_dataset
=
SUNRGBDDataset
(
...
...
tests/test_pipeline/test_indoor_pipeline.py
View file @
bdb3c14d
...
@@ -15,16 +15,21 @@ def test_scannet_pipeline():
...
@@ -15,16 +15,21 @@ def test_scannet_pipeline():
np
.
random
.
seed
(
0
)
np
.
random
.
seed
(
0
)
pipelines
=
[
pipelines
=
[
dict
(
dict
(
type
=
'
Indoor
LoadPointsFromFile'
,
type
=
'LoadPointsFromFile'
,
use
_height
=
True
,
shift
_height
=
True
,
load_dim
=
6
,
load_dim
=
6
,
use_dim
=
[
0
,
1
,
2
]),
use_dim
=
[
0
,
1
,
2
]),
dict
(
type
=
'IndoorLoadAnnotations3D'
),
dict
(
type
=
'LoadAnnotations3D'
,
with_bbox_3d
=
True
,
with_label_3d
=
True
,
with_mask_3d
=
True
,
with_seg_3d
=
True
),
dict
(
type
=
'IndoorPointSample'
,
num_points
=
5
),
dict
(
type
=
'IndoorPointSample'
,
num_points
=
5
),
dict
(
type
=
'IndoorFlipData'
,
flip_ratio_yz
=
1.0
,
flip_ratio_xz
=
1.0
),
dict
(
type
=
'IndoorFlipData'
,
flip_ratio_yz
=
1.0
,
flip_ratio_xz
=
1.0
),
dict
(
dict
(
type
=
'IndoorGlobalRotScale'
,
type
=
'IndoorGlobalRotScale'
,
use
_height
=
True
,
shift
_height
=
True
,
rot_range
=
[
-
1
/
36
,
1
/
36
],
rot_range
=
[
-
1
/
36
,
1
/
36
],
scale_range
=
None
),
scale_range
=
None
),
dict
(
type
=
'DefaultFormatBundle3D'
,
class_names
=
class_names
),
dict
(
type
=
'DefaultFormatBundle3D'
,
class_names
=
class_names
),
...
@@ -45,21 +50,21 @@ def test_scannet_pipeline():
...
@@ -45,21 +50,21 @@ def test_scannet_pipeline():
if
info
[
'annos'
][
'gt_num'
]
!=
0
:
if
info
[
'annos'
][
'gt_num'
]
!=
0
:
scannet_gt_bboxes_3d
=
info
[
'annos'
][
'gt_boxes_upright_depth'
]
scannet_gt_bboxes_3d
=
info
[
'annos'
][
'gt_boxes_upright_depth'
]
scannet_gt_labels_3d
=
info
[
'annos'
][
'class'
]
scannet_gt_labels_3d
=
info
[
'annos'
][
'class'
]
scannet_gt_bboxes_3d_mask
=
np
.
ones_like
(
scannet_gt_labels_3d
,
dtype
=
np
.
bool
)
else
:
else
:
scannet_gt_bboxes_3d
=
np
.
zeros
((
1
,
6
),
dtype
=
np
.
float32
)
scannet_gt_bboxes_3d
=
np
.
zeros
((
1
,
6
),
dtype
=
np
.
float32
)
scannet_gt_labels_3d
=
np
.
zeros
((
1
,
))
scannet_gt_labels_3d
=
np
.
zeros
((
1
,
))
scannet_gt_bboxes_3d_mask
=
np
.
zeros
((
1
,
),
dtype
=
np
.
bool
)
scan_name
=
info
[
'point_cloud'
][
'lidar_idx'
]
scan_name
=
info
[
'point_cloud'
][
'lidar_idx'
]
results
[
'ann_info'
]
=
dict
()
results
[
'ann_info'
][
'pts_instance_mask_path'
]
=
osp
.
join
(
data_path
,
f
'
{
scan_name
}
_ins_label.npy'
)
results
[
'ann_info'
][
'pts_semantic_mask_path'
]
=
osp
.
join
(
data_path
,
f
'
{
scan_name
}
_sem_label.npy'
)
results
[
'ann_info'
][
'gt_bboxes_3d'
]
=
scannet_gt_bboxes_3d
results
[
'ann_info'
][
'gt_labels_3d'
]
=
scannet_gt_labels_3d
results
[
'pts_instance_mask_path'
]
=
osp
.
join
(
data_path
,
results
[
'bbox3d_fields'
]
=
[]
f
'
{
scan_name
}
_ins_label.npy'
)
results
[
'pts_mask_fields'
]
=
[]
results
[
'pts_semantic_mask_path'
]
=
osp
.
join
(
data_path
,
results
[
'pts_seg_fields'
]
=
[]
f
'
{
scan_name
}
_sem_label.npy'
)
results
[
'gt_bboxes_3d'
]
=
scannet_gt_bboxes_3d
results
[
'gt_labels_3d'
]
=
scannet_gt_labels_3d
results
[
'gt_bboxes_3d_mask'
]
=
scannet_gt_bboxes_3d_mask
results
=
pipeline
(
results
)
results
=
pipeline
(
results
)
...
@@ -100,14 +105,15 @@ def test_sunrgbd_pipeline():
...
@@ -100,14 +105,15 @@ def test_sunrgbd_pipeline():
np
.
random
.
seed
(
0
)
np
.
random
.
seed
(
0
)
pipelines
=
[
pipelines
=
[
dict
(
dict
(
type
=
'
Indoor
LoadPointsFromFile'
,
type
=
'LoadPointsFromFile'
,
use
_height
=
True
,
shift
_height
=
True
,
load_dim
=
6
,
load_dim
=
6
,
use_dim
=
[
0
,
1
,
2
]),
use_dim
=
[
0
,
1
,
2
]),
dict
(
type
=
'LoadAnnotations3D'
),
dict
(
type
=
'IndoorFlipData'
,
flip_ratio_yz
=
1.0
),
dict
(
type
=
'IndoorFlipData'
,
flip_ratio_yz
=
1.0
),
dict
(
dict
(
type
=
'IndoorGlobalRotScale'
,
type
=
'IndoorGlobalRotScale'
,
use
_height
=
True
,
shift
_height
=
True
,
rot_range
=
[
-
1
/
6
,
1
/
6
],
rot_range
=
[
-
1
/
6
,
1
/
6
],
scale_range
=
[
0.85
,
1.15
]),
scale_range
=
[
0.85
,
1.15
]),
dict
(
type
=
'IndoorPointSample'
,
num_points
=
5
),
dict
(
type
=
'IndoorPointSample'
,
num_points
=
5
),
...
@@ -126,15 +132,18 @@ def test_sunrgbd_pipeline():
...
@@ -126,15 +132,18 @@ def test_sunrgbd_pipeline():
if
info
[
'annos'
][
'gt_num'
]
!=
0
:
if
info
[
'annos'
][
'gt_num'
]
!=
0
:
gt_bboxes_3d
=
info
[
'annos'
][
'gt_boxes_upright_depth'
]
gt_bboxes_3d
=
info
[
'annos'
][
'gt_boxes_upright_depth'
]
gt_labels_3d
=
info
[
'annos'
][
'class'
]
gt_labels_3d
=
info
[
'annos'
][
'class'
]
gt_bboxes_3d_mask
=
np
.
ones_like
(
gt_labels_3d
,
dtype
=
np
.
bool
)
else
:
else
:
gt_bboxes_3d
=
np
.
zeros
((
1
,
6
),
dtype
=
np
.
float32
)
gt_bboxes_3d
=
np
.
zeros
((
1
,
6
),
dtype
=
np
.
float32
)
gt_labels_3d
=
np
.
zeros
((
1
,
))
gt_labels_3d
=
np
.
zeros
((
1
,
))
gt_bboxes_3d_mask
=
np
.
zeros
((
1
,
),
dtype
=
np
.
bool
)
results
[
'gt_bboxes_3d'
]
=
gt_bboxes_3d
# prepare input of pipeline
results
[
'gt_labels_3d'
]
=
gt_labels_3d
results
[
'ann_info'
]
=
dict
()
results
[
'gt_bboxes_3d_mask'
]
=
gt_bboxes_3d_mask
results
[
'ann_info'
][
'gt_bboxes_3d'
]
=
gt_bboxes_3d
results
[
'ann_info'
][
'gt_labels_3d'
]
=
gt_labels_3d
results
[
'bbox3d_fields'
]
=
[]
results
[
'pts_mask_fields'
]
=
[]
results
[
'pts_seg_fields'
]
=
[]
results
=
pipeline
(
results
)
results
=
pipeline
(
results
)
points
=
results
[
'points'
].
_data
points
=
results
[
'points'
].
_data
gt_bboxes_3d
=
results
[
'gt_bboxes_3d'
].
_data
gt_bboxes_3d
=
results
[
'gt_bboxes_3d'
].
_data
...
...
tests/test_pipeline/test_
indoor_
loading.py
→
tests/test_pipeline/test_loading.py
View file @
bdb3c14d
...
@@ -2,14 +2,14 @@ import os.path as osp
...
@@ -2,14 +2,14 @@ import os.path as osp
import
mmcv
import
mmcv
import
numpy
as
np
import
numpy
as
np
import
pytest
from
mmdet3d.datasets.pipelines
import
(
IndoorLoadAnnotations3D
,
from
mmdet3d.datasets.pipelines
import
LoadAnnotations3D
,
LoadPointsFromFile
IndoorLoadPointsFromFile
)
def
test_
indoor_
load_points_from_file
():
def
test_load_points_from_
indoor_
file
():
sunrgbd_info
=
mmcv
.
load
(
'./tests/data/sunrgbd/sunrgbd_infos.pkl'
)
sunrgbd_info
=
mmcv
.
load
(
'./tests/data/sunrgbd/sunrgbd_infos.pkl'
)
sunrgbd_load_points_from_file
=
Indoor
LoadPointsFromFile
(
True
,
6
)
sunrgbd_load_points_from_file
=
LoadPointsFromFile
(
6
,
shift_height
=
True
)
sunrgbd_results
=
dict
()
sunrgbd_results
=
dict
()
data_path
=
'./tests/data/sunrgbd/sunrgbd_trainval'
data_path
=
'./tests/data/sunrgbd/sunrgbd_trainval'
sunrgbd_info
=
sunrgbd_info
[
0
]
sunrgbd_info
=
sunrgbd_info
[
0
]
...
@@ -21,7 +21,7 @@ def test_indoor_load_points_from_file():
...
@@ -21,7 +21,7 @@ def test_indoor_load_points_from_file():
assert
sunrgbd_point_cloud
.
shape
==
(
100
,
4
)
assert
sunrgbd_point_cloud
.
shape
==
(
100
,
4
)
scannet_info
=
mmcv
.
load
(
'./tests/data/scannet/scannet_infos.pkl'
)
scannet_info
=
mmcv
.
load
(
'./tests/data/scannet/scannet_infos.pkl'
)
scannet_load_data
=
Indoor
LoadPointsFromFile
(
True
)
scannet_load_data
=
LoadPointsFromFile
(
shift_height
=
True
)
scannet_results
=
dict
()
scannet_results
=
dict
()
data_path
=
'./tests/data/scannet/scannet_train_instance_data'
data_path
=
'./tests/data/scannet/scannet_train_instance_data'
scannet_results
[
'data_path'
]
=
data_path
scannet_results
[
'data_path'
]
=
data_path
...
@@ -35,50 +35,68 @@ def test_indoor_load_points_from_file():
...
@@ -35,50 +35,68 @@ def test_indoor_load_points_from_file():
assert
scannet_point_cloud
.
shape
==
(
100
,
4
)
assert
scannet_point_cloud
.
shape
==
(
100
,
4
)
def
test_load_annotations3D
():
def
test_load_points_from_outdoor_file
():
sunrgbd_info
=
mmcv
.
load
(
'./tests/data/sunrgbd/sunrgbd_infos.pkl'
)[
0
]
data_path
=
'tests/data/kitti/a.bin'
if
sunrgbd_info
[
'annos'
][
'gt_num'
]
!=
0
:
load_points_from_file
=
LoadPointsFromFile
(
4
,
4
)
sunrgbd_gt_bboxes_3d
=
sunrgbd_info
[
'annos'
][
'gt_boxes_upright_depth'
]
results
=
dict
()
sunrgbd_gt_labels_3d
=
sunrgbd_info
[
'annos'
][
'class'
]
results
[
'pts_filename'
]
=
data_path
sunrgbd_gt_bboxes_3d_mask
=
np
.
ones_like
(
results
=
load_points_from_file
(
results
)
sunrgbd_gt_labels_3d
,
dtype
=
np
.
bool
)
points
=
results
[
'points'
]
else
:
assert
points
.
shape
==
(
50
,
4
)
sunrgbd_gt_bboxes_3d
=
np
.
zeros
((
1
,
6
),
dtype
=
np
.
float32
)
assert
np
.
allclose
(
points
.
sum
(),
2637.479
)
sunrgbd_gt_labels_3d
=
np
.
zeros
((
1
,
))
sunrgbd_gt_bboxes_3d_mask
=
np
.
zeros
((
1
,
),
dtype
=
np
.
bool
)
load_points_from_file
=
LoadPointsFromFile
(
4
,
[
0
,
1
,
2
,
3
])
assert
sunrgbd_gt_bboxes_3d
.
shape
==
(
3
,
7
)
results
=
dict
()
assert
sunrgbd_gt_labels_3d
.
shape
==
(
3
,
)
results
[
'pts_filename'
]
=
data_path
assert
sunrgbd_gt_bboxes_3d_mask
.
shape
==
(
3
,
)
results
=
load_points_from_file
(
results
)
new_points
=
results
[
'points'
]
assert
new_points
.
shape
==
(
50
,
4
)
assert
np
.
allclose
(
points
.
sum
(),
2637.479
)
np
.
equal
(
points
,
new_points
)
with
pytest
.
raises
(
AssertionError
):
LoadPointsFromFile
(
4
,
5
)
def
test_load_annotations3D
():
# Test scannet LoadAnnotations3D
scannet_info
=
mmcv
.
load
(
'./tests/data/scannet/scannet_infos.pkl'
)[
0
]
scannet_info
=
mmcv
.
load
(
'./tests/data/scannet/scannet_infos.pkl'
)[
0
]
scannet_load_annotations3D
=
IndoorLoadAnnotations3D
()
scannet_load_annotations3D
=
LoadAnnotations3D
(
with_bbox_3d
=
True
,
with_label_3d
=
True
,
with_mask_3d
=
True
,
with_seg_3d
=
True
)
scannet_results
=
dict
()
scannet_results
=
dict
()
data_path
=
'./tests/data/scannet/scannet_train_instance_data'
data_path
=
'./tests/data/scannet/scannet_train_instance_data'
if
scannet_info
[
'annos'
][
'gt_num'
]
!=
0
:
if
scannet_info
[
'annos'
][
'gt_num'
]
!=
0
:
scannet_gt_bboxes_3d
=
scannet_info
[
'annos'
][
'gt_boxes_upright_depth'
]
scannet_gt_bboxes_3d
=
scannet_info
[
'annos'
][
'gt_boxes_upright_depth'
]
scannet_gt_labels_3d
=
scannet_info
[
'annos'
][
'class'
]
scannet_gt_labels_3d
=
scannet_info
[
'annos'
][
'class'
]
scannet_gt_bboxes_3d_mask
=
np
.
ones_like
(
scannet_gt_labels_3d
,
dtype
=
np
.
bool
)
else
:
else
:
scannet_gt_bboxes_3d
=
np
.
zeros
((
1
,
6
),
dtype
=
np
.
float32
)
scannet_gt_bboxes_3d
=
np
.
zeros
((
1
,
6
),
dtype
=
np
.
float32
)
scannet_gt_labels_3d
=
np
.
zeros
((
1
,
))
scannet_gt_labels_3d
=
np
.
zeros
((
1
,
))
scannet_gt_bboxes_3d_mask
=
np
.
zeros
((
1
,
),
dtype
=
np
.
bool
)
# prepare input of loading pipeline
scan_name
=
scannet_info
[
'point_cloud'
][
'lidar_idx'
]
scan_name
=
scannet_info
[
'point_cloud'
][
'lidar_idx'
]
scannet_results
[
'pts_instance_mask_path'
]
=
osp
.
join
(
scannet_results
[
'ann_info'
]
=
dict
()
scannet_results
[
'ann_info'
][
'pts_instance_mask_path'
]
=
osp
.
join
(
data_path
,
f
'
{
scan_name
}
_ins_label.npy'
)
data_path
,
f
'
{
scan_name
}
_ins_label.npy'
)
scannet_results
[
'pts_semantic_mask_path'
]
=
osp
.
join
(
scannet_results
[
'
ann_info'
][
'
pts_semantic_mask_path'
]
=
osp
.
join
(
data_path
,
f
'
{
scan_name
}
_sem_label.npy'
)
data_path
,
f
'
{
scan_name
}
_sem_label.npy'
)
scannet_results
[
'gt_bboxes_3d'
]
=
scannet_gt_bboxes_3d
scannet_results
[
'ann_info'
][
'gt_bboxes_3d'
]
=
scannet_gt_bboxes_3d
scannet_results
[
'gt_labels_3d'
]
=
scannet_gt_labels_3d
scannet_results
[
'ann_info'
][
'gt_labels_3d'
]
=
scannet_gt_labels_3d
scannet_results
[
'gt_bboxes_3d_mask'
]
=
scannet_gt_bboxes_3d_mask
scannet_results
[
'bbox3d_fields'
]
=
[]
scannet_results
[
'pts_mask_fields'
]
=
[]
scannet_results
[
'pts_seg_fields'
]
=
[]
scannet_results
=
scannet_load_annotations3D
(
scannet_results
)
scannet_results
=
scannet_load_annotations3D
(
scannet_results
)
scannet_gt_boxes
=
scannet_results
[
'gt_bboxes_3d'
]
scannet_gt_boxes
=
scannet_results
[
'gt_bboxes_3d'
]
scannet_gt_lbaels
=
scannet_results
[
'gt_labels_3d'
]
scannet_gt_lbaels
=
scannet_results
[
'gt_labels_3d'
]
scannet_gt_boxes_mask
=
scannet_results
[
'gt_bboxes_3d_mask'
]
scannet_pts_instance_mask
=
scannet_results
[
'pts_instance_mask'
]
scannet_pts_instance_mask
=
scannet_results
[
'pts_instance_mask'
]
scannet_pts_semantic_mask
=
scannet_results
[
'pts_semantic_mask'
]
scannet_pts_semantic_mask
=
scannet_results
[
'pts_semantic_mask'
]
assert
scannet_gt_boxes
.
shape
==
(
27
,
6
)
assert
scannet_gt_boxes
.
shape
==
(
27
,
6
)
assert
scannet_gt_lbaels
.
shape
==
(
27
,
)
assert
scannet_gt_lbaels
.
shape
==
(
27
,
)
assert
scannet_gt_boxes_mask
.
shape
==
(
27
,
)
assert
scannet_pts_instance_mask
.
shape
==
(
100
,
)
assert
scannet_pts_instance_mask
.
shape
==
(
100
,
)
assert
scannet_pts_semantic_mask
.
shape
==
(
100
,
)
assert
scannet_pts_semantic_mask
.
shape
==
(
100
,
)
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