Commit 7d68f829 authored by liyinhao's avatar liyinhao
Browse files

add two pipelines to the uninttest, change label shape and mask shape, delete init file

parent 2d3eac30
......@@ -127,6 +127,7 @@ class DefaultFormatBundle3D(DefaultFormatBundle):
gt_bboxes_3d_mask = results['gt_bboxes_3d_mask']
results['gt_bboxes_3d'] = results['gt_bboxes_3d'][
gt_bboxes_3d_mask]
if 'gt_names_3d' in results:
results['gt_names_3d'] = results['gt_names_3d'][
gt_bboxes_3d_mask]
if 'gt_bboxes_mask' in results:
......@@ -151,8 +152,10 @@ class DefaultFormatBundle3D(DefaultFormatBundle):
dtype=np.int64)
# we still assume one pipeline for one frame LiDAR
# thus, the 3D name is list[string]
if 'gt_names_3d' in results:
results['gt_labels_3d'] = np.array([
self.class_names.index(n) for n in results['gt_names_3d']
self.class_names.index(n)
for n in results['gt_names_3d']
],
dtype=np.int64)
results = super(DefaultFormatBundle3D, self).__call__(results)
......
......@@ -39,15 +39,16 @@ def test_load_annotations3D():
sunrgbd_info = mmcv.load('./tests/data/sunrgbd/sunrgbd_infos.pkl')[0]
if sunrgbd_info['annos']['gt_num'] != 0:
sunrgbd_gt_bboxes_3d = sunrgbd_info['annos']['gt_boxes_upright_depth']
sunrgbd_gt_labels = sunrgbd_info['annos']['class'].reshape(-1, 1)
sunrgbd_gt_bboxes_3d_mask = np.ones_like(sunrgbd_gt_labels)
sunrgbd_gt_labels = sunrgbd_info['annos']['class']
sunrgbd_gt_bboxes_3d_mask = np.ones_like(sunrgbd_gt_labels).astype(
np.bool)
else:
sunrgbd_gt_bboxes_3d = np.zeros((1, 6), dtype=np.float32)
sunrgbd_gt_labels = np.zeros((1, 1))
sunrgbd_gt_bboxes_3d_mask = np.zeros((1, 1))
sunrgbd_gt_labels = np.zeros((1, ))
sunrgbd_gt_bboxes_3d_mask = np.zeros((1, ))
assert sunrgbd_gt_bboxes_3d.shape == (3, 7)
assert sunrgbd_gt_labels.shape == (3, 1)
assert sunrgbd_gt_bboxes_3d_mask.shape == (3, 1)
assert sunrgbd_gt_labels.shape == (3, )
assert sunrgbd_gt_bboxes_3d_mask.shape == (3, )
scannet_info = mmcv.load('./tests/data/scannet/scannet_infos.pkl')[0]
scannet_load_annotations3D = IndoorLoadAnnotations3D()
......@@ -55,12 +56,13 @@ def test_load_annotations3D():
data_path = './tests/data/scannet/scannet_train_instance_data'
if scannet_info['annos']['gt_num'] != 0:
scannet_gt_bboxes_3d = scannet_info['annos']['gt_boxes_upright_depth']
scannet_gt_labels = scannet_info['annos']['class'].reshape(-1, 1)
scannet_gt_bboxes_3d_mask = np.ones_like(scannet_gt_labels)
scannet_gt_labels = scannet_info['annos']['class']
scannet_gt_bboxes_3d_mask = np.ones_like(scannet_gt_labels).astype(
np.bool)
else:
scannet_gt_bboxes_3d = np.zeros((1, 6), dtype=np.float32)
scannet_gt_labels = np.zeros((1, 1))
scannet_gt_bboxes_3d_mask = np.zeros((1, 1))
scannet_gt_labels = np.zeros((1, ))
scannet_gt_bboxes_3d_mask = np.zeros((1, )).astype(np.bool)
scan_name = scannet_info['point_cloud']['lidar_idx']
scannet_results['pts_instance_mask_path'] = osp.join(
data_path, f'{scan_name}_ins_label.npy')
......@@ -76,7 +78,7 @@ def test_load_annotations3D():
scannet_pts_instance_mask = scannet_results['pts_instance_mask']
scannet_pts_semantic_mask = scannet_results['pts_semantic_mask']
assert scannet_gt_boxes.shape == (27, 6)
assert scannet_gt_lbaels.shape == (27, 1)
assert scannet_gt_boxes_mask.shape == (27, 1)
assert scannet_gt_lbaels.shape == (27, )
assert scannet_gt_boxes_mask.shape == (27, )
assert scannet_pts_instance_mask.shape == (100, )
assert scannet_pts_semantic_mask.shape == (100, )
......@@ -7,6 +7,11 @@ from mmdet3d.datasets.pipelines import Compose
def test_scannet_pipeline():
class_names = ('cabinet', 'bed', 'chair', 'sofa', 'table', 'door',
'window', 'bookshelf', 'picture', 'counter', 'desk',
'curtain', 'refrigerator', 'showercurtrain', 'toilet',
'sink', 'bathtub', 'garbagebin')
np.random.seed(0)
pipelines = [
dict(
......@@ -21,7 +26,14 @@ def test_scannet_pipeline():
type='IndoorGlobalRotScale',
use_height=True,
rot_range=[-np.pi * 1 / 36, np.pi * 1 / 36],
scale_range=None)
scale_range=None),
dict(type='DefaultFormatBundle3D', class_names=class_names),
dict(
type='Collect3D',
keys=[
'points', 'gt_bboxes_3d', 'gt_labels', 'pts_semantic_mask',
'pts_instance_mask'
]),
]
pipeline = Compose(pipelines)
info = mmcv.load('./tests/data/scannet/scannet_infos.pkl')[0]
......@@ -32,13 +44,15 @@ def test_scannet_pipeline():
results['pts_filename'] = osp.join(data_path, f'{scan_name}_vert.npy')
if info['annos']['gt_num'] != 0:
scannet_gt_bboxes_3d = info['annos']['gt_boxes_upright_depth']
scannet_gt_labels = info['annos']['class'].reshape(-1, 1)
scannet_gt_bboxes_3d_mask = np.ones_like(scannet_gt_labels)
scannet_gt_labels = info['annos']['class']
scannet_gt_bboxes_3d_mask = np.ones_like(scannet_gt_labels).astype(
np.bool)
else:
scannet_gt_bboxes_3d = np.zeros((1, 6), dtype=np.float32)
scannet_gt_labels = np.zeros((1, 1))
scannet_gt_bboxes_3d_mask = np.zeros((1, 1))
scannet_gt_labels = np.zeros((1, ))
scannet_gt_bboxes_3d_mask = np.zeros((1, )).astype(np.bool)
scan_name = info['point_cloud']['lidar_idx']
results['pts_instance_mask_path'] = osp.join(data_path,
f'{scan_name}_ins_label.npy')
results['pts_semantic_mask_path'] = osp.join(data_path,
......@@ -46,10 +60,12 @@ def test_scannet_pipeline():
results['gt_bboxes_3d'] = scannet_gt_bboxes_3d
results['gt_labels'] = scannet_gt_labels
results['gt_bboxes_3d_mask'] = scannet_gt_bboxes_3d_mask
results = pipeline(results)
points = results['points']
gt_bboxes_3d = results['gt_bboxes_3d']
gt_labels = results['gt_labels']
points = results['points']._data
gt_bboxes_3d = results['gt_bboxes_3d']._data
gt_labels = results['gt_labels']._data
pts_semantic_mask = results['pts_semantic_mask']
pts_instance_mask = results['pts_instance_mask']
expected_points = np.array(
......@@ -73,12 +89,14 @@ def test_scannet_pipeline():
expected_pts_instance_mask = np.array([44, 22, 10, 10, 57])
assert np.allclose(points, expected_points)
assert np.allclose(gt_bboxes_3d[:5, :], expected_gt_bboxes_3d)
assert np.all(gt_labels.flatten() == expected_gt_labels)
assert np.all(gt_labels.numpy() == expected_gt_labels)
assert np.all(pts_semantic_mask == expected_pts_semantic_mask)
assert np.all(pts_instance_mask == expected_pts_instance_mask)
def test_sunrgbd_pipeline():
class_names = ('bed', 'table', 'sofa', 'chair', 'toilet', 'desk',
'dresser', 'night_stand', 'bookshelf', 'bathtub')
np.random.seed(0)
pipelines = [
dict(
......@@ -93,6 +111,8 @@ def test_sunrgbd_pipeline():
rot_range=[-np.pi / 6, np.pi / 6],
scale_range=[0.85, 1.15]),
dict(type='IndoorPointSample', num_points=5),
dict(type='DefaultFormatBundle3D', class_names=class_names),
dict(type='Collect3D', keys=['points', 'gt_bboxes_3d', 'gt_labels']),
]
pipeline = Compose(pipelines)
results = dict()
......@@ -104,19 +124,20 @@ def test_sunrgbd_pipeline():
if info['annos']['gt_num'] != 0:
gt_bboxes_3d = info['annos']['gt_boxes_upright_depth']
gt_labels = info['annos']['class'].reshape(-1, 1)
gt_bboxes_3d_mask = np.ones_like(gt_labels)
gt_labels = info['annos']['class']
gt_bboxes_3d_mask = np.ones_like(gt_labels).astype(np.bool)
else:
gt_bboxes_3d = np.zeros((1, 6), dtype=np.float32)
gt_labels = np.zeros((1, 1))
gt_bboxes_3d_mask = np.zeros((1, 1))
gt_labels = np.zeros((1, ))
gt_bboxes_3d_mask = np.zeros((1, )).astype(np.bool)
results['gt_bboxes_3d'] = gt_bboxes_3d
results['gt_labels'] = gt_labels
results['gt_bboxes_3d_mask'] = gt_bboxes_3d_mask
results = pipeline(results)
points = results['points']
gt_bboxes_3d = results['gt_bboxes_3d']
gt_labels = results['gt_labels']
points = results['points']._data
gt_bboxes_3d = results['gt_bboxes_3d']._data
gt_labels = results['gt_labels']._data
expected_points = np.array(
[[0.6570105, 1.5538014, 0.24514851, 1.0165423],
[0.656101, 1.558591, 0.21755838, 0.98895216],
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment