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
470a58ad
Commit
470a58ad
authored
May 06, 2020
by
liyinhao
Browse files
change names, paras
parent
bdce5236
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
105 additions
and
286 deletions
+105
-286
mmdet3d/datasets/pipelines/indoor_augment.py
mmdet3d/datasets/pipelines/indoor_augment.py
+47
-51
mmdet3d/datasets/pipelines/indoor_loading.py
mmdet3d/datasets/pipelines/indoor_loading.py
+0
-122
tests/test_indoor_augment.py
tests/test_indoor_augment.py
+58
-52
tests/test_indoor_loading.py
tests/test_indoor_loading.py
+0
-61
No files found.
mmdet3d/datasets/pipelines/indoor_augment.py
View file @
470a58ad
...
@@ -22,7 +22,7 @@ def _rotz(t):
...
@@ -22,7 +22,7 @@ def _rotz(t):
@
PIPELINES
.
register_module
()
@
PIPELINES
.
register_module
()
class
IndoorFlipData
(
object
):
class
IndoorFlipData
(
object
):
"""Indoor Flip Data
"""Indoor Flip Data
.
Flip point_cloud and groundtruth boxes.
Flip point_cloud and groundtruth boxes.
...
@@ -30,28 +30,27 @@ class IndoorFlipData(object):
...
@@ -30,28 +30,27 @@ class IndoorFlipData(object):
seed (int): Numpy random seed.
seed (int): Numpy random seed.
"""
"""
def
__init__
(
self
,
seed
=
None
):
def
__init__
(
self
):
if
seed
is
not
None
:
pass
np
.
random
.
seed
(
seed
)
def
__call__
(
self
,
results
):
def
__call__
(
self
,
results
):
point
_cloud
=
results
.
get
(
'point
_cloud
'
,
None
)
point
s
=
results
.
get
(
'point
s
'
,
None
)
gt_boxes
=
results
.
get
(
'gt_boxes'
,
None
)
gt_
b
boxes
_3d
=
results
.
get
(
'gt_
b
boxes
_3d
'
,
None
)
name
=
'scannet'
if
gt_boxes
.
shape
[
1
]
==
6
else
'sunrgbd'
name
=
'scannet'
if
gt_
b
boxes
_3d
.
shape
[
1
]
==
6
else
'sunrgbd'
if
np
.
random
.
random
()
>
0.5
:
if
np
.
random
.
random
()
>
0.5
:
# Flipping along the YZ plane
# Flipping along the YZ plane
point
_cloud
[:,
0
]
=
-
1
*
point
_cloud
[:,
0
]
point
s
[:,
0
]
=
-
1
*
point
s
[:,
0
]
gt_boxes
[:,
0
]
=
-
1
*
gt_boxes
[:,
0
]
gt_
b
boxes
_3d
[:,
0
]
=
-
1
*
gt_
b
boxes
_3d
[:,
0
]
if
name
==
'sunrgbd'
:
if
name
==
'sunrgbd'
:
gt_boxes
[:,
6
]
=
np
.
pi
-
gt_boxes
[:,
6
]
gt_
b
boxes
_3d
[:,
6
]
=
np
.
pi
-
gt_
b
boxes
_3d
[:,
6
]
results
[
'gt_boxes'
]
=
gt_boxes
results
[
'gt_boxes'
]
=
gt_
b
boxes
_3d
if
name
==
'scannet'
and
np
.
random
.
random
()
>
0.5
:
if
name
==
'scannet'
and
np
.
random
.
random
()
>
0.5
:
# Flipping along the XZ plane
# Flipping along the XZ plane
point
_cloud
[:,
1
]
=
-
1
*
point
_cloud
[:,
1
]
point
s
[:,
1
]
=
-
1
*
point
s
[:,
1
]
gt_boxes
[:,
1
]
=
-
1
*
gt_boxes
[:,
1
]
gt_
b
boxes
_3d
[:,
1
]
=
-
1
*
gt_
b
boxes
_3d
[:,
1
]
results
[
'gt_boxes'
]
=
gt_boxes
results
[
'gt_
b
boxes
_3d
'
]
=
gt_
b
boxes
_3d
results
[
'point
_cloud
'
]
=
point
_cloud
results
[
'point
s
'
]
=
point
s
return
results
return
results
...
@@ -79,17 +78,13 @@ class IndoorGlobalRotScale(object):
...
@@ -79,17 +78,13 @@ class IndoorGlobalRotScale(object):
"""
"""
def
__init__
(
self
,
def
__init__
(
self
,
seed
=
None
,
use_rotate
=
True
,
use_rotate
=
True
,
use_color
=
False
,
use_color
=
False
,
use_scale
=
True
,
use_scale
=
True
,
use_height
=
True
,
use_height
=
True
,
rot_range
=
1
/
3
,
rot_range
=
[
-
np
.
pi
/
6
,
np
.
pi
/
6
]
,
scale_range
=
0.
3
,
scale_range
=
[
0.
85
,
1.15
]
,
color_mean
=
[
0.5
,
0.5
,
0.5
]):
color_mean
=
[
0.5
,
0.5
,
0.5
]):
if
seed
is
not
None
:
np
.
random
.
seed
(
seed
)
self
.
use_rotate
=
use_rotate
self
.
use_rotate
=
use_rotate
self
.
use_color
=
use_color
self
.
use_color
=
use_color
self
.
use_scale
=
use_scale
self
.
use_scale
=
use_scale
...
@@ -132,53 +127,54 @@ class IndoorGlobalRotScale(object):
...
@@ -132,53 +127,54 @@ class IndoorGlobalRotScale(object):
return
np
.
concatenate
([
new_centers
,
new_lengths
],
axis
=
1
)
return
np
.
concatenate
([
new_centers
,
new_lengths
],
axis
=
1
)
def
__call__
(
self
,
results
):
def
__call__
(
self
,
results
):
point
_cloud
=
results
.
get
(
'point
_cloud
'
,
None
)
point
s
=
results
.
get
(
'point
s
'
,
None
)
gt_boxes
=
results
.
get
(
'gt_boxes'
,
None
)
gt_
b
boxes
_3d
=
results
.
get
(
'gt_
b
boxes
_3d
'
,
None
)
name
=
'scannet'
if
gt_boxes
.
shape
[
1
]
==
6
else
'sunrgbd'
name
=
'scannet'
if
gt_
b
boxes
_3d
.
shape
[
1
]
==
6
else
'sunrgbd'
if
self
.
use_rotate
:
if
self
.
use_rotate
:
rot_angle
=
(
np
.
random
.
random
()
*
self
.
rot_range
*
np
.
pi
rot_angle
=
np
.
random
.
random
()
*
(
)
-
np
.
pi
*
self
.
rot_range
/
2
# -30 ~ +30 degree
self
.
rot_range
[
1
]
-
self
.
rot_range
[
0
])
+
self
.
rot_range
[
0
]
rot_mat
=
_rotz
(
rot_angle
)
rot_mat
=
_rotz
(
rot_angle
)
point_cloud
[:,
0
:
3
]
=
np
.
dot
(
point_cloud
[:,
0
:
3
],
points
[:,
0
:
3
]
=
np
.
dot
(
points
[:,
0
:
3
],
np
.
transpose
(
rot_mat
))
np
.
transpose
(
rot_mat
))
if
name
==
'scannet'
:
if
name
==
'scannet'
:
gt_boxes
=
self
.
_rotate_aligned_boxes
(
gt_boxes
,
rot_mat
)
gt_bboxes_3d
=
self
.
_rotate_aligned_boxes
(
gt_bboxes_3d
,
rot_mat
)
else
:
else
:
gt_boxes
[:,
0
:
3
]
=
np
.
dot
(
gt_boxes
[:,
0
:
3
],
gt_
b
boxes
_3d
[:,
0
:
3
]
=
np
.
dot
(
gt_
b
boxes
_3d
[:,
0
:
3
],
np
.
transpose
(
rot_mat
))
np
.
transpose
(
rot_mat
))
gt_boxes
[:,
6
]
-=
rot_angle
gt_
b
boxes
_3d
[:,
6
]
-=
rot_angle
# Augment RGB color
# Augment RGB color
if
self
.
use_color
:
if
self
.
use_color
:
rgb_color
=
point_cloud
[:,
3
:
6
]
+
self
.
color_mean
rgb_color
=
points
[:,
3
:
6
]
+
self
.
color_mean
rgb_color
*=
(
1
+
0.4
*
np
.
random
.
random
(
3
)
-
0.2
# brightness change for each channel
)
# brightness change for each channel
rgb_color
*=
(
1
+
0.4
*
np
.
random
.
random
(
3
)
-
0.2
)
rgb_color
+=
(
0.1
*
np
.
random
.
random
(
3
)
-
0.05
# color shift for each channel
)
# color shift for each channel
rgb_color
+=
(
0.1
*
np
.
random
.
random
(
3
)
-
0.05
)
# jittering on each pixel
rgb_color
+=
np
.
expand_dims
(
rgb_color
+=
np
.
expand_dims
(
(
0.05
*
np
.
random
.
random
(
point_cloud
.
shape
[
0
])
-
0.025
),
(
0.05
*
np
.
random
.
random
(
points
.
shape
[
0
])
-
0.025
),
-
1
)
-
1
)
# jittering on each pixel
rgb_color
=
np
.
clip
(
rgb_color
,
0
,
1
)
rgb_color
=
np
.
clip
(
rgb_color
,
0
,
1
)
# randomly drop out 30% of the points' colors
# randomly drop out 30% of the points' colors
rgb_color
*=
np
.
expand_dims
(
rgb_color
*=
np
.
expand_dims
(
np
.
random
.
random
(
point
_cloud
.
shape
[
0
])
>
0.3
,
-
1
)
np
.
random
.
random
(
point
s
.
shape
[
0
])
>
0.3
,
-
1
)
point
_cloud
[:,
3
:
6
]
=
rgb_color
-
self
.
color_mean
point
s
[:,
3
:
6
]
=
rgb_color
-
self
.
color_mean
if
self
.
use_scale
:
if
self
.
use_scale
:
# Augment point cloud scale: 0.85x-1.15x
# Augment point cloud scale
scale_ratio
=
np
.
random
.
random
(
scale_ratio
=
np
.
random
.
random
()
*
(
)
*
self
.
scale_range
+
1
-
self
.
scale_range
/
2
self
.
scale_range
[
1
]
-
scale_ratio
=
np
.
expand_dims
(
np
.
tile
(
scale_ratio
,
3
),
0
)
self
.
scale_range
[
0
])
+
self
.
scale_range
[
0
]
point_cloud
[:,
0
:
3
]
*=
scale_ratio
scale_ratio
=
np
.
tile
(
scale_ratio
,
3
)[
None
,
...]
gt_boxes
[:,
0
:
3
]
*=
scale_ratio
points
[:,
0
:
3
]
*=
scale_ratio
gt_boxes
[:,
3
:
6
]
*=
scale_ratio
gt_bboxes_3d
[:,
0
:
3
]
*=
scale_ratio
gt_bboxes_3d
[:,
3
:
6
]
*=
scale_ratio
if
self
.
use_height
:
if
self
.
use_height
:
point
_cloud
[:,
-
1
]
*=
scale_ratio
[
0
,
0
]
point
s
[:,
-
1
]
*=
scale_ratio
[
0
,
0
]
results
[
'point
_cloud
'
]
=
point
_cloud
results
[
'point
s
'
]
=
point
s
results
[
'gt_boxes'
]
=
gt_boxes
results
[
'gt_
b
boxes
_3d
'
]
=
gt_
b
boxes
_3d
return
results
return
results
def
__repr__
(
self
):
def
__repr__
(
self
):
...
...
mmdet3d/datasets/pipelines/indoor_loading.py
deleted
100644 → 0
View file @
bdce5236
import
os.path
as
osp
import
numpy
as
np
from
mmdet.datasets.registry
import
PIPELINES
@
PIPELINES
.
register_module
class
LoadPointsFromFile
(
object
):
"""Load Points From File.
Load sunrgbd and scannet points from file.
Args:
name (str): scannet or sunrgbd.
use_color (bool): Whether to use color.
use_height (bool): Whether to use height.
mean_color (List[float]): Mean color of the point cloud.
"""
def
__init__
(
self
,
use_color
,
use_height
,
mean_color
):
self
.
use_color
=
use_color
self
.
use_height
=
use_height
self
.
mean_color
=
mean_color
def
__call__
(
self
,
results
):
data_path
=
results
.
get
(
'data_path'
,
None
)
info
=
results
.
get
(
'info'
,
None
)
name
=
'scannet'
if
info
.
get
(
'image'
,
None
)
is
None
else
'sunrgbd'
if
name
==
'scannet'
:
scan_name
=
info
[
'point_cloud'
][
'lidar_idx'
]
point_cloud
=
self
.
_get_lidar
(
scan_name
,
data_path
)
else
:
point_cloud
=
np
.
load
(
osp
.
join
(
data_path
,
'lidar'
,
'%06d.npz'
%
info
[
'point_cloud'
][
'lidar_idx'
]))[
'pc'
]
if
not
self
.
use_color
:
if
name
==
'scannet'
:
pcl_color
=
point_cloud
[:,
3
:
6
]
point_cloud
=
point_cloud
[:,
0
:
3
]
else
:
if
name
==
'scannet'
:
pcl_color
=
point_cloud
[:,
3
:
6
]
point_cloud
=
point_cloud
[:,
0
:
6
]
point_cloud
[:,
3
:]
=
(
point_cloud
[:,
3
:]
-
np
.
array
(
self
.
mean_color
))
/
256.0
if
self
.
use_height
:
floor_height
=
np
.
percentile
(
point_cloud
[:,
2
],
0.99
)
height
=
point_cloud
[:,
2
]
-
floor_height
point_cloud
=
np
.
concatenate
(
[
point_cloud
,
np
.
expand_dims
(
height
,
1
)],
1
)
results
[
'point_cloud'
]
=
point_cloud
if
name
==
'scannet'
:
results
[
'pcl_color'
]
=
pcl_color
return
results
def
__repr__
(
self
):
repr_str
=
self
.
__class__
.
__name__
repr_str
+=
'(use_height={})'
.
format
(
self
.
use_height
)
repr_str
+=
'(use_color={}'
.
format
(
self
.
use_color
)
repr_str
+=
'(mean_color={})'
.
format
(
self
.
mean_color
)
return
repr_str
def
_get_lidar
(
self
,
scan_name
,
data_path
):
lidar_file
=
osp
.
join
(
data_path
,
scan_name
+
'_vert.npy'
)
assert
osp
.
exists
(
lidar_file
)
return
np
.
load
(
lidar_file
)
@
PIPELINES
.
register_module
class
LoadAnnotations3D
(
object
):
"""Load Annotations3D.
Load sunrgbd and scannet annotations.
Args:
name (str): scannet or sunrgbd.
"""
def
__init__
(
self
):
pass
def
__call__
(
self
,
results
):
data_path
=
results
.
get
(
'data_path'
,
None
)
info
=
results
.
get
(
'info'
,
None
)
if
info
[
'annos'
][
'gt_num'
]
!=
0
:
gt_boxes
=
info
[
'annos'
][
'gt_boxes_upright_depth'
]
gt_classes
=
info
[
'annos'
][
'class'
].
reshape
(
-
1
,
1
)
gt_boxes_mask
=
np
.
ones_like
(
gt_classes
)
else
:
gt_boxes
=
np
.
zeros
((
1
,
6
),
dtype
=
np
.
float32
)
gt_classes
=
np
.
zeros
((
1
,
1
))
gt_boxes_mask
=
np
.
zeros
((
1
,
1
))
name
=
'scannet'
if
info
.
get
(
'image'
,
None
)
is
None
else
'sunrgbd'
if
name
==
'scannet'
:
scan_name
=
info
[
'point_cloud'
][
'lidar_idx'
]
instance_labels
=
self
.
_get_instance_label
(
scan_name
,
data_path
)
semantic_labels
=
self
.
_get_semantic_label
(
scan_name
,
data_path
)
results
[
'instance_labels'
]
=
instance_labels
results
[
'semantic_labels'
]
=
semantic_labels
results
[
'gt_boxes'
]
=
gt_boxes
results
[
'gt_classes'
]
=
gt_classes
results
[
'gt_boxes_mask'
]
=
gt_boxes_mask
return
results
def
__repr__
(
self
):
repr_str
=
self
.
__class__
.
__name__
return
repr_str
def
_get_instance_label
(
self
,
scan_name
,
data_path
):
ins_file
=
osp
.
join
(
data_path
,
scan_name
+
'_ins_label.npy'
)
assert
osp
.
exists
(
ins_file
)
return
np
.
load
(
ins_file
)
def
_get_semantic_label
(
self
,
scan_name
,
data_path
):
sem_file
=
osp
.
join
(
data_path
,
scan_name
+
'_sem_label.npy'
)
assert
osp
.
exists
(
sem_file
)
return
np
.
load
(
sem_file
)
tests/test_indoor_augment.py
View file @
470a58ad
...
@@ -5,114 +5,120 @@ from mmdet3d.datasets.pipelines.indoor_augment import (IndoorFlipData,
...
@@ -5,114 +5,120 @@ from mmdet3d.datasets.pipelines.indoor_augment import (IndoorFlipData,
def
test_indoor_flip_data
():
def
test_indoor_flip_data
():
sunrgbd_indoor_flip_data
=
IndoorFlipData
(
0
)
np
.
random
.
seed
(
0
)
sunrgbd_indoor_flip_data
=
IndoorFlipData
()
sunrgbd_results
=
dict
()
sunrgbd_results
=
dict
()
sunrgbd_results
[
'point
_cloud
'
]
=
np
.
array
(
sunrgbd_results
[
'point
s
'
]
=
np
.
array
(
[[
1.02828765e+00
,
3.65790772e+00
,
1.97294697e-01
,
1.61959505e+00
],
[[
1.02828765e+00
,
3.65790772e+00
,
1.97294697e-01
,
1.61959505e+00
],
[
-
3.95979017e-01
,
1.05465031e+00
,
-
7.49204338e-01
,
6.73096001e-01
]])
[
-
3.95979017e-01
,
1.05465031e+00
,
-
7.49204338e-01
,
6.73096001e-01
]])
sunrgbd_results
[
'gt_boxes'
]
=
np
.
array
([[
sunrgbd_results
[
'gt_
b
boxes
_3d
'
]
=
np
.
array
([[
0.213684
,
1.036364
,
-
0.982323
,
0.61541
,
0.572574
,
0.872728
,
3.07028526
0.213684
,
1.036364
,
-
0.982323
,
0.61541
,
0.572574
,
0.872728
,
3.07028526
],
],
[
[
-
0.449953
,
1.395455
,
-
1.027778
,
-
0.449953
,
1.395455
,
1.500956
,
1.637298
,
0.636364
,
-
1.027778
,
1.500956
,
-
1.58242359
1.637298
,
0.636364
,
]])
-
1.58242359
]])
sunrgbd_results
=
sunrgbd_indoor_flip_data
(
sunrgbd_results
)
sunrgbd_results
=
sunrgbd_indoor_flip_data
(
sunrgbd_results
)
sunrgbd_point
_cloud
=
sunrgbd_results
.
get
(
'point
_cloud
'
,
None
)
sunrgbd_point
s
=
sunrgbd_results
.
get
(
'point
s
'
,
None
)
sunrgbd_gt_boxes
=
sunrgbd_results
.
get
(
'gt_boxes'
,
None
)
sunrgbd_gt_
b
boxes
_3d
=
sunrgbd_results
.
get
(
'gt_
b
boxes
_3d
'
,
None
)
expected_sunrgbd_point
_cloud
=
np
.
array
(
expected_sunrgbd_point
s
=
np
.
array
(
[[
-
1.02828765
,
3.65790772
,
0.1972947
,
1.61959505
],
[[
-
1.02828765
,
3.65790772
,
0.1972947
,
1.61959505
],
[
0.39597902
,
1.05465031
,
-
0.74920434
,
0.673096
]])
[
0.39597902
,
1.05465031
,
-
0.74920434
,
0.673096
]])
expected_sunrgbd_gt_boxes
=
np
.
array
([[
expected_sunrgbd_gt_
b
boxes
_3d
=
np
.
array
([[
-
0.213684
,
1.036364
,
-
0.982323
,
0.61541
,
0.572574
,
0.872728
,
0.07130739
-
0.213684
,
1.036364
,
-
0.982323
,
0.61541
,
0.572574
,
0.872728
,
0.07130739
],
[
],
[
0.449953
,
1.395455
,
-
1.027778
,
1.500956
,
1.637298
,
0.636364
,
4.72401624
0.449953
,
1.395455
,
-
1.027778
,
1.500956
,
1.637298
,
0.636364
,
4.72401624
]])
]])
assert
np
.
allclose
(
sunrgbd_point
_cloud
,
expected_sunrgbd_point
_cloud
)
assert
np
.
allclose
(
sunrgbd_point
s
,
expected_sunrgbd_point
s
)
assert
np
.
allclose
(
sunrgbd_gt_boxes
,
expected_sunrgbd_gt_boxes
)
assert
np
.
allclose
(
sunrgbd_gt_
b
boxes
_3d
,
expected_sunrgbd_gt_
b
boxes
_3d
)
scannet_indoor_flip_data
=
IndoorFlipData
(
0
)
np
.
random
.
seed
(
0
)
scannet_indoor_flip_data
=
IndoorFlipData
()
scannet_results
=
dict
()
scannet_results
=
dict
()
scannet_results
[
'point
_cloud
'
]
=
np
.
array
(
scannet_results
[
'point
s
'
]
=
np
.
array
(
[[
1.6110241e+00
,
-
1.6903955e-01
,
5.8115810e-01
,
5.9897250e-01
],
[[
1.6110241e+00
,
-
1.6903955e-01
,
5.8115810e-01
,
5.9897250e-01
],
[
1.3978075e+00
,
4.2035791e-01
,
3.8729519e-01
,
4.0510958e-01
]])
[
1.3978075e+00
,
4.2035791e-01
,
3.8729519e-01
,
4.0510958e-01
]])
scannet_results
[
'gt_boxes'
]
=
np
.
array
([[
scannet_results
[
'gt_
b
boxes
_3d
'
]
=
np
.
array
([[
0.55903838
,
0.48201692
,
0.65688646
,
0.65370704
,
0.60029864
,
0.5163464
0.55903838
,
0.48201692
,
0.65688646
,
0.65370704
,
0.60029864
,
0.5163464
],
[
],
[
-
0.03226406
,
1.70392646
,
0.60348618
,
0.65165804
,
0.72084366
,
0.64667457
-
0.03226406
,
1.70392646
,
0.60348618
,
0.65165804
,
0.72084366
,
0.64667457
]])
]])
scannet_results
=
scannet_indoor_flip_data
(
scannet_results
)
scannet_results
=
scannet_indoor_flip_data
(
scannet_results
)
scannet_point
_cloud
=
scannet_results
.
get
(
'point
_cloud
'
,
None
)
scannet_point
s
=
scannet_results
.
get
(
'point
s
'
,
None
)
scannet_gt_boxes
=
scannet_results
.
get
(
'gt_boxes'
,
None
)
scannet_gt_
b
boxes
_3d
=
scannet_results
.
get
(
'gt_
b
boxes
_3d
'
,
None
)
expected_scannet_point
_cloud
=
np
.
array
(
expected_scannet_point
s
=
np
.
array
(
[[
-
1.6110241
,
0.16903955
,
0.5811581
,
0.5989725
],
[[
-
1.6110241
,
0.16903955
,
0.5811581
,
0.5989725
],
[
-
1.3978075
,
-
0.42035791
,
0.38729519
,
0.40510958
]])
[
-
1.3978075
,
-
0.42035791
,
0.38729519
,
0.40510958
]])
expected_scannet_gt_boxes
=
np
.
array
([[
expected_scannet_gt_
b
boxes
_3d
=
np
.
array
([[
-
0.55903838
,
-
0.48201692
,
0.65688646
,
0.65370704
,
0.60029864
,
0.5163464
-
0.55903838
,
-
0.48201692
,
0.65688646
,
0.65370704
,
0.60029864
,
0.5163464
],
[
],
[
0.03226406
,
-
1.70392646
,
0.60348618
,
0.65165804
,
0.72084366
,
0.64667457
0.03226406
,
-
1.70392646
,
0.60348618
,
0.65165804
,
0.72084366
,
0.64667457
]])
]])
assert
np
.
allclose
(
scannet_point
_cloud
,
expected_scannet_point
_cloud
)
assert
np
.
allclose
(
scannet_point
s
,
expected_scannet_point
s
)
assert
np
.
allclose
(
scannet_gt_boxes
,
expected_scannet_gt_boxes
)
assert
np
.
allclose
(
scannet_gt_
b
boxes
_3d
,
expected_scannet_gt_
b
boxes
_3d
)
def
test_global_rot_scale
():
def
test_global_rot_scale
():
sunrgbd_augment
=
IndoorGlobalRotScale
(
0
,
True
,
False
,
True
,
True
)
np
.
random
.
seed
(
0
)
sunrgbd_augment
=
IndoorGlobalRotScale
(
True
,
False
,
True
,
True
)
sunrgbd_results
=
dict
()
sunrgbd_results
=
dict
()
sunrgbd_results
[
'point
_cloud
'
]
=
np
.
array
(
sunrgbd_results
[
'point
s
'
]
=
np
.
array
(
[[
1.02828765e+00
,
3.65790772e+00
,
1.97294697e-01
,
1.61959505e+00
],
[[
1.02828765e+00
,
3.65790772e+00
,
1.97294697e-01
,
1.61959505e+00
],
[
-
3.95979017e-01
,
1.05465031e+00
,
-
7.49204338e-01
,
6.73096001e-01
]])
[
-
3.95979017e-01
,
1.05465031e+00
,
-
7.49204338e-01
,
6.73096001e-01
]])
sunrgbd_results
[
'gt_boxes'
]
=
np
.
array
([[
sunrgbd_results
[
'gt_
b
boxes
_3d
'
]
=
np
.
array
([[
0.213684
,
1.036364
,
-
0.982323
,
0.61541
,
0.572574
,
0.872728
,
3.07028526
0.213684
,
1.036364
,
-
0.982323
,
0.61541
,
0.572574
,
0.872728
,
3.07028526
],
],
[
[
-
0.449953
,
1.395455
,
-
1.027778
,
-
0.449953
,
1.395455
,
1.500956
,
1.637298
,
0.636364
,
-
1.027778
,
1.500956
,
-
1.58242359
1.637298
,
0.636364
,
]])
-
1.58242359
]])
sunrgbd_results
=
sunrgbd_augment
(
sunrgbd_results
)
sunrgbd_results
=
sunrgbd_augment
(
sunrgbd_results
)
sunrgbd_point
_cloud
=
sunrgbd_results
.
get
(
'point
_cloud
'
,
None
)
sunrgbd_point
s
=
sunrgbd_results
.
get
(
'point
s
'
,
None
)
sunrgbd_gt_boxes
=
sunrgbd_results
.
get
(
'gt_boxes'
,
None
)
sunrgbd_gt_
b
boxes
_3d
=
sunrgbd_results
.
get
(
'gt_
b
boxes
_3d
'
,
None
)
expected_sunrgbd_point
_cloud
=
np
.
array
(
expected_sunrgbd_point
s
=
np
.
array
(
[[
0.89427376
,
3.94489646
,
0.21003141
,
1.72415094
],
[[
0.89427376
,
3.94489646
,
0.21003141
,
1.72415094
],
[
-
0.47835783
,
1.09972989
,
-
0.79757058
,
0.71654893
]])
[
-
0.47835783
,
1.09972989
,
-
0.79757058
,
0.71654893
]])
expected_sunrgbd_gt_boxes
=
np
.
array
([[
expected_sunrgbd_gt_
b
boxes
_3d
=
np
.
array
([[
0.17080999
,
1.11345031
,
-
1.04573864
,
0.65513891
,
0.60953755
,
0.17080999
,
1.11345031
,
-
1.04573864
,
0.65513891
,
0.60953755
,
0.92906854
,
3.01916788
0.92906854
,
3.01916788
],
],
[
[
-
0.55427876
,
1.45912611
,
-
0.55427876
,
1.45912611
,
-
1.09412807
,
1.59785293
,
-
1.09412807
,
1.59785293
,
1.74299674
,
0.67744563
,
1.74299674
,
0.67744563
,
-
1.63354097
-
1.63354097
]])
]])
assert
np
.
allclose
(
sunrgbd_point
_cloud
,
expected_sunrgbd_point
_cloud
)
assert
np
.
allclose
(
sunrgbd_point
s
,
expected_sunrgbd_point
s
)
assert
np
.
allclose
(
sunrgbd_gt_boxes
,
expected_sunrgbd_gt_boxes
)
assert
np
.
allclose
(
sunrgbd_gt_
b
boxes
_3d
,
expected_sunrgbd_gt_
b
boxes
_3d
)
np
.
random
.
seed
(
0
)
scannet_augment
=
IndoorGlobalRotScale
(
scannet_augment
=
IndoorGlobalRotScale
(
0
,
True
,
False
,
False
,
True
,
rot_range
=
1
/
18
)
True
,
False
,
False
,
True
,
rot_range
=
[
-
np
.
pi
*
1
/
36
,
np
.
pi
*
1
/
36
]
)
scannet_results
=
dict
()
scannet_results
=
dict
()
scannet_results
[
'point
_cloud
'
]
=
np
.
array
(
scannet_results
[
'point
s
'
]
=
np
.
array
(
[[
1.6110241e+00
,
-
1.6903955e-01
,
5.8115810e-01
,
5.9897250e-01
],
[[
1.6110241e+00
,
-
1.6903955e-01
,
5.8115810e-01
,
5.9897250e-01
],
[
1.3978075e+00
,
4.2035791e-01
,
3.8729519e-01
,
4.0510958e-01
]])
[
1.3978075e+00
,
4.2035791e-01
,
3.8729519e-01
,
4.0510958e-01
]])
scannet_results
[
'gt_boxes'
]
=
np
.
array
([[
scannet_results
[
'gt_
b
boxes
_3d
'
]
=
np
.
array
([[
0.55903838
,
0.48201692
,
0.65688646
,
0.65370704
,
0.60029864
,
0.5163464
0.55903838
,
0.48201692
,
0.65688646
,
0.65370704
,
0.60029864
,
0.5163464
],
[
],
[
-
0.03226406
,
1.70392646
,
0.60348618
,
0.65165804
,
0.72084366
,
0.64667457
-
0.03226406
,
1.70392646
,
0.60348618
,
0.65165804
,
0.72084366
,
0.64667457
]])
]])
scannet_results
=
scannet_augment
(
scannet_results
)
scannet_results
=
scannet_augment
(
scannet_results
)
scannet_point
_cloud
=
scannet_results
.
get
(
'point
_cloud
'
,
None
)
scannet_point
s
=
scannet_results
.
get
(
'point
s
'
,
None
)
scannet_gt_boxes
=
scannet_results
.
get
(
'gt_boxes'
,
None
)
scannet_gt_
b
boxes
_3d
=
scannet_results
.
get
(
'gt_
b
boxes
_3d
'
,
None
)
expected_scannet_point
_cloud
=
np
.
array
(
expected_scannet_point
s
=
np
.
array
(
[[
1.61240576
,
-
0.15530836
,
0.5811581
,
0.5989725
],
[[
1.61240576
,
-
0.15530836
,
0.5811581
,
0.5989725
],
[
1.39417555
,
0.43225122
,
0.38729519
,
0.40510958
]])
[
1.39417555
,
0.43225122
,
0.38729519
,
0.40510958
]])
expected_scannet_gt_boxes
=
np
.
array
([[
expected_scannet_gt_
b
boxes
_3d
=
np
.
array
([[
0.55491157
,
0.48676213
,
0.65688646
,
0.65879754
,
0.60584609
,
0.5163464
0.55491157
,
0.48676213
,
0.65688646
,
0.65879754
,
0.60584609
,
0.5163464
],
[
],
[
-
0.04677942
,
1.70358975
,
0.60348618
,
0.65777559
,
0.72636927
,
0.64667457
-
0.04677942
,
1.70358975
,
0.60348618
,
0.65777559
,
0.72636927
,
0.64667457
]])
]])
assert
np
.
allclose
(
scannet_point
_cloud
,
expected_scannet_point
_cloud
)
assert
np
.
allclose
(
scannet_point
s
,
expected_scannet_point
s
)
assert
np
.
allclose
(
scannet_gt_boxes
,
expected_scannet_gt_boxes
)
assert
np
.
allclose
(
scannet_gt_
b
boxes
_3d
,
expected_scannet_gt_
b
boxes
_3d
)
tests/test_indoor_loading.py
deleted
100644 → 0
View file @
bdce5236
import
mmcv
from
mmdet3d.datasets.pipelines.indoor_loading
import
(
LoadAnnotations3D
,
LoadPointsFromFile
)
def
test_load_points_from_file
():
sunrgbd_info
=
mmcv
.
load
(
'./tests/data/sunrgbd/sunrgbd_infos.pkl'
)
sunrgbd_load_points_from_file
=
LoadPointsFromFile
(
False
,
True
,
[
0.5
,
0.5
,
0.5
])
sunrgbd_results
=
dict
()
sunrgbd_results
[
'data_path'
]
=
'./tests/data/sunrgbd/sunrgbd_trainval'
sunrgbd_results
[
'info'
]
=
sunrgbd_info
[
0
]
sunrgbd_results
=
sunrgbd_load_points_from_file
(
sunrgbd_results
)
sunrgbd_point_cloud
=
sunrgbd_results
.
get
(
'point_cloud'
,
None
)
assert
sunrgbd_point_cloud
.
shape
==
(
1000
,
4
)
scannet_info
=
mmcv
.
load
(
'./tests/data/scannet/scannet_infos.pkl'
)
scannet_load_data
=
LoadPointsFromFile
(
False
,
True
,
[
0.5
,
0.5
,
0.5
])
scannet_results
=
dict
()
scannet_results
[
'data_path'
]
=
'./tests/data/scannet/scannet_train_instance_data'
scannet_results
[
'info'
]
=
scannet_info
[
0
]
scannet_results
=
scannet_load_data
(
scannet_results
)
scannet_point_cloud
=
scannet_results
.
get
(
'point_cloud'
,
None
)
scannet_pcl_color
=
scannet_results
.
get
(
'pcl_color'
,
None
)
assert
scannet_point_cloud
.
shape
==
(
1000
,
4
)
assert
scannet_pcl_color
.
shape
==
(
1000
,
3
)
def
test_load_annotations3D
():
sunrgbd_info
=
mmcv
.
load
(
'./tests/data/sunrgbd/sunrgbd_infos.pkl'
)
sunrgbd_load_annotations3D
=
LoadAnnotations3D
()
sunrgbd_results
=
dict
()
sunrgbd_results
[
'data_path'
]
=
'./tests/data/sunrgbd/sunrgbd_trainval'
sunrgbd_results
[
'info'
]
=
sunrgbd_info
[
0
]
sunrgbd_results
=
sunrgbd_load_annotations3D
(
sunrgbd_results
)
sunrgbd_gt_boxes
=
sunrgbd_results
.
get
(
'gt_boxes'
,
None
)
sunrgbd_gt_classes
=
sunrgbd_results
.
get
(
'gt_classes'
,
None
)
sunrgbd_gt_boxes_mask
=
sunrgbd_results
.
get
(
'gt_boxes_mask'
,
None
)
assert
sunrgbd_gt_boxes
.
shape
==
(
3
,
7
)
assert
sunrgbd_gt_classes
.
shape
==
(
3
,
1
)
assert
sunrgbd_gt_boxes_mask
.
shape
==
(
3
,
1
)
scannet_info
=
mmcv
.
load
(
'./tests/data/scannet/scannet_infos.pkl'
)
scannet_load_annotations3D
=
LoadAnnotations3D
()
scannet_results
=
dict
()
scannet_results
[
'data_path'
]
=
'./tests/data/scannet/scannet_train_instance_data'
scannet_results
[
'info'
]
=
scannet_info
[
0
]
scannet_results
=
scannet_load_annotations3D
(
scannet_results
)
scannet_gt_boxes
=
scannet_results
.
get
(
'gt_boxes'
,
None
)
scannet_gt_classes
=
scannet_results
.
get
(
'gt_classes'
,
None
)
scannet_gt_boxes_mask
=
scannet_results
.
get
(
'gt_boxes_mask'
,
None
)
scannet_instance_labels
=
scannet_results
.
get
(
'instance_labels'
,
None
)
scannet_semantic_labels
=
scannet_results
.
get
(
'semantic_labels'
,
None
)
assert
scannet_gt_boxes
.
shape
==
(
27
,
6
)
assert
scannet_gt_classes
.
shape
==
(
27
,
1
)
assert
scannet_gt_boxes_mask
.
shape
==
(
27
,
1
)
assert
scannet_instance_labels
.
shape
==
(
1000
,
)
assert
scannet_semantic_labels
.
shape
==
(
1000
,
)
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