scannet_dataset.py 2.02 KB
Newer Older
1
2
3
4
5
import os.path as osp

import numpy as np

from mmdet.datasets import DATASETS
6
from .indoor_base_dataset import IndoorBaseDataset
7
8
9


@DATASETS.register_module()
10
class ScanNetDataset(IndoorBaseDataset):
11

12
13
14
15
16
17
18
19
20
    CLASSES = ('cabinet', 'bed', 'chair', 'sofa', 'table', 'door', 'window',
               'bookshelf', 'picture', 'counter', 'desk', 'curtain',
               'refrigerator', 'showercurtrain', 'toilet', 'sink', 'bathtub',
               'garbagebin')

    def __init__(self,
                 root_path,
                 ann_file,
                 pipeline=None,
liyinhao's avatar
liyinhao committed
21
                 classes=None,
yinchimaoliang's avatar
yinchimaoliang committed
22
23
                 test_mode=False,
                 with_label=True):
liyinhao's avatar
liyinhao committed
24
25
        super().__init__(root_path, ann_file, pipeline, classes, test_mode,
                         with_label)
26

yinchimaoliang's avatar
yinchimaoliang committed
27
    def _get_pts_filename(self, sample_idx):
28
        pts_filename = osp.join(self.root_path, f'{sample_idx}_vert.npy')
yinchimaoliang's avatar
yinchimaoliang committed
29
        return pts_filename
30

yinchimaoliang's avatar
yinchimaoliang committed
31
    def _get_ann_info(self, index, sample_idx):
32
        # Use index to get the annos, thus the evalhook could also use this api
liyinhao's avatar
liyinhao committed
33
        info = self.data_infos[index]
34
35
        if info['annos']['gt_num'] != 0:
            gt_bboxes_3d = info['annos']['gt_boxes_upright_depth']  # k, 6
yinchimaoliang's avatar
yinchimaoliang committed
36
            gt_labels = info['annos']['class']
37
            gt_bboxes_3d_mask = np.ones_like(gt_labels, dtype=np.bool)
38
39
        else:
            gt_bboxes_3d = np.zeros((1, 6), dtype=np.float32)
40
41
            gt_labels = np.zeros(1, dtype=np.bool)
            gt_bboxes_3d_mask = np.zeros(1, dtype=np.bool)
42
        pts_instance_mask_path = osp.join(self.root_path,
liyinhao's avatar
liyinhao committed
43
                                          f'{sample_idx}_ins_label.npy')
44
        pts_semantic_mask_path = osp.join(self.root_path,
liyinhao's avatar
liyinhao committed
45
                                          f'{sample_idx}_sem_label.npy')
46
47
48
49
50
51
52
53

        anns_results = dict(
            gt_bboxes_3d=gt_bboxes_3d,
            gt_labels=gt_labels,
            gt_bboxes_3d_mask=gt_bboxes_3d_mask,
            pts_instance_mask_path=pts_instance_mask_path,
            pts_semantic_mask_path=pts_semantic_mask_path)
        return anns_results