Skip to content

SemanticKITTI

The SemanticKITTI dataset, as described in the paper SemanticKITTI: A Dataset for Semantic Scene Understanding of LiDAR Sequences.

First page of SemanticKITTI: A Dataset for Semantic Scene Understanding of LiDAR Sequences

1904.01416 · April 2019

Classes:

  • SemanticKITTI –

    The SemanticKITTI dataset, as described in the paper

Functions:

SemanticKITTI

SemanticKITTI(
    root: PathLike,
    *,
    split: Union[SemanticKittiSplit, str] = "train",
    sequences: Optional[
        ValueCollection[Union[SemanticKittiSequence, str]]
    ] = None,
    transform: Optional[
        Callable[[Dict[str, Any]], Dict[str, Any]]
    ] = None,
)

Bases: PointCloudDataset

The SemanticKITTI dataset, as described in the paper SemanticKITTI: A Dataset for Semantic Scene Understanding of LiDAR Sequences.

The dataset contains a sequence of LiDAR scans collected from a vehicle driving in several urban areas, with point-wise semantic and instance annotations. The 22 sequences are split into train (00-07, 09, 10), val (08), and test (11-21). Test labels are not publicly available; only the velodyne scans are released.

Note

The raw dataset must be downloaded manually from https://www.semantic-kitti.org/dataset.html (a license must be accepted). The expected layout under <root>/SemanticKITTI/raw is:

sequences/
    00/
        velodyne/{frame:06d}.bin
        labels/{frame:06d}.label
    01/
        ...

Each sample is returned as a dict with the following keys:

Key Shape Dtype Description
pos \((N, 3)\) float32 XYZ coordinates
intensity \((N, 1)\) float32 Reflected LiDAR intensity
segment \((N,)\) int64 Raw per-point semantic id (when available)
instance \((N,)\) int64 Per-point instance id (when available)
sequence - str Source sequence id (e.g. "00")
frame - str Source frame id (e.g. "000000")
Note

Scans are loaded from disk on demand (lazy loading), so the dataset can be used with very large splits without exhausting host memory. As a consequence, the dataset has no process step: it just enumerates .bin files at construction time. Augmentation, voxelization, feature normalization, and label remapping are intentionally left out so they can be composed with torch_pointcloud.transforms and shared across models.

Note

segment contains the raw SemanticKITTI label ids (see SEMANTIC_KITTI_LABEL_NAMES); no class merging or contiguous remapping is applied. Compose a downstream torch_pointcloud.transforms.Relabel to project them onto the (model-specific) class set you train against.

Parameters:

  • root (PathLike) –

    Root directory of the dataset. Raw data is expected under <root>/SemanticKITTI/raw/sequences/<seq>/....

  • split (Union[SemanticKittiSplit, str], default: 'train' ) –

    One of "train", "val", "trainval", or "test". Selects the sequences used by the official benchmark. Ignored when sequences is set.

  • sequences (Optional[ValueCollection[Union[SemanticKittiSequence, str]]], default: None ) –

    Optional explicit list of sequences to use. Overrides split.

  • transform (Optional[Callable[[Dict[str, Any]], Dict[str, Any]]], default: None ) –

    Callable applied to each sample dict at __getitem__ time. Used for augmentation, voxelization, label remapping, feature construction, etc.

Example

Assuming you have downloaded the raw dataset and extracted it under data/SemanticKITTI/raw/sequences/..., you can load the validation split:

from torch_pointcloud.datasets import SemanticKITTI

dataset = SemanticKITTI(root="data", split="val")
sample = dataset[0]
sample["pos"].shape         # torch.Size([N, 3])
sample["intensity"].shape   # torch.Size([N, 1])
sample["segment"].shape     # torch.Size([N]) - raw label ids in [0, 259]

To map raw labels onto a 19-class training set, compose a Relabel transform yourself. The mapping below follows the evaluation protocol this library's SemanticKITTI pretrained weights were trained against. It is not the official semantic-kitti-api learning map: the official 19-class map merges bus (13) and on-rails (16) into other-vehicle and lane-marking (60) into road, whereas this one sends them to the ignore index.

import torch_pointcloud.transforms as T
from torch_pointcloud.datasets import SemanticKITTI

# `{raw_id: contiguous_index}`
# (moving-* are merged with their static counterpart; bus/on-rails/
# lane-marking/other-* fall through to `default=255`).
labels = {
    10: 0, 252: 0,                  # car (+ moving-car)
    11: 1,                          # bicycle
    15: 2,                          # motorcycle
    18: 3, 258: 3,                  # truck (+ moving-truck)
    20: 4, 259: 4,                  # other-vehicle (+ moving-other-vehicle)
    30: 5, 254: 5,                  # person (+ moving-person)
    31: 6, 253: 6,                  # bicyclist (+ moving-bicyclist)
    32: 7, 255: 7,                  # motorcyclist (+ moving-motorcyclist)
    40: 8, 44: 9, 48: 10, 49: 11,   # road, parking, sidewalk, other-ground
    50: 12, 51: 13,                 # building, fence
    70: 14, 71: 15, 72: 16,         # vegetation, trunk, terrain
    80: 17, 81: 18,                 # pole, traffic-sign
}
dataset = SemanticKITTI(
    root="data",
    split="val",
    transform=T.Relabel(keys="segment", labels=labels, default=255),
)

Methods:

  • download –

    SemanticKITTI must be downloaded manually (a license must be accepted).

  • load –

    Enumerate the velodyne scans for the configured sequences.

Attributes:

  • sequences_dir (str) –

    Path to the raw sequences directory.

  • processed_dir (str) –

    Path to the processed cache directory, which aliases raw_dir since the scans are read as-is.

  • name (str) –

    Name of the dataset directory.

  • data_dir (str) –

    Path to the dataset directory <root>/<name>.

  • raw_dir (str) –

    Path to the raw download directory.

sequences_dir property

sequences_dir: str

Path to the raw sequences directory.

processed_dir property

processed_dir: str

Path to the processed cache directory, which aliases raw_dir since the scans are read as-is.

name property

name: str

Name of the dataset directory.

data_dir property

data_dir: str

Path to the dataset directory <root>/<name>.

raw_dir property

raw_dir: str

Path to the raw download directory.

download

download(force: bool = False) -> None

SemanticKITTI must be downloaded manually (a license must be accepted).

Parameters:

  • force (bool, default: False ) –

    Unused; present to mirror the other datasets' download signature.

Raises: RuntimeError: Always; automatic download is not supported.

load

load() -> None

Enumerate the velodyne scans for the configured sequences.

This populates self.scans with (sequence, frame, bin_path, label_path) tuples, where label_path is None when no .label file is present (e.g. test split). Raises a RuntimeError listing the missing sequences when only part of the requested sequences has velodyne scans on disk.

load_semantickitti_scan

load_semantickitti_scan(
    file_path: PathLike,
) -> tuple[Tensor, Tensor]

Load a single SemanticKITTI velodyne scan from a .bin file.

Each .bin file contains a raw float32 array of shape \((N \cdot 4,)\) interpreted as \((N, 4)\) points with columns (x, y, z, intensity).

Parameters:

  • file_path (PathLike) –

    Path to the .bin file.

Returns:

  • tuple[Tensor, Tensor] –

    A pair (pos, intensity) of tensors with shapes \((N, 3)\) and \((N, 1)\).

Example
from torch_pointcloud.datasets.semantickitti import load_semantickitti_scan

pos, intensity = load_semantickitti_scan(
    "data/SemanticKITTI/raw/sequences/00/velodyne/000000.bin"
)

load_semantickitti_labels

load_semantickitti_labels(
    file_path: PathLike,
) -> tuple[Tensor, Tensor]

Load a single SemanticKITTI .label file.

Each .label file contains a raw uint32 array of shape \((N,)\) where the lower 16 bits encode the semantic label and the upper 16 bits encode the instance id.

Parameters:

  • file_path (PathLike) –

    Path to the .label file.

Returns:

  • Tensor –

    A pair (segment, instance) of int64 tensors with shape \((N,)\), where

  • Tensor –

    segment contains the raw semantic label ids (see

  • tuple[Tensor, Tensor] –

    SEMANTIC_KITTI_LABEL_NAMES) and instance contains the per-class

  • tuple[Tensor, Tensor] –

    instance ids.

Example
from torch_pointcloud.datasets.semantickitti import load_semantickitti_labels

segment, instance = load_semantickitti_labels(
    "data/SemanticKITTI/raw/sequences/00/labels/000000.label"
)