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

Classes:
-
SemanticKITTIβThe SemanticKITTI dataset, as described in the paper
Functions:
-
load_semantickitti_scanβLoad a single SemanticKITTI velodyne scan from a
.binfile. -
load_semantickitti_labelsβLoad a single SemanticKITTI
.labelfile.
SemanticKITTI [source] ΒΆ
SemanticKITTI(
root: PathLike,
*,
split: SemanticKittiSplit = "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:
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(SemanticKittiSplit, default:'train') βOne of
"train","val","trainval", or"test". Selects the sequences used by the official benchmark. Ignored whensequencesis 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 the 19-class benchmark, compose a Relabel transform with SEMANTIC_KITTI_LEARNING_MAP, the official semantic-kitti-api learning map (bus and on-rails merge into other-vehicle, lane-marking into road). Checkpoints trained with another map register their own: randlanet.semantickitti.tsung-han-wu sends those three classes to the ignore index.
import torch_pointcloud.transforms as T
from torch_pointcloud.datasets import SemanticKITTI
from torch_pointcloud.datasets.semantickitti import SEMANTIC_KITTI_LEARNING_MAP
dataset = SemanticKITTI(
root="data",
split="val",
transform=T.Relabel(keys="segment", labels=SEMANTIC_KITTI_LEARNING_MAP, 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
sequencesdirectory. -
processed_dir(str) βPath to the processed cache directory, which aliases
raw_dirsince 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.
processed_dir property ΒΆ
Path to the processed cache directory, which aliases raw_dir since the scans are read as-is.
download [source] ΒΆ
SemanticKITTI must be downloaded manually (a license must be accepted).
Parameters:
-
force(bool, default:False) βUnused; present to mirror the other datasets'
downloadsignature.
Raises: RuntimeError: Always; automatic download is not supported.
load [source] ΒΆ
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 [source] ΒΆ
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
.binfile.
Returns:
-
tuple[Tensor, Tensor]βA pair
(pos, intensity)of tensors with shapes \((N, 3)\) and \((N, 1)\).
load_semantickitti_labels [source] ΒΆ
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
.labelfile.
Returns:
-
TensorβA pair
(segment, instance)of int64 tensors with shape \((N,)\), where -
Tensorβsegmentcontains the raw semantic label ids (see -
tuple[Tensor, Tensor]βSEMANTIC_KITTI_LABEL_NAMES) andinstancecontains the per-class -
tuple[Tensor, Tensor]βinstance ids.