Skip to content

Commit

Permalink
fix small bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
Wuziyi616 committed May 7, 2021
1 parent bebbc2b commit 14e6e08
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 46 deletions.
11 changes: 1 addition & 10 deletions configs/_base_/datasets/scannet-3d-18class.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -79,26 +77,19 @@
]
# 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',
coord_type='DEPTH',
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(
Expand Down
5 changes: 1 addition & 4 deletions mmdet3d/core/visualizer/show_result.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions mmdet3d/datasets/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
13 changes: 2 additions & 11 deletions mmdet3d/datasets/scannet_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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,
Expand Down
18 changes: 2 additions & 16 deletions tests/test_data/test_datasets/test_scannet_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions tools/data_converter/scannet_data_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 14e6e08

Please sign in to comment.