From 14e6e08a0e0d02835979e0ff083159027f61dea4 Mon Sep 17 00:00:00 2001 From: Wuziyi616 Date: Tue, 20 Apr 2021 21:26:33 +0800 Subject: [PATCH] fix small bugs --- configs/_base_/datasets/scannet-3d-18class.py | 11 +---------- mmdet3d/core/visualizer/show_result.py | 5 +---- mmdet3d/datasets/__init__.py | 3 +-- mmdet3d/datasets/scannet_dataset.py | 13 ++----------- .../test_datasets/test_scannet_dataset.py | 18 ++---------------- tools/data_converter/scannet_data_utils.py | 3 --- 6 files changed, 7 insertions(+), 46 deletions(-) diff --git a/configs/_base_/datasets/scannet-3d-18class.py b/configs/_base_/datasets/scannet-3d-18class.py index b97e858ba5..8fdd5e142a 100644 --- a/configs/_base_/datasets/scannet-3d-18class.py +++ b/configs/_base_/datasets/scannet-3d-18class.py @@ -5,8 +5,6 @@ 'bookshelf', 'picture', 'counter', 'desk', 'curtain', 'refrigerator', 'showercurtrain', 'toilet', 'sink', 'bathtub', 'garbagebin') -valid_class_ids = (3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 16, 24, 28, 33, 34, 36, - 39) train_pipeline = [ dict( type='LoadPointsFromFile', @@ -79,7 +77,6 @@ ] # construct a pipeline for data and gt loading in show function # please keep its loading function consistent with test_pipeline (e.g. client) -# we need to load gt masks for aligned gt bbox extracting eval_pipeline = [ dict( type='LoadPointsFromFile', @@ -87,18 +84,12 @@ shift_height=False, load_dim=6, use_dim=[0, 1, 2]), - dict( - type='LoadAnnotations3D', - with_bbox_3d=True, - with_label_3d=True, - with_mask_3d=False, - with_seg_3d=False), dict(type='GlobalAlignment', rotation_axis=2), dict( type='DefaultFormatBundle3D', class_names=class_names, with_label=False), - dict(type='Collect3D', keys=['points', 'gt_bboxes_3d', 'gt_labels_3d']) + dict(type='Collect3D', keys=['points']) ] data = dict( diff --git a/mmdet3d/core/visualizer/show_result.py b/mmdet3d/core/visualizer/show_result.py index e7b4789e0a..c4f414ad3a 100644 --- a/mmdet3d/core/visualizer/show_result.py +++ b/mmdet3d/core/visualizer/show_result.py @@ -61,10 +61,7 @@ def convert_oriented_box_to_trimesh_fmt(box): scene_bbox = np.zeros((1, 7)) scene = trimesh.scene.Scene() for box in scene_bbox: - try: - scene.add_geometry(convert_oriented_box_to_trimesh_fmt(box)) - except ValueError: # invalid box shape, e.g. width==0 - continue + scene.add_geometry(convert_oriented_box_to_trimesh_fmt(box)) mesh_list = trimesh.util.concatenate(scene.dump()) # save to obj file diff --git a/mmdet3d/datasets/__init__.py b/mmdet3d/datasets/__init__.py index f98b22858d..3dbab47e5c 100644 --- a/mmdet3d/datasets/__init__.py +++ b/mmdet3d/datasets/__init__.py @@ -27,8 +27,7 @@ 'DATASETS', 'build_dataset', 'CocoDataset', 'NuScenesDataset', 'NuScenesMonoDataset', 'LyftDataset', 'ObjectSample', 'RandomFlip3D', 'ObjectNoise', 'GlobalRotScaleTrans', 'PointShuffle', 'ObjectRangeFilter', - 'PointsRangeFilter', 'Collect3D', 'LoadPointsFromFile', - 'S3DISSegDataset', + 'PointsRangeFilter', 'Collect3D', 'LoadPointsFromFile', 'S3DISSegDataset', 'NormalizePointsColor', 'IndoorPatchPointSample', 'IndoorPointSample', 'LoadAnnotations3D', 'GlobalAlignment', 'SUNRGBDDataset', 'ScanNetDataset', 'ScanNetSegDataset', 'SemanticKITTIDataset', 'Custom3DDataset', diff --git a/mmdet3d/datasets/scannet_dataset.py b/mmdet3d/datasets/scannet_dataset.py index 1dfff7d7f7..eaba0ad3fc 100644 --- a/mmdet3d/datasets/scannet_dataset.py +++ b/mmdet3d/datasets/scannet_dataset.py @@ -163,20 +163,12 @@ def _build_default_pipeline(self): shift_height=False, load_dim=6, use_dim=[0, 1, 2]), - dict( - type='LoadAnnotations3D', - with_bbox_3d=True, - with_label_3d=True, - with_mask_3d=False, - with_seg_3d=False), dict(type='GlobalAlignment', rotation_axis=2), dict( type='DefaultFormatBundle3D', class_names=self.CLASSES, with_label=False), - dict( - type='Collect3D', - keys=['points', 'gt_bboxes_3d', 'gt_labels_3d']) + dict(type='Collect3D', keys=['points']) ] return Compose(pipeline) @@ -196,8 +188,7 @@ def show(self, results, out_dir, show=True, pipeline=None): data_info = self.data_infos[i] pts_path = data_info['pts_path'] file_name = osp.split(pts_path)[-1].split('.')[0] - points = self._extract_data( - i, pipeline, 'points', load_annos=True).numpy() + points = self._extract_data(i, pipeline, 'points').numpy() gt_bboxes = self.get_ann_info(i)['gt_bboxes_3d'].tensor.numpy() pred_bboxes = result['boxes_3d'].tensor.numpy() show_result(points, gt_bboxes, pred_bboxes, out_dir, file_name, diff --git a/tests/test_data/test_datasets/test_scannet_dataset.py b/tests/test_data/test_datasets/test_scannet_dataset.py index 1974553447..b907fe92cb 100644 --- a/tests/test_data/test_datasets/test_scannet_dataset.py +++ b/tests/test_data/test_datasets/test_scannet_dataset.py @@ -183,19 +183,12 @@ def test_evaluate(): shift_height=False, load_dim=6, use_dim=[0, 1, 2]), - dict( - type='LoadAnnotations3D', - with_bbox_3d=True, - with_label_3d=True, - with_mask_3d=False, - with_seg_3d=False), dict(type='GlobalAlignment', rotation_axis=2), dict( type='DefaultFormatBundle3D', class_names=class_names, with_label=False), - dict( - type='Collect3D', keys=['points', 'gt_bboxes_3d', 'gt_labels_3d']) + dict(type='Collect3D', keys=['points']) ] ret_dict = scannet_dataset.evaluate( results, metric, pipeline=eval_pipeline) @@ -265,19 +258,12 @@ def test_show(): shift_height=False, load_dim=6, use_dim=[0, 1, 2]), - dict( - type='LoadAnnotations3D', - with_bbox_3d=True, - with_label_3d=True, - with_mask_3d=False, - with_seg_3d=False), dict(type='GlobalAlignment', rotation_axis=2), dict( type='DefaultFormatBundle3D', class_names=class_names, with_label=False), - dict( - type='Collect3D', keys=['points', 'gt_bboxes_3d', 'gt_labels_3d']) + dict(type='Collect3D', keys=['points']) ] tmp_dir = tempfile.TemporaryDirectory() temp_dir = tmp_dir.name diff --git a/tools/data_converter/scannet_data_utils.py b/tools/data_converter/scannet_data_utils.py index c94ab54156..c52b3f5b63 100644 --- a/tools/data_converter/scannet_data_utils.py +++ b/tools/data_converter/scannet_data_utils.py @@ -219,9 +219,6 @@ def _convert_to_label(self, mask): mask = np.load(mask) else: mask = np.fromfile(mask, dtype=np.long) - # first filter out unannotated points (labeled as 0) - mask = mask[mask != 0] - # then convert to [0, 20) labels label = self.cat_id2class[mask] return label