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
5219773a
Commit
5219773a
authored
Apr 28, 2020
by
liyinhao
Browse files
change names, change some os method to mmcv method
parent
90396ed6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
17 deletions
+16
-17
tools/data_converter/scannet_data_utils.py
tools/data_converter/scannet_data_utils.py
+5
-4
tools/data_converter/sunrgbd_data_utils.py
tools/data_converter/sunrgbd_data_utils.py
+11
-13
No files found.
tools/data_converter/scannet_data_utils.py
View file @
5219773a
import
concurrent.futures
as
futures
import
os
import
mmcv
import
numpy
as
np
...
...
@@ -33,10 +34,10 @@ class ScanNetData(object):
for
i
,
nyu40id
in
enumerate
(
list
(
self
.
cat_ids
))
}
assert
split
in
[
'train'
,
'val'
,
'test'
]
split_
dir
=
os
.
path
.
join
(
self
.
root_dir
,
'meta_data'
,
f
'scannetv2_
{
split
}
.txt'
)
self
.
sample_id_list
=
[
x
.
strip
()
for
x
in
open
(
split_dir
).
readlines
(
)
]
if
os
.
path
.
exists
(
split_dir
)
else
None
split_
file
=
os
.
path
.
join
(
self
.
root_dir
,
'meta_data'
,
f
'scannetv2_
{
split
}
.txt'
)
mmcv
.
check_file_exist
(
split_file
)
self
.
sample_id_list
=
mmcv
.
list_from_file
(
split_file
)
def
__len__
(
self
):
return
len
(
self
.
sample_id_list
)
...
...
tools/data_converter/sunrgbd_data_utils.py
View file @
5219773a
...
...
@@ -6,14 +6,14 @@ import numpy as np
import
scipy.io
as
sio
def
random_sampling
(
pc
,
num_
sample
s
,
replace
=
None
,
return_choices
=
False
):
def
random_sampling
(
pc
,
num_
point
s
,
replace
=
None
,
return_choices
=
False
):
"""Random Sampling.
Sampling point cloud to
num_samples
points.
Sampling point cloud to
a certain number of
points.
Args:
pc (ndarray): Point cloud.
num_
sample
s (int): The number of samples.
num_
point
s (int): The number of samples.
replace (bool): Whether the sample is with or without replacement.
return_choices (bool): Whether to return choices.
...
...
@@ -22,8 +22,8 @@ def random_sampling(pc, num_samples, replace=None, return_choices=False):
"""
if
replace
is
None
:
replace
=
(
pc
.
shape
[
0
]
<
num_
sample
s
)
choices
=
np
.
random
.
choice
(
pc
.
shape
[
0
],
num_
sample
s
,
replace
=
replace
)
replace
=
(
pc
.
shape
[
0
]
<
num_
point
s
)
choices
=
np
.
random
.
choice
(
pc
.
shape
[
0
],
num_
point
s
,
replace
=
replace
)
if
return_choices
:
return
pc
[
choices
],
choices
else
:
...
...
@@ -81,11 +81,9 @@ class SUNRGBDData(object):
for
label
in
range
(
len
(
self
.
classes
))
}
assert
split
in
[
'train'
,
'val'
,
'test'
]
split_dir
=
os
.
path
.
join
(
self
.
root_dir
,
f
'
{
split
}
_data_idx.txt'
)
self
.
sample_id_list
=
[
int
(
x
.
strip
())
for
x
in
open
(
split_dir
).
readlines
()
]
if
os
.
path
.
exists
(
split_dir
)
else
None
split_file
=
os
.
path
.
join
(
self
.
root_dir
,
f
'
{
split
}
_data_idx.txt'
)
mmcv
.
check_file_exist
(
split_file
)
self
.
sample_id_list
=
map
(
int
,
mmcv
.
list_from_file
(
split_file
))
self
.
image_dir
=
os
.
path
.
join
(
self
.
split_dir
,
'image'
)
self
.
calib_dir
=
os
.
path
.
join
(
self
.
split_dir
,
'calib'
)
self
.
depth_dir
=
os
.
path
.
join
(
self
.
split_dir
,
'depth'
)
...
...
@@ -143,8 +141,9 @@ class SUNRGBDData(object):
print
(
f
'
{
self
.
split
}
sample_idx:
{
sample_idx
}
'
)
# convert depth to points
SAMPLE_NUM
=
50000
# TODO: Check whether can move the point
# sampling process during training.
pc_upright_depth
=
self
.
get_depth
(
sample_idx
)
# TODO : sample points in loading process and test
pc_upright_depth_subsampled
=
random_sampling
(
pc_upright_depth
,
SAMPLE_NUM
)
np
.
savez_compressed
(
...
...
@@ -213,8 +212,7 @@ class SUNRGBDData(object):
return
info
lidar_save_dir
=
os
.
path
.
join
(
self
.
root_dir
,
'lidar'
)
if
not
os
.
path
.
exists
(
lidar_save_dir
):
os
.
mkdir
(
lidar_save_dir
)
mmcv
.
mkdir_or_exist
(
lidar_save_dir
)
sample_id_list
=
sample_id_list
if
\
sample_id_list
is
not
None
else
self
.
sample_id_list
with
futures
.
ThreadPoolExecutor
(
num_workers
)
as
executor
:
...
...
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