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
dd53c2ac
Unverified
Commit
dd53c2ac
authored
Feb 18, 2023
by
Xiang Xu
Committed by
GitHub
Feb 18, 2023
Browse files
[Feature] Update test set to v2 version (#2285)
* support test set * update waymo version
parent
216c1642
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
166 additions
and
150 deletions
+166
-150
tools/create_data.py
tools/create_data.py
+6
-4
tools/dataset_converters/update_infos_to_v2.py
tools/dataset_converters/update_infos_to_v2.py
+160
-146
No files found.
tools/create_data.py
View file @
dd53c2ac
...
@@ -35,9 +35,11 @@ def kitti_data_prep(root_path,
...
@@ -35,9 +35,11 @@ def kitti_data_prep(root_path,
info_train_path
=
osp
.
join
(
out_dir
,
f
'
{
info_prefix
}
_infos_train.pkl'
)
info_train_path
=
osp
.
join
(
out_dir
,
f
'
{
info_prefix
}
_infos_train.pkl'
)
info_val_path
=
osp
.
join
(
out_dir
,
f
'
{
info_prefix
}
_infos_val.pkl'
)
info_val_path
=
osp
.
join
(
out_dir
,
f
'
{
info_prefix
}
_infos_val.pkl'
)
info_trainval_path
=
osp
.
join
(
out_dir
,
f
'
{
info_prefix
}
_infos_trainval.pkl'
)
info_trainval_path
=
osp
.
join
(
out_dir
,
f
'
{
info_prefix
}
_infos_trainval.pkl'
)
info_test_path
=
osp
.
join
(
out_dir
,
f
'
{
info_prefix
}
_infos_test.pkl'
)
update_pkl_infos
(
'kitti'
,
out_dir
=
out_dir
,
pkl_path
=
info_train_path
)
update_pkl_infos
(
'kitti'
,
out_dir
=
out_dir
,
pkl_path
=
info_train_path
)
update_pkl_infos
(
'kitti'
,
out_dir
=
out_dir
,
pkl_path
=
info_val_path
)
update_pkl_infos
(
'kitti'
,
out_dir
=
out_dir
,
pkl_path
=
info_val_path
)
update_pkl_infos
(
'kitti'
,
out_dir
=
out_dir
,
pkl_path
=
info_trainval_path
)
update_pkl_infos
(
'kitti'
,
out_dir
=
out_dir
,
pkl_path
=
info_trainval_path
)
update_pkl_infos
(
'kitti'
,
out_dir
=
out_dir
,
pkl_path
=
info_test_path
)
create_groundtruth_database
(
create_groundtruth_database
(
'KittiDataset'
,
'KittiDataset'
,
root_path
,
root_path
,
...
@@ -122,11 +124,11 @@ def scannet_data_prep(root_path, info_prefix, out_dir, workers):
...
@@ -122,11 +124,11 @@ def scannet_data_prep(root_path, info_prefix, out_dir, workers):
indoor
.
create_indoor_info_file
(
indoor
.
create_indoor_info_file
(
root_path
,
info_prefix
,
out_dir
,
workers
=
workers
)
root_path
,
info_prefix
,
out_dir
,
workers
=
workers
)
info_train_path
=
osp
.
join
(
out_dir
,
f
'
{
info_prefix
}
_infos_train.pkl'
)
info_train_path
=
osp
.
join
(
out_dir
,
f
'
{
info_prefix
}
_infos_train.pkl'
)
info_test_path
=
osp
.
join
(
out_dir
,
f
'
{
info_prefix
}
_infos_test.pkl'
)
info_val_path
=
osp
.
join
(
out_dir
,
f
'
{
info_prefix
}
_infos_val.pkl'
)
info_val_path
=
osp
.
join
(
out_dir
,
f
'
{
info_prefix
}
_infos_val.pkl'
)
info_test_path
=
osp
.
join
(
out_dir
,
f
'
{
info_prefix
}
_infos_test.pkl'
)
update_pkl_infos
(
'scannet'
,
out_dir
=
out_dir
,
pkl_path
=
info_train_path
)
update_pkl_infos
(
'scannet'
,
out_dir
=
out_dir
,
pkl_path
=
info_train_path
)
update_pkl_infos
(
'scannet'
,
out_dir
=
out_dir
,
pkl_path
=
info_test_path
)
update_pkl_infos
(
'scannet'
,
out_dir
=
out_dir
,
pkl_path
=
info_val_path
)
update_pkl_infos
(
'scannet'
,
out_dir
=
out_dir
,
pkl_path
=
info_val_path
)
update_pkl_infos
(
'scannet'
,
out_dir
=
out_dir
,
pkl_path
=
info_test_path
)
def
s3dis_data_prep
(
root_path
,
info_prefix
,
out_dir
,
workers
):
def
s3dis_data_prep
(
root_path
,
info_prefix
,
out_dir
,
workers
):
...
@@ -210,11 +212,11 @@ def waymo_data_prep(root_path,
...
@@ -210,11 +212,11 @@ def waymo_data_prep(root_path,
info_train_path
=
osp
.
join
(
out_dir
,
f
'
{
info_prefix
}
_infos_train.pkl'
)
info_train_path
=
osp
.
join
(
out_dir
,
f
'
{
info_prefix
}
_infos_train.pkl'
)
info_val_path
=
osp
.
join
(
out_dir
,
f
'
{
info_prefix
}
_infos_val.pkl'
)
info_val_path
=
osp
.
join
(
out_dir
,
f
'
{
info_prefix
}
_infos_val.pkl'
)
info_trainval_path
=
osp
.
join
(
out_dir
,
f
'
{
info_prefix
}
_infos_trainval.pkl'
)
info_trainval_path
=
osp
.
join
(
out_dir
,
f
'
{
info_prefix
}
_infos_trainval.pkl'
)
test_path
=
osp
.
join
(
out_dir
,
f
'
{
info_prefix
}
_infos_test.pkl'
)
info_
test_path
=
osp
.
join
(
out_dir
,
f
'
{
info_prefix
}
_infos_test.pkl'
)
update_pkl_infos
(
'waymo'
,
out_dir
=
out_dir
,
pkl_path
=
info_train_path
)
update_pkl_infos
(
'waymo'
,
out_dir
=
out_dir
,
pkl_path
=
info_train_path
)
update_pkl_infos
(
'waymo'
,
out_dir
=
out_dir
,
pkl_path
=
info_val_path
)
update_pkl_infos
(
'waymo'
,
out_dir
=
out_dir
,
pkl_path
=
info_val_path
)
update_pkl_infos
(
'waymo'
,
out_dir
=
out_dir
,
pkl_path
=
info_trainval_path
)
update_pkl_infos
(
'waymo'
,
out_dir
=
out_dir
,
pkl_path
=
info_trainval_path
)
update_pkl_infos
(
'waymo'
,
out_dir
=
out_dir
,
pkl_path
=
test_path
)
update_pkl_infos
(
'waymo'
,
out_dir
=
out_dir
,
pkl_path
=
info_
test_path
)
GTDatabaseCreater
(
GTDatabaseCreater
(
'WaymoDataset'
,
'WaymoDataset'
,
out_dir
,
out_dir
,
...
...
tools/dataset_converters/update_infos_to_v2.py
View file @
dd53c2ac
...
@@ -337,29 +337,34 @@ def update_nuscenes_infos(pkl_path, out_dir):
...
@@ -337,29 +337,34 @@ def update_nuscenes_infos(pkl_path, out_dir):
empty_img_info
[
'lidar2cam'
]
=
lidar2sensor
.
astype
(
empty_img_info
[
'lidar2cam'
]
=
lidar2sensor
.
astype
(
np
.
float32
).
tolist
()
np
.
float32
).
tolist
()
temp_data_info
[
'images'
][
cam
]
=
empty_img_info
temp_data_info
[
'images'
][
cam
]
=
empty_img_info
num_instances
=
ori_info_dict
[
'gt_boxes'
].
shape
[
0
]
ignore_class_name
=
set
()
ignore_class_name
=
set
()
for
i
in
range
(
num_instances
):
if
'gt_boxes'
in
ori_info_dict
:
empty_instance
=
get_empty_instance
()
num_instances
=
ori_info_dict
[
'gt_boxes'
].
shape
[
0
]
empty_instance
[
'bbox_3d'
]
=
ori_info_dict
[
'gt_boxes'
][
for
i
in
range
(
num_instances
):
i
,
:].
tolist
()
empty_instance
=
get_empty_instance
()
if
ori_info_dict
[
'gt_names'
][
i
]
in
METAINFO
[
'classes'
]:
empty_instance
[
'bbox_3d'
]
=
ori_info_dict
[
'gt_boxes'
][
empty_instance
[
'bbox_label'
]
=
METAINFO
[
'classes'
].
index
(
i
,
:].
tolist
()
ori_info_dict
[
'gt_names'
][
i
])
if
ori_info_dict
[
'gt_names'
][
i
]
in
METAINFO
[
'classes'
]:
else
:
empty_instance
[
'bbox_label'
]
=
METAINFO
[
'classes'
].
index
(
ignore_class_name
.
add
(
ori_info_dict
[
'gt_names'
][
i
])
ori_info_dict
[
'gt_names'
][
i
])
empty_instance
[
'bbox_label'
]
=
-
1
else
:
empty_instance
[
'bbox_label_3d'
]
=
copy
.
deepcopy
(
ignore_class_name
.
add
(
ori_info_dict
[
'gt_names'
][
i
])
empty_instance
[
'bbox_label'
])
empty_instance
[
'bbox_label'
]
=
-
1
empty_instance
[
'velocity'
]
=
ori_info_dict
[
'gt_velocity'
][
empty_instance
[
'bbox_label_3d'
]
=
copy
.
deepcopy
(
i
,
:].
tolist
()
empty_instance
[
'bbox_label'
])
empty_instance
[
'num_lidar_pts'
]
=
ori_info_dict
[
'num_lidar_pts'
][
i
]
empty_instance
[
'velocity'
]
=
ori_info_dict
[
'gt_velocity'
][
empty_instance
[
'num_radar_pts'
]
=
ori_info_dict
[
'num_radar_pts'
][
i
]
i
,
:].
tolist
()
empty_instance
[
'bbox_3d_isvalid'
]
=
ori_info_dict
[
'valid_flag'
][
i
]
empty_instance
[
'num_lidar_pts'
]
=
ori_info_dict
[
empty_instance
=
clear_instance_unused_keys
(
empty_instance
)
'num_lidar_pts'
][
i
]
temp_data_info
[
'instances'
].
append
(
empty_instance
)
empty_instance
[
'num_radar_pts'
]
=
ori_info_dict
[
temp_data_info
[
'cam_instances'
]
=
generate_nuscenes_camera_instances
(
'num_radar_pts'
][
i
]
ori_info_dict
,
nusc
)
empty_instance
[
'bbox_3d_isvalid'
]
=
ori_info_dict
[
'valid_flag'
][
i
]
empty_instance
=
clear_instance_unused_keys
(
empty_instance
)
temp_data_info
[
'instances'
].
append
(
empty_instance
)
temp_data_info
[
'cam_instances'
]
=
generate_nuscenes_camera_instances
(
ori_info_dict
,
nusc
)
temp_data_info
,
_
=
clear_data_info_unused_keys
(
temp_data_info
)
temp_data_info
,
_
=
clear_data_info_unused_keys
(
temp_data_info
)
converted_list
.
append
(
temp_data_info
)
converted_list
.
append
(
temp_data_info
)
pkl_name
=
Path
(
pkl_path
).
name
pkl_name
=
Path
(
pkl_path
).
name
...
@@ -444,61 +449,63 @@ def update_kitti_infos(pkl_path, out_dir):
...
@@ -444,61 +449,63 @@ def update_kitti_infos(pkl_path, out_dir):
temp_data_info
[
'lidar_points'
][
'Tr_imu_to_velo'
]
=
ori_info_dict
[
temp_data_info
[
'lidar_points'
][
'Tr_imu_to_velo'
]
=
ori_info_dict
[
'calib'
][
'Tr_imu_to_velo'
].
astype
(
np
.
float32
).
tolist
()
'calib'
][
'Tr_imu_to_velo'
].
astype
(
np
.
float32
).
tolist
()
anns
=
ori_info_dict
[
'annos'
]
num_instances
=
len
(
anns
[
'name'
])
cam2img
=
ori_info_dict
[
'calib'
][
'P2'
]
cam2img
=
ori_info_dict
[
'calib'
][
'P2'
]
anns
=
ori_info_dict
.
get
(
'annos'
,
None
)
ignore_class_name
=
set
()
ignore_class_name
=
set
()
instance_list
=
[]
if
anns
is
not
None
:
for
instance_id
in
range
(
num_instances
):
num_instances
=
len
(
anns
[
'name'
])
empty_instance
=
get_empty_instance
()
instance_list
=
[]
empty_instance
[
'bbox'
]
=
anns
[
'bbox'
][
instance_id
].
tolist
()
for
instance_id
in
range
(
num_instances
):
empty_instance
=
get_empty_instance
()
if
anns
[
'name'
][
instance_id
]
in
METAINFO
[
'classes'
]:
empty_instance
[
'bbox'
]
=
anns
[
'bbox'
][
instance_id
].
tolist
()
empty_instance
[
'bbox_label'
]
=
METAINFO
[
'classes'
].
index
(
anns
[
'name'
][
instance_id
])
if
anns
[
'name'
][
instance_id
]
in
METAINFO
[
'classes'
]:
else
:
empty_instance
[
'bbox_label'
]
=
METAINFO
[
'classes'
].
index
(
ignore_class_name
.
add
(
anns
[
'name'
][
instance_id
])
anns
[
'name'
][
instance_id
])
empty_instance
[
'bbox_label'
]
=
-
1
else
:
ignore_class_name
.
add
(
anns
[
'name'
][
instance_id
])
empty_instance
[
'bbox'
]
=
anns
[
'bbox'
][
instance_id
].
tolist
()
empty_instance
[
'bbox_label'
]
=
-
1
loc
=
anns
[
'location'
][
instance_id
]
empty_instance
[
'bbox'
]
=
anns
[
'bbox'
][
instance_id
].
tolist
()
dims
=
anns
[
'dimensions'
][
instance_id
]
rots
=
anns
[
'rotation_y'
][:,
None
][
instance_id
]
loc
=
anns
[
'location'
][
instance_id
]
dims
=
anns
[
'dimensions'
][
instance_id
]
dst
=
np
.
array
([
0.5
,
0.5
,
0.5
])
rots
=
anns
[
'rotation_y'
][:,
None
][
instance_id
]
src
=
np
.
array
([
0.5
,
1.0
,
0.5
])
dst
=
np
.
array
([
0.5
,
0.5
,
0.5
])
center_3d
=
loc
+
dims
*
(
dst
-
src
)
src
=
np
.
array
([
0.5
,
1.0
,
0.5
])
center_2d
=
points_cam2img
(
center_3d
.
reshape
([
1
,
3
]),
cam2img
,
with_depth
=
True
)
center_3d
=
loc
+
dims
*
(
dst
-
src
)
center_2d
=
center_2d
.
squeeze
().
tolist
()
center_2d
=
points_cam2img
(
empty_instance
[
'center_2d'
]
=
center_2d
[:
2
]
center_3d
.
reshape
([
1
,
3
]),
cam2img
,
with_depth
=
True
)
empty_instance
[
'depth'
]
=
center_2d
[
2
]
center_2d
=
center_2d
.
squeeze
().
tolist
()
empty_instance
[
'center_2d'
]
=
center_2d
[:
2
]
gt_bboxes_3d
=
np
.
concatenate
([
loc
,
dims
,
rots
]).
tolist
()
empty_instance
[
'depth'
]
=
center_2d
[
2
]
empty_instance
[
'bbox_3d'
]
=
gt_bboxes_3d
empty_instance
[
'bbox_label_3d'
]
=
copy
.
deepcopy
(
gt_bboxes_3d
=
np
.
concatenate
([
loc
,
dims
,
rots
]).
tolist
()
empty_instance
[
'bbox_label'
])
empty_instance
[
'bbox_3d'
]
=
gt_bboxes_3d
empty_instance
[
'bbox'
]
=
anns
[
'bbox'
][
instance_id
].
tolist
()
empty_instance
[
'bbox_label_3d'
]
=
copy
.
deepcopy
(
empty_instance
[
'truncated'
]
=
anns
[
'truncated'
][
empty_instance
[
'bbox_label'
])
instance_id
].
tolist
()
empty_instance
[
'bbox'
]
=
anns
[
'bbox'
][
instance_id
].
tolist
()
empty_instance
[
'occluded'
]
=
anns
[
'occluded'
][
instance_id
].
tolist
()
empty_instance
[
'truncated'
]
=
anns
[
'truncated'
][
empty_instance
[
'alpha'
]
=
anns
[
'alpha'
][
instance_id
].
tolist
()
instance_id
].
tolist
()
empty_instance
[
'score'
]
=
anns
[
'score'
][
instance_id
].
tolist
()
empty_instance
[
'occluded'
]
=
anns
[
'occluded'
][
empty_instance
[
'index'
]
=
anns
[
'index'
][
instance_id
].
tolist
()
instance_id
].
tolist
()
empty_instance
[
'group_id'
]
=
anns
[
'group_ids'
][
instance_id
].
tolist
(
empty_instance
[
'alpha'
]
=
anns
[
'alpha'
][
instance_id
].
tolist
()
)
empty_instance
[
'score'
]
=
anns
[
'score'
][
instance_id
].
tolist
()
empty_instance
[
'difficulty'
]
=
anns
[
'difficulty'
][
empty_instance
[
'index'
]
=
anns
[
'index'
][
instance_id
].
tolist
()
instance_id
].
tolist
()
empty_instance
[
'group_id'
]
=
anns
[
'group_ids'
][
empty_instance
[
'num_lidar_pts'
]
=
anns
[
'num_points_in_gt'
][
instance_id
].
tolist
()
instance_id
].
tolist
()
empty_instance
[
'difficulty'
]
=
anns
[
'difficulty'
][
empty_instance
=
clear_instance_unused_keys
(
empty_instance
)
instance_id
].
tolist
()
instance_list
.
append
(
empty_instance
)
empty_instance
[
'num_lidar_pts'
]
=
anns
[
'num_points_in_gt'
][
temp_data_info
[
'instances'
]
=
instance_list
instance_id
].
tolist
()
cam_instances
=
generate_kitti_camera_instances
(
ori_info_dict
)
empty_instance
=
clear_instance_unused_keys
(
empty_instance
)
temp_data_info
[
'cam_instances'
]
=
cam_instances
instance_list
.
append
(
empty_instance
)
temp_data_info
[
'instances'
]
=
instance_list
cam_instances
=
generate_kitti_camera_instances
(
ori_info_dict
)
temp_data_info
[
'cam_instances'
]
=
cam_instances
temp_data_info
,
_
=
clear_data_info_unused_keys
(
temp_data_info
)
temp_data_info
,
_
=
clear_data_info_unused_keys
(
temp_data_info
)
converted_list
.
append
(
temp_data_info
)
converted_list
.
append
(
temp_data_info
)
pkl_name
=
Path
(
pkl_path
).
name
pkl_name
=
Path
(
pkl_path
).
name
...
@@ -537,10 +544,12 @@ def update_s3dis_infos(pkl_path, out_dir):
...
@@ -537,10 +544,12 @@ def update_s3dis_infos(pkl_path, out_dir):
'point_cloud'
][
'num_features'
]
'point_cloud'
][
'num_features'
]
temp_data_info
[
'lidar_points'
][
'lidar_path'
]
=
Path
(
temp_data_info
[
'lidar_points'
][
'lidar_path'
]
=
Path
(
ori_info_dict
[
'pts_path'
]).
name
ori_info_dict
[
'pts_path'
]).
name
temp_data_info
[
'pts_semantic_mask_path'
]
=
Path
(
if
'pts_semantic_mask_path'
in
ori_info_dict
:
ori_info_dict
[
'pts_semantic_mask_path'
]).
name
temp_data_info
[
'pts_semantic_mask_path'
]
=
Path
(
temp_data_info
[
'pts_instance_mask_path'
]
=
Path
(
ori_info_dict
[
'pts_semantic_mask_path'
]).
name
ori_info_dict
[
'pts_instance_mask_path'
]).
name
if
'pts_instance_mask_path'
in
ori_info_dict
:
temp_data_info
[
'pts_instance_mask_path'
]
=
Path
(
ori_info_dict
[
'pts_instance_mask_path'
]).
name
# TODO support camera
# TODO support camera
# np.linalg.inv(info['axis_align_matrix'] @ extrinsic): depth2cam
# np.linalg.inv(info['axis_align_matrix'] @ extrinsic): depth2cam
...
@@ -611,37 +620,40 @@ def update_scannet_infos(pkl_path, out_dir):
...
@@ -611,37 +620,40 @@ def update_scannet_infos(pkl_path, out_dir):
'point_cloud'
][
'num_features'
]
'point_cloud'
][
'num_features'
]
temp_data_info
[
'lidar_points'
][
'lidar_path'
]
=
Path
(
temp_data_info
[
'lidar_points'
][
'lidar_path'
]
=
Path
(
ori_info_dict
[
'pts_path'
]).
name
ori_info_dict
[
'pts_path'
]).
name
temp_data_info
[
'pts_semantic_mask_path'
]
=
Path
(
if
'pts_semantic_mask_path'
in
ori_info_dict
:
ori_info_dict
[
'pts_semantic_mask_path'
]).
name
temp_data_info
[
'pts_semantic_mask_path'
]
=
Path
(
temp_data_info
[
'pts_instance_mask_path'
]
=
Path
(
ori_info_dict
[
'pts_semantic_mask_path'
]).
name
ori_info_dict
[
'pts_instance_mask_path'
]).
name
if
'pts_instance_mask_path'
in
ori_info_dict
:
temp_data_info
[
'pts_instance_mask_path'
]
=
Path
(
ori_info_dict
[
'pts_instance_mask_path'
]).
name
# TODO support camera
# TODO support camera
# np.linalg.inv(info['axis_align_matrix'] @ extrinsic): depth2cam
# np.linalg.inv(info['axis_align_matrix'] @ extrinsic): depth2cam
anns
=
ori_info_dict
[
'annos'
]
anns
=
ori_info_dict
.
get
(
'annos'
,
None
)
temp_data_info
[
'axis_align_matrix'
]
=
anns
[
'axis_align_matrix'
].
tolist
(
if
anns
is
not
None
:
)
temp_data_info
[
'axis_align_matrix'
]
=
anns
[
if
anns
[
'gt_num'
]
==
0
:
'axis_align_matrix'
].
tolist
()
instance_list
=
[]
if
anns
[
'gt_num'
]
==
0
:
else
:
instance_list
=
[]
num_instances
=
len
(
anns
[
'name'
])
else
:
ignore_class_name
=
set
()
num_instances
=
len
(
anns
[
'name'
])
instance_list
=
[]
ignore_class_name
=
set
()
for
instance_id
in
range
(
num_instances
):
instance_list
=
[]
empty_instance
=
get_empty_instance
()
for
instance_id
in
range
(
num_instances
):
empty_instance
[
'bbox_3d'
]
=
anns
[
'gt_boxes_upright_depth'
][
empty_instance
=
get_empty_instance
()
instance_id
].
tolist
()
empty_instance
[
'bbox_3d'
]
=
anns
[
'gt_boxes_upright_depth'
][
instance_id
].
tolist
()
if
anns
[
'name'
][
instance_id
]
in
METAINFO
[
'classes'
]:
if
anns
[
'name'
][
instance_id
]
in
METAINFO
[
'classes'
]:
empty_instance
[
'bbox_label_3d'
]
=
METAINFO
[
empty_instance
[
'bbox_label_3d'
]
=
METAINFO
[
'classes'
].
index
(
anns
[
'name'
][
instance_id
])
'classes'
].
index
(
anns
[
'name'
][
instance_id
])
else
:
else
:
ignore_class_name
.
add
(
anns
[
'name'
][
instance_id
])
ignore_class_name
.
add
(
anns
[
'name'
][
instance_id
])
empty_instance
[
'bbox_label_3d'
]
=
-
1
empty_instance
[
'bbox_label_3d'
]
=
-
1
empty_instance
=
clear_instance_unused_keys
(
empty_instance
)
empty_instance
=
clear_instance_unused_keys
(
empty_instance
)
instance_list
.
append
(
empty_instance
)
instance_list
.
append
(
empty_instance
)
temp_data_info
[
'instances'
]
=
instance_list
temp_data_info
[
'instances'
]
=
instance_list
temp_data_info
,
_
=
clear_data_info_unused_keys
(
temp_data_info
)
temp_data_info
,
_
=
clear_data_info_unused_keys
(
temp_data_info
)
converted_list
.
append
(
temp_data_info
)
converted_list
.
append
(
temp_data_info
)
pkl_name
=
Path
(
pkl_path
).
name
pkl_name
=
Path
(
pkl_path
).
name
...
@@ -696,30 +708,31 @@ def update_sunrgbd_infos(pkl_path, out_dir):
...
@@ -696,30 +708,31 @@ def update_sunrgbd_infos(pkl_path, out_dir):
temp_data_info
[
'images'
][
'CAM0'
][
'height'
]
=
h
temp_data_info
[
'images'
][
'CAM0'
][
'height'
]
=
h
temp_data_info
[
'images'
][
'CAM0'
][
'width'
]
=
w
temp_data_info
[
'images'
][
'CAM0'
][
'width'
]
=
w
anns
=
ori_info_dict
[
'annos'
]
anns
=
ori_info_dict
.
get
(
'annos'
,
None
)
if
anns
[
'gt_num'
]
==
0
:
if
anns
is
not
None
:
instance_list
=
[]
if
anns
[
'gt_num'
]
==
0
:
else
:
instance_list
=
[]
num_instances
=
len
(
anns
[
'name'
])
else
:
ignore_class_name
=
set
()
num_instances
=
len
(
anns
[
'name'
])
instance_list
=
[]
ignore_class_name
=
set
()
for
instance_id
in
range
(
num_instances
):
instance_list
=
[]
empty_instance
=
get_empty_instance
()
for
instance_id
in
range
(
num_instances
):
empty_instance
[
'bbox_3d'
]
=
anns
[
'gt_boxes_upright_depth'
][
empty_instance
=
get_empty_instance
()
instance_id
].
tolist
()
empty_instance
[
'bbox_3d'
]
=
anns
[
'gt_boxes_upright_depth'
][
empty_instance
[
'bbox'
]
=
anns
[
'bbox'
][
instance_id
].
tolist
()
instance_id
].
tolist
()
if
anns
[
'name'
][
instance_id
]
in
METAINFO
[
'classes'
]:
empty_instance
[
'bbox'
]
=
anns
[
'bbox'
][
instance_id
].
tolist
()
empty_instance
[
'bbox_label_3d'
]
=
METAINFO
[
if
anns
[
'name'
][
instance_id
]
in
METAINFO
[
'classes'
]:
'classes'
].
index
(
anns
[
'name'
][
instance_id
])
empty_instance
[
'bbox_label_3d'
]
=
METAINFO
[
empty_instance
[
'bbox_label'
]
=
empty_instance
[
'classes'
].
index
(
anns
[
'name'
][
instance_id
])
'bbox_label_3d'
]
empty_instance
[
'bbox_label'
]
=
empty_instance
[
else
:
'bbox_label_3d'
]
ignore_class_name
.
add
(
anns
[
'name'
][
instance_id
])
else
:
empty_instance
[
'bbox_label_3d'
]
=
-
1
ignore_class_name
.
add
(
anns
[
'name'
][
instance_id
])
empty_instance
[
'bbox_label'
]
=
-
1
empty_instance
[
'bbox_label_3d'
]
=
-
1
empty_instance
=
clear_instance_unused_keys
(
empty_instance
)
empty_instance
[
'bbox_label'
]
=
-
1
instance_list
.
append
(
empty_instance
)
empty_instance
=
clear_instance_unused_keys
(
empty_instance
)
temp_data_info
[
'instances'
]
=
instance_list
instance_list
.
append
(
empty_instance
)
temp_data_info
[
'instances'
]
=
instance_list
temp_data_info
,
_
=
clear_data_info_unused_keys
(
temp_data_info
)
temp_data_info
,
_
=
clear_data_info_unused_keys
(
temp_data_info
)
converted_list
.
append
(
temp_data_info
)
converted_list
.
append
(
temp_data_info
)
pkl_name
=
Path
(
pkl_path
).
name
pkl_name
=
Path
(
pkl_path
).
name
...
@@ -818,22 +831,23 @@ def update_lyft_infos(pkl_path, out_dir):
...
@@ -818,22 +831,23 @@ def update_lyft_infos(pkl_path, out_dir):
empty_img_info
[
'lidar2cam'
]
=
lidar2sensor
.
astype
(
empty_img_info
[
'lidar2cam'
]
=
lidar2sensor
.
astype
(
np
.
float32
).
tolist
()
np
.
float32
).
tolist
()
temp_data_info
[
'images'
][
cam
]
=
empty_img_info
temp_data_info
[
'images'
][
cam
]
=
empty_img_info
num_instances
=
ori_info_dict
[
'gt_boxes'
].
shape
[
0
]
ignore_class_name
=
set
()
ignore_class_name
=
set
()
for
i
in
range
(
num_instances
):
if
'gt_boxes'
in
ori_info_dict
:
empty_instance
=
get_empty_instance
()
num_instances
=
ori_info_dict
[
'gt_boxes'
].
shape
[
0
]
empty_instance
[
'bbox_3d'
]
=
ori_info_dict
[
'gt_boxes'
][
for
i
in
range
(
num_instances
):
i
,
:].
tolist
()
empty_instance
=
get_empty_instance
()
if
ori_info_dict
[
'gt_names'
][
i
]
in
METAINFO
[
'classes'
]:
empty_instance
[
'bbox_3d'
]
=
ori_info_dict
[
'gt_boxes'
][
empty_instance
[
'bbox_label'
]
=
METAINFO
[
'classes'
].
index
(
i
,
:].
tolist
()
ori_info_dict
[
'gt_names'
][
i
])
if
ori_info_dict
[
'gt_names'
][
i
]
in
METAINFO
[
'classes'
]:
else
:
empty_instance
[
'bbox_label'
]
=
METAINFO
[
'classes'
].
index
(
ignore_class_name
.
add
(
ori_info_dict
[
'gt_names'
][
i
])
ori_info_dict
[
'gt_names'
][
i
])
empty_instance
[
'bbox_label'
]
=
-
1
else
:
empty_instance
[
'bbox_label_3d'
]
=
copy
.
deepcopy
(
ignore_class_name
.
add
(
ori_info_dict
[
'gt_names'
][
i
])
empty_instance
[
'bbox_label'
])
empty_instance
[
'bbox_label'
]
=
-
1
empty_instance
=
clear_instance_unused_keys
(
empty_instance
)
empty_instance
[
'bbox_label_3d'
]
=
copy
.
deepcopy
(
temp_data_info
[
'instances'
].
append
(
empty_instance
)
empty_instance
[
'bbox_label'
])
empty_instance
=
clear_instance_unused_keys
(
empty_instance
)
temp_data_info
[
'instances'
].
append
(
empty_instance
)
temp_data_info
,
_
=
clear_data_info_unused_keys
(
temp_data_info
)
temp_data_info
,
_
=
clear_data_info_unused_keys
(
temp_data_info
)
converted_list
.
append
(
temp_data_info
)
converted_list
.
append
(
temp_data_info
)
pkl_name
=
Path
(
pkl_path
).
name
pkl_name
=
Path
(
pkl_path
).
name
...
@@ -954,7 +968,7 @@ def update_waymo_infos(pkl_path, out_dir):
...
@@ -954,7 +968,7 @@ def update_waymo_infos(pkl_path, out_dir):
temp_data_info
[
'lidar_sweeps'
].
append
(
lidar_sweep
)
temp_data_info
[
'lidar_sweeps'
].
append
(
lidar_sweep
)
temp_data_info
[
'image_sweeps'
].
append
(
image_sweep
)
temp_data_info
[
'image_sweeps'
].
append
(
image_sweep
)
anns
=
ori_info_dict
.
get
(
'annos'
)
anns
=
ori_info_dict
.
get
(
'annos'
,
None
)
ignore_class_name
=
set
()
ignore_class_name
=
set
()
if
anns
is
not
None
:
if
anns
is
not
None
:
num_instances
=
len
(
anns
[
'name'
])
num_instances
=
len
(
anns
[
'name'
])
...
@@ -1001,7 +1015,7 @@ def update_waymo_infos(pkl_path, out_dir):
...
@@ -1001,7 +1015,7 @@ def update_waymo_infos(pkl_path, out_dir):
temp_data_info
[
'instances'
]
=
instance_list
temp_data_info
[
'instances'
]
=
instance_list
# waymo provide the labels that sync with cam
# waymo provide the labels that sync with cam
anns
=
ori_info_dict
.
get
(
'cam_sync_annos'
)
anns
=
ori_info_dict
.
get
(
'cam_sync_annos'
,
None
)
ignore_class_name
=
set
()
ignore_class_name
=
set
()
if
anns
is
not
None
:
if
anns
is
not
None
:
num_instances
=
len
(
anns
[
'name'
])
num_instances
=
len
(
anns
[
'name'
])
...
@@ -1060,7 +1074,7 @@ def update_waymo_infos(pkl_path, out_dir):
...
@@ -1060,7 +1074,7 @@ def update_waymo_infos(pkl_path, out_dir):
for
ignore_class
in
ignore_class_name
:
for
ignore_class
in
ignore_class_name
:
metainfo
[
'categories'
][
ignore_class
]
=
-
1
metainfo
[
'categories'
][
ignore_class
]
=
-
1
metainfo
[
'dataset'
]
=
'waymo'
metainfo
[
'dataset'
]
=
'waymo'
metainfo
[
'version'
]
=
'1.
2
'
metainfo
[
'version'
]
=
'1.
4
'
metainfo
[
'info_version'
]
=
'1.1'
metainfo
[
'info_version'
]
=
'1.1'
converted_data_info
=
dict
(
metainfo
=
metainfo
,
data_list
=
converted_list
)
converted_data_info
=
dict
(
metainfo
=
metainfo
,
data_list
=
converted_list
)
...
...
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