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
24deecb3
Commit
24deecb3
authored
May 01, 2020
by
liyinhao
Browse files
fix load data comments
parent
93a2b097
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
84 additions
and
42 deletions
+84
-42
mmdet3d/datasets/pipelines/indoor_loading.py
mmdet3d/datasets/pipelines/indoor_loading.py
+53
-30
tests/test_indoor_loading.py
tests/test_indoor_loading.py
+30
-11
tools/data_converter/sunrgbd_data_utils.py
tools/data_converter/sunrgbd_data_utils.py
+1
-1
No files found.
mmdet3d/datasets/pipelines/indoor_loading.py
View file @
24deecb3
...
@@ -6,10 +6,10 @@ from mmdet.datasets.registry import PIPELINES
...
@@ -6,10 +6,10 @@ from mmdet.datasets.registry import PIPELINES
@
PIPELINES
.
register_module
@
PIPELINES
.
register_module
class
IndoorLoadData
(
object
):
class
LoadPointsFromFile
(
object
):
"""Load
Indoor Data
"""Load
Points From File.
Load sunrgbd and scannet
data
.
Load sunrgbd and scannet
points from file
.
Args:
Args:
name (str): scannet or sunrgbd.
name (str): scannet or sunrgbd.
...
@@ -18,9 +18,7 @@ class IndoorLoadData(object):
...
@@ -18,9 +18,7 @@ class IndoorLoadData(object):
mean_color (List[float]): Mean color of the point cloud.
mean_color (List[float]): Mean color of the point cloud.
"""
"""
def
__init__
(
self
,
name
,
use_color
,
use_height
,
mean_color
):
def
__init__
(
self
,
use_color
,
use_height
,
mean_color
):
assert
name
in
[
'scannet'
,
'sunrgbd'
]
self
.
name
=
name
self
.
use_color
=
use_color
self
.
use_color
=
use_color
self
.
use_height
=
use_height
self
.
use_height
=
use_height
self
.
mean_color
=
mean_color
self
.
mean_color
=
mean_color
...
@@ -28,32 +26,21 @@ class IndoorLoadData(object):
...
@@ -28,32 +26,21 @@ class IndoorLoadData(object):
def
__call__
(
self
,
results
):
def
__call__
(
self
,
results
):
data_path
=
results
.
get
(
'data_path'
,
None
)
data_path
=
results
.
get
(
'data_path'
,
None
)
info
=
results
.
get
(
'info'
,
None
)
info
=
results
.
get
(
'info'
,
None
)
name
=
'scannet'
if
info
.
get
(
'image'
,
None
)
is
None
else
'sunrgbd'
if
info
[
'annos'
][
'gt_num'
]
!=
0
:
if
name
==
'scannet'
:
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
))
if
self
.
name
==
'scannet'
:
scan_name
=
info
[
'point_cloud'
][
'lidar_idx'
]
scan_name
=
info
[
'point_cloud'
][
'lidar_idx'
]
point_cloud
=
self
.
_get_lidar
(
scan_name
,
data_path
)
point_cloud
=
self
.
_get_lidar
(
scan_name
,
data_path
)
instance_labels
=
self
.
_get_instance_label
(
scan_name
,
data_path
)
semantic_labels
=
self
.
_get_semantic_label
(
scan_name
,
data_path
)
else
:
else
:
point_cloud
=
np
.
load
(
point_cloud
=
np
.
load
(
osp
.
join
(
data_path
,
'lidar'
,
osp
.
join
(
data_path
,
'lidar'
,
'%06d.npz'
%
info
[
'point_cloud'
][
'lidar_idx'
]))[
'pc'
]
'%06d.npz'
%
info
[
'point_cloud'
][
'lidar_idx'
]))[
'pc'
]
if
not
self
.
use_color
:
if
not
self
.
use_color
:
if
self
.
name
==
'scannet'
:
if
name
==
'scannet'
:
pcl_color
=
point_cloud
[:,
3
:
6
]
pcl_color
=
point_cloud
[:,
3
:
6
]
point_cloud
=
point_cloud
[:,
0
:
3
]
# do not use color for now
point_cloud
=
point_cloud
[:,
0
:
3
]
else
:
else
:
if
self
.
name
==
'scannet'
:
if
name
==
'scannet'
:
pcl_color
=
point_cloud
[:,
3
:
6
]
pcl_color
=
point_cloud
[:,
3
:
6
]
point_cloud
=
point_cloud
[:,
0
:
6
]
point_cloud
=
point_cloud
[:,
0
:
6
]
point_cloud
[:,
3
:]
=
(
point_cloud
[:,
3
:]
-
point_cloud
[:,
3
:]
=
(
point_cloud
[:,
3
:]
-
...
@@ -65,19 +52,12 @@ class IndoorLoadData(object):
...
@@ -65,19 +52,12 @@ class IndoorLoadData(object):
point_cloud
=
np
.
concatenate
(
point_cloud
=
np
.
concatenate
(
[
point_cloud
,
np
.
expand_dims
(
height
,
1
)],
1
)
[
point_cloud
,
np
.
expand_dims
(
height
,
1
)],
1
)
results
[
'point_cloud'
]
=
point_cloud
results
[
'point_cloud'
]
=
point_cloud
if
name
==
'scannet'
:
if
self
.
name
==
'scannet'
:
results
[
'pcl_color'
]
=
pcl_color
results
[
'pcl_color'
]
=
pcl_color
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
return
results
def
__repr__
(
self
):
def
__repr__
(
self
):
repr_str
=
self
.
__class__
.
__name__
repr_str
=
self
.
__class__
.
__name__
repr_str
+=
'(dataset_name={})'
.
format
(
self
.
name
)
repr_str
+=
'(use_height={})'
.
format
(
self
.
use_height
)
repr_str
+=
'(use_height={})'
.
format
(
self
.
use_height
)
repr_str
+=
'(use_color={}'
.
format
(
self
.
use_color
)
repr_str
+=
'(use_color={}'
.
format
(
self
.
use_color
)
repr_str
+=
'(mean_color={})'
.
format
(
self
.
mean_color
)
repr_str
+=
'(mean_color={})'
.
format
(
self
.
mean_color
)
...
@@ -88,6 +68,49 @@ class IndoorLoadData(object):
...
@@ -88,6 +68,49 @@ class IndoorLoadData(object):
assert
osp
.
exists
(
lidar_file
)
assert
osp
.
exists
(
lidar_file
)
return
np
.
load
(
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
):
def
_get_instance_label
(
self
,
scan_name
,
data_path
):
ins_file
=
osp
.
join
(
data_path
,
scan_name
+
'_ins_label.npy'
)
ins_file
=
osp
.
join
(
data_path
,
scan_name
+
'_ins_label.npy'
)
assert
osp
.
exists
(
ins_file
)
assert
osp
.
exists
(
ins_file
)
...
...
tests/test_indoor_loading.py
View file @
24deecb3
import
mmcv
import
mmcv
from
mmdet3d.datasets.pipelines.indoor_loading
import
IndoorLoadData
from
mmdet3d.datasets.pipelines.indoor_loading
import
(
LoadAnnotations3D
,
LoadPointsFromFile
)
def
test_
indoor_load_data
():
def
test_
load_points_from_file
():
sunrgbd_info
=
mmcv
.
load
(
'./tests/data/sunrgbd/sunrgbd_infos.pkl'
)
sunrgbd_info
=
mmcv
.
load
(
'./tests/data/sunrgbd/sunrgbd_infos.pkl'
)
sunrgbd_load_data
=
IndoorLoadData
(
'sunrgbd'
,
False
,
True
,
[
0.5
,
0.5
,
0.5
])
sunrgbd_load_points_from_file
=
LoadPointsFromFile
(
False
,
True
,
[
0.5
,
0.5
,
0.5
])
sunrgbd_results
=
dict
()
sunrgbd_results
=
dict
()
sunrgbd_results
[
'data_path'
]
=
'./tests/data/sunrgbd/sunrgbd_trainval'
sunrgbd_results
[
'data_path'
]
=
'./tests/data/sunrgbd/sunrgbd_trainval'
sunrgbd_results
[
'info'
]
=
sunrgbd_info
[
0
]
sunrgbd_results
[
'info'
]
=
sunrgbd_info
[
0
]
sunrgbd_results
=
sunrgbd_load_
data
(
sunrgbd_results
)
sunrgbd_results
=
sunrgbd_load_
points_from_file
(
sunrgbd_results
)
sunrgbd_point_cloud
=
sunrgbd_results
.
get
(
'point_cloud'
,
None
)
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_boxes
=
sunrgbd_results
.
get
(
'gt_boxes'
,
None
)
sunrgbd_gt_classes
=
sunrgbd_results
.
get
(
'gt_classes'
,
None
)
sunrgbd_gt_classes
=
sunrgbd_results
.
get
(
'gt_classes'
,
None
)
sunrgbd_gt_boxes_mask
=
sunrgbd_results
.
get
(
'gt_boxes_mask'
,
None
)
sunrgbd_gt_boxes_mask
=
sunrgbd_results
.
get
(
'gt_boxes_mask'
,
None
)
assert
sunrgbd_point_cloud
.
shape
==
(
1000
,
4
)
assert
sunrgbd_gt_boxes
.
shape
==
(
3
,
7
)
assert
sunrgbd_gt_boxes
.
shape
==
(
3
,
7
)
assert
sunrgbd_gt_classes
.
shape
==
(
3
,
1
)
assert
sunrgbd_gt_classes
.
shape
==
(
3
,
1
)
assert
sunrgbd_gt_boxes_mask
.
shape
==
(
3
,
1
)
assert
sunrgbd_gt_boxes_mask
.
shape
==
(
3
,
1
)
scannet_info
=
mmcv
.
load
(
'./tests/data/scannet/scannet_infos.pkl'
)
scannet_info
=
mmcv
.
load
(
'./tests/data/scannet/scannet_infos.pkl'
)
scannet_load_
data
=
IndoorLoadData
(
'scannet'
,
False
,
True
,
[
0.5
,
0.5
,
0.5
]
)
scannet_load_
annotations3D
=
LoadAnnotations3D
(
)
scannet_results
=
dict
()
scannet_results
=
dict
()
scannet_results
[
scannet_results
[
'data_path'
]
=
'./tests/data/scannet/scannet_train_instance_data'
'data_path'
]
=
'./tests/data/scannet/scannet_train_instance_data'
scannet_results
[
'info'
]
=
scannet_info
[
0
]
scannet_results
[
'info'
]
=
scannet_info
[
0
]
scannet_results
=
scannet_load_data
(
scannet_results
)
scannet_results
=
scannet_load_annotations3D
(
scannet_results
)
scannet_point_cloud
=
scannet_results
.
get
(
'point_cloud'
,
None
)
scannet_gt_boxes
=
scannet_results
.
get
(
'gt_boxes'
,
None
)
scannet_gt_boxes
=
scannet_results
.
get
(
'gt_boxes'
,
None
)
scannet_gt_classes
=
scannet_results
.
get
(
'gt_classes'
,
None
)
scannet_gt_classes
=
scannet_results
.
get
(
'gt_classes'
,
None
)
scannet_gt_boxes_mask
=
scannet_results
.
get
(
'gt_boxes_mask'
,
None
)
scannet_gt_boxes_mask
=
scannet_results
.
get
(
'gt_boxes_mask'
,
None
)
scannet_pcl_color
=
scannet_results
.
get
(
'pcl_color'
,
None
)
scannet_instance_labels
=
scannet_results
.
get
(
'instance_labels'
,
None
)
scannet_instance_labels
=
scannet_results
.
get
(
'instance_labels'
,
None
)
scannet_semantic_labels
=
scannet_results
.
get
(
'semantic_labels'
,
None
)
scannet_semantic_labels
=
scannet_results
.
get
(
'semantic_labels'
,
None
)
assert
scannet_point_cloud
.
shape
==
(
1000
,
4
)
assert
scannet_gt_boxes
.
shape
==
(
27
,
6
)
assert
scannet_gt_boxes
.
shape
==
(
27
,
6
)
assert
scannet_gt_classes
.
shape
==
(
27
,
1
)
assert
scannet_gt_classes
.
shape
==
(
27
,
1
)
assert
scannet_gt_boxes_mask
.
shape
==
(
27
,
1
)
assert
scannet_gt_boxes_mask
.
shape
==
(
27
,
1
)
assert
scannet_pcl_color
.
shape
==
(
1000
,
3
)
assert
scannet_instance_labels
.
shape
==
(
1000
,
)
assert
scannet_instance_labels
.
shape
==
(
1000
,
)
assert
scannet_semantic_labels
.
shape
==
(
1000
,
)
assert
scannet_semantic_labels
.
shape
==
(
1000
,
)
tools/data_converter/sunrgbd_data_utils.py
View file @
24deecb3
...
@@ -112,7 +112,7 @@ class SUNRGBDData(object):
...
@@ -112,7 +112,7 @@ class SUNRGBDData(object):
def
process_single_scene
(
sample_idx
):
def
process_single_scene
(
sample_idx
):
print
(
'%s sample_idx: %s'
%
(
self
.
split
,
sample_idx
))
print
(
'%s sample_idx: %s'
%
(
self
.
split
,
sample_idx
))
# convert depth to points
# convert depth to points
SAMPLE_NUM
=
1
000
SAMPLE_NUM
=
50
000
pc_upright_depth
=
self
.
get_depth
(
sample_idx
)
pc_upright_depth
=
self
.
get_depth
(
sample_idx
)
# TODO : sample points in loading process and test
# TODO : sample points in loading process and test
pc_upright_depth_subsampled
=
random_sampling
(
pc_upright_depth_subsampled
=
random_sampling
(
...
...
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