-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Feature] SemanticKITTI Dataset (#287)
* add ini * add semantickitti_dataset * add test semantickitti_dataset * delete last line in test_semmaticdataset * add test data * change_names * load_labels dytype * change_name * numpy * name * dtype string * minor issue-string * seg_3d_dtype
- Loading branch information
1 parent
c556d27
commit b050172
Showing
8 changed files
with
143 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
from os import path as osp | ||
|
||
from mmdet.datasets import DATASETS | ||
from .custom_3d import Custom3DDataset | ||
|
||
|
||
@DATASETS.register_module() | ||
class SemanticKITTIDataset(Custom3DDataset): | ||
r"""SemanticKITTI Dataset. | ||
This class serves as the API for experiments on the SemanticKITTI Dataset | ||
Please refer to <http://www.semantic-kitti.org/dataset.html>`_ | ||
for data downloading | ||
Args: | ||
data_root (str): Path of dataset root. | ||
ann_file (str): Path of annotation file. | ||
pipeline (list[dict], optional): Pipeline used for data processing. | ||
Defaults to None. | ||
classes (tuple[str], optional): Classes used in the dataset. | ||
Defaults to None. | ||
modality (dict, optional): Modality to specify the sensor data used | ||
as input. Defaults to None. | ||
box_type_3d (str, optional): NO 3D box for this dataset. | ||
You can choose any type | ||
Based on the `box_type_3d`, the dataset will encapsulate the box | ||
to its original format then converted them to `box_type_3d`. | ||
Defaults to 'LiDAR' in this dataset. Available options includes | ||
- 'LiDAR': Box in LiDAR coordinates. | ||
- 'Depth': Box in depth coordinates, usually for indoor dataset. | ||
- 'Camera': Box in camera coordinates. | ||
filter_empty_gt (bool, optional): Whether to filter empty GT. | ||
Defaults to True. | ||
test_mode (bool, optional): Whether the dataset is in test mode. | ||
Defaults to False. | ||
""" | ||
CLASSES = ('unlabeled', 'car', 'bicycle', 'motorcycle', 'truck', 'bus', | ||
'person', 'bicyclist', 'motorcyclist', 'road', 'parking', | ||
'sidewalk', 'other-ground', 'building', 'fence', 'vegetation', | ||
'trunck', 'terrian', 'pole', 'traffic-sign') | ||
|
||
def __init__(self, | ||
data_root, | ||
ann_file, | ||
pipeline=None, | ||
classes=None, | ||
modality=None, | ||
box_type_3d='Lidar', | ||
filter_empty_gt=False, | ||
test_mode=False): | ||
super().__init__( | ||
data_root=data_root, | ||
ann_file=ann_file, | ||
pipeline=pipeline, | ||
classes=classes, | ||
modality=modality, | ||
box_type_3d=box_type_3d, | ||
filter_empty_gt=filter_empty_gt, | ||
test_mode=test_mode) | ||
|
||
def get_ann_info(self, index): | ||
"""Get annotation info according to the given index. | ||
Args: | ||
index (int): Index of the annotation data to get. | ||
Returns: | ||
dict: annotation information consists of the following keys: | ||
- pts_semantic_mask_path (str): Path of semantic masks. | ||
""" | ||
# Use index to get the annos, thus the evalhook could also use this api | ||
info = self.data_infos[index] | ||
|
||
pts_semantic_mask_path = osp.join(self.data_root, | ||
info['pts_semantic_mask_path']) | ||
|
||
anns_results = dict(pts_semantic_mask_path=pts_semantic_mask_path) | ||
return anns_results |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import numpy as np | ||
|
||
from mmdet3d.datasets import SemanticKITTIDataset | ||
|
||
|
||
def test_getitem(): | ||
np.random.seed(0) | ||
root_path = './tests/data/semantickitti/' | ||
ann_file = './tests/data/semantickitti/semantickitti_infos.pkl' | ||
class_names = ('unlabeled', 'car', 'bicycle', 'motorcycle', 'truck', 'bus', | ||
'person', 'bicyclist', 'motorcyclist', 'road', 'parking', | ||
'sidewalk', 'other-ground', 'building', 'fence', | ||
'vegetation', 'trunck', 'terrian', 'pole', 'traffic-sign') | ||
pipelines = [ | ||
dict( | ||
type='LoadPointsFromFile', | ||
coord_type='LIDAR', | ||
shift_height=True, | ||
load_dim=4, | ||
use_dim=[0, 1, 2]), | ||
dict( | ||
type='LoadAnnotations3D', | ||
with_bbox_3d=False, | ||
with_label_3d=False, | ||
with_mask_3d=False, | ||
with_seg_3d=True, | ||
seg_3d_dtype=np.int32), | ||
dict( | ||
type='RandomFlip3D', | ||
sync_2d=False, | ||
flip_ratio_bev_horizontal=1.0, | ||
flip_ratio_bev_vertical=1.0), | ||
dict( | ||
type='GlobalRotScaleTrans', | ||
rot_range=[-0.087266, 0.087266], | ||
scale_ratio_range=[1.0, 1.0], | ||
shift_height=True), | ||
dict(type='DefaultFormatBundle3D', class_names=class_names), | ||
dict( | ||
type='Collect3D', | ||
keys=[ | ||
'points', | ||
'pts_semantic_mask', | ||
], | ||
meta_keys=['file_name', 'sample_idx', 'pcd_rotation']), | ||
] | ||
|
||
semantickitti_dataset = SemanticKITTIDataset(root_path, ann_file, | ||
pipelines) | ||
data = semantickitti_dataset[0] | ||
assert data['points']._data.shape[0] == data[ | ||
'pts_semantic_mask']._data.shape[0] |