scannet
The ScanNet dataset as described in the paper ScanNet: Richly-annotated 3D Reconstructions of Indoor Scenes.

Classes:
-
ScanNetDataβPer-point arrays of one ScanNet scene, as returned by
load_scannet_scene. -
ScanNetβThe ScanNet dataset as described in the paper
-
ScanNet20βScanNet restricted to the standard 20-class semantic-segmentation benchmark.
-
ScanNet200βScanNet restricted to the 200-class benchmark, as described in the paper
Functions:
-
load_scannet_scene_meshβLoad a ScanNet PLY file and return the vertices and face.
-
load_scannet_scene_metadataβLoad a ScanNet metadata file and return the metadata.
-
load_scannet_scene_aggregation_and_segsβRead per-vertex instance ids and semantic labels from aggregation + segments.
-
load_scannet_labelsβLoad the ScanNet labels CSV file as a
pandas.DataFrameobject. -
select_scannet_classesβSelect the classes to load from the labels.
-
load_scannet_sceneβLoad a ScanNet scene and return the parsed points, color, normal, instance, and labels
-
tile_scannet_sceneβSplit a single ScanNet scene dict into fixed-size spatial blocks.
ScanNetData [source] ΒΆ
Bases: TypedDict
Per-point arrays of one ScanNet scene, as returned by load_scannet_scene.
ScanNet [source] ΒΆ
ScanNet(
root: PathLike,
*,
version: Literal["v1", "v2"] = "v2",
split: Literal["train", "test", "val"] = "train",
label_name: str = "nyu40class",
label_id: str = "nyu40id",
use_axis_alignment: bool = True,
return_superpoint: bool = False,
block_size: Optional[float] = None,
block_stride: float = 0.75,
num_nodes: int = 8192,
min_num_nodes: int = 100,
transform: Optional[Callable] = None,
download: bool = False,
force_download: bool = False,
force_process: bool = False,
show_progress: bool = True,
num_workers: Optional[int] = None,
accept_terms: bool = False,
)
Bases: PointCloudDataset
The ScanNet dataset as described in the paper ScanNet: Richly-annotated 3D Reconstructions of Indoor Scenes. This dataset contains 2.5M views in 1513 scans acquired in 707 distinct spaces. Each scan is annotated with 3D camera poses, meshes, object segmentation, and scene semantics for a total of 36,000 annotated object instance.
The dataset is available in two versions:
v1: The original dataset with 1,513 scans.v2: Improved annotation coverage to ~90% (from 63% in v1), with 100 more scans for test.
Note
It is recommended to use the v2 version, as it contains more annotated object instance. The v1 version is kept for backward compatibility.
Note
By default, the labels are taken from the nyu40class column in the labels CSV file, and the nyu40id column is used to sort the labels. Note than the class_to_idx property returns a dictionary mapping the class name to the contiguous index, and indices may not correspond to the nyu40id values.
In most cases, the loaded labels are contiguous; see class_to_idx for the mapping from class name to index (indices may not match raw nyu40id values in the source files).
Parameters:
-
root(PathLike) βThe root directory of the dataset.
-
version(Literal['v1', 'v2'], default:'v2') βThe version of the dataset to use.
-
split(Literal['train', 'test', 'val'], default:'train') βThe split to load, one of
train,val, ortest. -
label_name(str, default:'nyu40class') βThe name of the label column in the labels CSV file.
-
label_id(str, default:'nyu40id') βThe name of the id column in the labels CSV file.
-
use_axis_alignment(bool, default:True) βIf True, apply ScanNet's axis-alignment transform to the mesh.
-
return_superpoint(bool, default:False) βAlso emit the per-point
superpointids, read from the rawscans/<scene>/<scene>_vh_clean_2.0.010000.segs.jsonmesh segmentation (requires the raw scans). -
block_size(Optional[float], default:None) βIf set, split each scene into ground-plane blocks of this size (meters) for training.
-
block_stride(float, default:0.75) βStride between adjacent blocks when
block_sizeis set. -
num_nodes(int, default:8192) βNumber of points sampled per block (when
block_sizeis set) or per scene. -
min_num_nodes(int, default:100) βSkip blocks with fewer than this many points.
-
transform(Optional[Callable], default:None) βA callable that transforms the data when retrieved from the dataset.
-
download(bool, default:False) βWhether to download the raw data.
-
force_download(bool, default:False) βWhether to force the download of the raw data.
-
force_process(bool, default:False) βWhether to force the processing of the raw data.
-
show_progress(bool, default:True) βWhether to show a progress bar during processing.
-
num_workers(Optional[int], default:None) βWorker processes for preprocessing, or
Nonefor sequential processing. -
accept_terms(bool, default:False) βConfirm that you have signed the ScanNet terms of use (
terms_url). When leftFalse,downloadasks for the confirmation on the terminal, once in every process that triggers the download.
Example
Assuming you have downloaded the raw dataset from https://kaldir.vc.in.tum.de/scannet/, and extracted it under data/ScanNet/raw, you can load the dataset as follows:
from torch_pointcloud.datasets import ScanNet
dataset = ScanNet(
root="data",
version="v2",
split="train",
)
By default, the labels are taken from the nyu40class column in the labels CSV file, and the nyu40id column is used to map the labels to contiguous indices. You can change this by setting the label_name and label_id arguments.
For example, to use the raw_category column and the id column, you can do:
Methods:
-
read_sceneβRead one processed scene directory into a sample dict, relabeled if
relabelis set.
Attributes:
-
labels(DataFrame) βThe raw label table, read from the version's combined labels TSV.
-
classes(List[str]) βClass names in label order.
-
class_to_idx(Dict[str, int]) βMapping from class name to label index.
-
relabel(Optional[Relabel]) βTransform remapping the raw segment ids to the benchmark ids, or
Nonewhen they are used as-is. -
processed_dir(str) βPath to the processed cache directory, suffixed
_noalignwhen axis alignment is off. -
processed_files(List[Path]) βSorted list of the split's processed scene directories.
-
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.
labels cached property ΒΆ
The raw label table, read from the version's combined labels TSV.
class_to_idx cached property ΒΆ
Mapping from class name to label index.
relabel cached property ΒΆ
relabel: Optional[Relabel]
Transform remapping the raw segment ids to the benchmark ids, or None when they are used as-is.
processed_dir property ΒΆ
Path to the processed cache directory, suffixed _noalign when axis alignment is off.
processed_files property ΒΆ
Sorted list of the split's processed scene directories.
read_scene [source] ΒΆ
Read one processed scene directory into a sample dict, relabeled if relabel is set.
Parameters:
-
path(Path) βProcessed scene directory holding
pos.npy,color.npy,normal.npyand, when annotated,segment.npy/instance.npy.
Returns:
-
Dict[str, Any]βThe scene as a
DataKeys-keyed dict of tensors plus itsDataKeys.SCENEid.
ScanNet20 [source] ΒΆ
ScanNet20(
root: PathLike,
*,
version: Literal["v1", "v2"] = "v2",
split: Literal["train", "test", "val"] = "train",
use_axis_alignment: bool = True,
return_superpoint: bool = False,
block_size: Optional[float] = None,
block_stride: float = 0.75,
num_nodes: int = 8192,
min_num_nodes: int = 100,
transform: Optional[Callable] = None,
download: bool = False,
force_download: bool = False,
force_process: bool = False,
show_progress: bool = True,
num_workers: Optional[int] = None,
accept_terms: bool = False,
)
Bases: ScanNet
ScanNet restricted to the standard 20-class semantic-segmentation benchmark.
A thin wrapper over ScanNet that fixes the label columns to nyu40class / nyu40id and exposes the official 20-class benchmark label set (wall, floor, cabinet, ..., otherfurniture) plus the <unk> ignore class at index \(0\). The relabel transform, applied while loading, maps the raw NYU40 segment ids onto these contiguous benchmark indices; points outside the 20 classes map to <unk>. The processed cache lives in processed_20/ so it never collides with the base ScanNet or ScanNet200 caches.
Parameters:
-
root(PathLike) βThe root directory of the dataset.
-
version(Literal['v1', 'v2'], default:'v2') βThe version of the dataset to use.
-
split(Literal['train', 'test', 'val'], default:'train') βThe split to load, one of
train,val, ortest. -
use_axis_alignment(bool, default:True) βIf True, apply ScanNet's axis-alignment transform to the mesh.
-
return_superpoint(bool, default:False) βAlso emit the per-point
superpointids, read from the rawscans/<scene>/<scene>_vh_clean_2.0.010000.segs.jsonmesh segmentation (requires the raw scans). -
block_size(Optional[float], default:None) βIf set, split each scene into ground-plane blocks of this size (meters) for training.
-
block_stride(float, default:0.75) βStride between adjacent blocks when
block_sizeis set. -
num_nodes(int, default:8192) βNumber of points sampled per block (when
block_sizeis set) or per scene. -
min_num_nodes(int, default:100) βSkip blocks with fewer than this many points.
-
transform(Optional[Callable], default:None) βA callable that transforms the data when retrieved from the dataset.
-
download(bool, default:False) βWhether to download the raw data.
-
force_download(bool, default:False) βWhether to force the download of the raw data.
-
force_process(bool, default:False) βWhether to force the processing of the raw data.
-
show_progress(bool, default:True) βWhether to show a progress bar during processing.
-
num_workers(Optional[int], default:None) βWorker processes for preprocessing, or
Nonefor sequential processing. -
accept_terms(bool, default:False) βConfirm that you have signed the ScanNet terms of use (
terms_url). When leftFalse,downloadasks for the confirmation on the terminal, once in every process that triggers the download.
Example
Assuming you have downloaded the raw dataset from https://kaldir.vc.in.tum.de/scannet/ and extracted it under data/ScanNet/raw, you can load the benchmark labels as follows:
Methods:
-
read_sceneβRead one processed scene directory into a sample dict, relabeled if
relabelis set.
Attributes:
-
name(str) βName of the dataset directory (shared with
ScanNet). -
processed_dir(str) βPath to the processed cache directory, suffixed
_20for the 20-class benchmark. -
classes(List[str]) βClass names in label order.
-
relabel(Relabel) βTransform remapping the raw segment ids to the 20 benchmark ids.
-
data_dir(str) βPath to the dataset directory
<root>/<name>. -
raw_dir(str) βPath to the raw download directory.
-
labels(DataFrame) βThe raw label table, read from the version's combined labels TSV.
-
class_to_idx(Dict[str, int]) βMapping from class name to label index.
-
processed_files(List[Path]) βSorted list of the split's processed scene directories.
processed_dir property ΒΆ
Path to the processed cache directory, suffixed _20 for the 20-class benchmark.
relabel cached property ΒΆ
relabel: Relabel
Transform remapping the raw segment ids to the 20 benchmark ids.
labels cached property ΒΆ
The raw label table, read from the version's combined labels TSV.
class_to_idx cached property ΒΆ
Mapping from class name to label index.
processed_files property ΒΆ
Sorted list of the split's processed scene directories.
read_scene [source] ΒΆ
Read one processed scene directory into a sample dict, relabeled if relabel is set.
Parameters:
-
path(Path) βProcessed scene directory holding
pos.npy,color.npy,normal.npyand, when annotated,segment.npy/instance.npy.
Returns:
-
Dict[str, Any]βThe scene as a
DataKeys-keyed dict of tensors plus itsDataKeys.SCENEid.
ScanNet200 [source] ΒΆ
ScanNet200(
root: PathLike,
*,
version: Literal["v1", "v2"] = "v2",
split: Literal["train", "test", "val"] = "train",
use_axis_alignment: bool = True,
return_superpoint: bool = False,
block_size: Optional[float] = None,
block_stride: float = 0.75,
num_nodes: int = 8192,
min_num_nodes: int = 100,
transform: Optional[Callable] = None,
download: bool = False,
force_download: bool = False,
force_process: bool = False,
show_progress: bool = True,
num_workers: Optional[int] = None,
accept_terms: bool = False,
)
Bases: ScanNet
ScanNet restricted to the 200-class benchmark, as described in the paper Language-Grounded Indoor 3D Semantic Segmentation in the Wild.
A thin wrapper over ScanNet that reads the fine-grained raw_category / id label columns and exposes the 200-class benchmark label set plus the <unk> ignore class at index \(0\). The relabel transform, applied while loading, maps the raw category ids onto contiguous benchmark indices; categories outside the 200 classes map to <unk>. The processed cache lives in processed_200/ so it never collides with the base ScanNet or ScanNet20 caches.
Parameters:
-
root(PathLike) βThe root directory of the dataset.
-
version(Literal['v1', 'v2'], default:'v2') βThe version of the dataset to use.
-
split(Literal['train', 'test', 'val'], default:'train') βThe split to load, one of
train,val, ortest. -
use_axis_alignment(bool, default:True) βIf True, apply ScanNet's axis-alignment transform to the mesh.
-
return_superpoint(bool, default:False) βAlso emit the per-point
superpointids, read from the rawscans/<scene>/<scene>_vh_clean_2.0.010000.segs.jsonmesh segmentation (requires the raw scans). -
block_size(Optional[float], default:None) βIf set, split each scene into ground-plane blocks of this size (meters) for training.
-
block_stride(float, default:0.75) βStride between adjacent blocks when
block_sizeis set. -
num_nodes(int, default:8192) βNumber of points sampled per block (when
block_sizeis set) or per scene. -
min_num_nodes(int, default:100) βSkip blocks with fewer than this many points.
-
transform(Optional[Callable], default:None) βA callable that transforms the data when retrieved from the dataset.
-
download(bool, default:False) βWhether to download the raw data.
-
force_download(bool, default:False) βWhether to force the download of the raw data.
-
force_process(bool, default:False) βWhether to force the processing of the raw data.
-
show_progress(bool, default:True) βWhether to show a progress bar during processing.
-
num_workers(Optional[int], default:None) βWorker processes for preprocessing, or
Nonefor sequential processing. -
accept_terms(bool, default:False) βConfirm that you have signed the ScanNet terms of use (
terms_url). When leftFalse,downloadasks for the confirmation on the terminal, once in every process that triggers the download.
Example
Assuming you have downloaded the raw dataset from https://kaldir.vc.in.tum.de/scannet/ and extracted it under data/ScanNet/raw, you can load the benchmark labels as follows:
Methods:
-
read_sceneβRead one processed scene directory into a sample dict, relabeled if
relabelis set.
Attributes:
-
name(str) βName of the dataset directory (shared with
ScanNet). -
processed_dir(str) βPath to the processed cache directory, suffixed
_200for the 200-class benchmark. -
classes(List[str]) βClass names in label order.
-
relabel(Relabel) βTransform remapping the raw segment ids to the 200 benchmark ids.
-
data_dir(str) βPath to the dataset directory
<root>/<name>. -
raw_dir(str) βPath to the raw download directory.
-
labels(DataFrame) βThe raw label table, read from the version's combined labels TSV.
-
class_to_idx(Dict[str, int]) βMapping from class name to label index.
-
processed_files(List[Path]) βSorted list of the split's processed scene directories.
processed_dir property ΒΆ
Path to the processed cache directory, suffixed _200 for the 200-class benchmark.
relabel cached property ΒΆ
relabel: Relabel
Transform remapping the raw segment ids to the 200 benchmark ids.
labels cached property ΒΆ
The raw label table, read from the version's combined labels TSV.
class_to_idx cached property ΒΆ
Mapping from class name to label index.
processed_files property ΒΆ
Sorted list of the split's processed scene directories.
read_scene [source] ΒΆ
Read one processed scene directory into a sample dict, relabeled if relabel is set.
Parameters:
-
path(Path) βProcessed scene directory holding
pos.npy,color.npy,normal.npyand, when annotated,segment.npy/instance.npy.
Returns:
-
Dict[str, Any]βThe scene as a
DataKeys-keyed dict of tensors plus itsDataKeys.SCENEid.
load_scannet_scene_mesh [source] ΒΆ
Load a ScanNet PLY file and return the vertices and face.
Parameters:
-
file_path(PathLike) βThe path to the PLY file.
Returns:
-
Tuple[Tensor, Tensor]βThe vertices and face.
Examples:
load_scannet_scene_metadata [source] ΒΆ
Load a ScanNet metadata file and return the metadata.
Parameters:
-
meta_path(PathLike) βThe path to the metadata file, usually saved as
data/ScanNet/raw/v2/scans/{scan_id}/{scan_id}.txt.
Returns:
-
Dict[str, Any]βThe metadata.
Examples:
>>> meta = load_scannet_scene_metadata(
... "data/ScanNet/raw/v2/scans/scene0000_00/scene0000_00.txt"
... ) # doctest: +SKIP
>>> meta.keys() # doctest: +SKIP
dict_keys(['axisAlignment', 'colorToDepthExtrinsics', 'colorHeight', 'colorWidth', 'depthHeight', 'depthWidth',
'fx_color', 'fy_color', 'mx_color', 'my_color', 'numColorFrames', 'numDepthFrames', 'numIMUmeasurements',
'sceneType'])
load_scannet_scene_aggregation_and_segs [source] ΒΆ
load_scannet_scene_aggregation_and_segs(
aggregation_path: PathLike,
segs_path: PathLike,
label_to_idx: Optional[Dict[str, int]] = None,
) -> Tuple[Tensor, Optional[Tensor]]
Read per-vertex instance ids and semantic labels from aggregation + segments.
Parameters:
-
aggregation_path(PathLike) βPath to the aggregation JSON file.
-
segs_path(PathLike) βPath to the segments JSON file.
-
label_to_idx(Optional[Dict[str, int]], default:None) βOptional mapping from
raw_categorystring to NYU40 id (or any integer label). Built from the TSV with e.g.{row["raw_category"]: int(row["nyu40id"]) for _, row in df.iterrows()}. If provided, per-vertex semantic labels are returned. Unrecognized categories map to 0 (unlabeled).
Returns:
-
TensorβThe per-vertex instance ids (the 0-based aggregation
objectId, or-1for vertices in no -
Optional[Tensor]βsegment group) and labels.
Examples:
load_scannet_labels [source] ΒΆ
Load the ScanNet labels CSV file as a pandas.DataFrame object.
Parameters:
-
file_path(PathLike) βPath to the labels CSV file, usually located in the
rawdirectory asdata/ScanNet/raw/metadata/scannetv2-labels.combined.tsv
Returns:
-
DataFrameβThe labels as a
pandas.DataFrameobject.
Examples:
select_scannet_classes [source] ΒΆ
select_scannet_classes(
labels: DataFrame,
name: str,
sort_by: Optional[str] = None,
values: Union[Sequence[str], Literal["all"]] = "all",
) -> List[Any]
Select the classes to load from the labels.
Parameters:
-
labels(DataFrame) βThe labels as a
pandas.DataFrameobject. -
name(str) βThe name of the column in the labels to select the classes from.
-
sort_by(Optional[str], default:None) βThe column to sort the labels by.
-
values(Union[Sequence[str], Literal['all']], default:'all') βThe values to select from the labels.
Returns:
-
List[Any]βThe selected classes.
Examples:
>>> labels = load_scannet_labels("data/ScanNet/raw/metadata/scannetv2-labels.combined.tsv") # doctest: +SKIP
>>> classes = select_scannet_classes(labels, "raw_category", sort_by="id", values=["wall", "floor"]) # doctest: +SKIP
>>> nyu40classes = select_scannet_classes(labels, "nyu40class", sort_by="nyu40id", values="all") # doctest: +SKIP
load_scannet_scene [source] ΒΆ
load_scannet_scene(
mesh_path: PathLike,
meta_path: Optional[PathLike] = None,
aggregation_path: Optional[PathLike] = None,
segments_path: Optional[PathLike] = None,
label_to_idx: Optional[Dict[str, int]] = None,
scene_id: Optional[str] = None,
use_axis_alignment: bool = True,
) -> ScanNetData
Load a ScanNet scene and return the parsed points, color, normal, instance, and labels in a dictionary format.
Parameters:
-
mesh_path(PathLike) βPath to the raw mesh file, usually saved as
data/ScanNet/raw/v2/scans/{scan_id}/{scan_id}.ply. -
meta_path(Optional[PathLike], default:None) βPath to the metadata file, usually saved as
data/ScanNet/raw/v2/scans/{scan_id}/{scan_id}.txt. -
aggregation_path(Optional[PathLike], default:None) βPath to the aggregation file, usually saved as
data/ScanNet/raw/v2/scans/{scan_id}/{scan_id}.aggregation.json. -
segments_path(Optional[PathLike], default:None) βPath to the segments file, usually saved as
data/ScanNet/raw/v2/scans/{scan_id}/{scan_id}.segs.json. -
label_to_idx(Optional[Dict[str, int]], default:None) βA dictionary mapping object labels to contiguous positive indices. The labels correspond to the
raw_categorycolumn in the labels CSV file, or to thelabelkey in the aggregation JSON file. This mapping is used to map object labels to their associated target indices. -
use_axis_alignment(bool, default:True) βWhether to apply the axis alignment transformation from the scene metadata. Set to
Falseto keep the raw PLY coordinates.
Returns:
-
ScanNetDataβThe loaded scene.
Examples:
>>> labels_path = "data/ScanNet/raw/metadata/scannetv2-labels.combined.tsv"
>>> labels = load_scannet_labels(labels_path) # doctest: +SKIP
>>> label_to_idx = {label: idx for idx, label in enumerate(labels["raw_category"].unique())} # doctest: +SKIP
>>> scene_dir = "data/ScanNet/raw/v2/scans/scene0000_00"
>>> scene = load_scannet_scene( # doctest: +SKIP
... mesh_path=f"{scene_dir}/scene0000_00_vh_clean_2.ply",
... meta_path=f"{scene_dir}/scene0000_00.txt",
... aggregation_path=f"{scene_dir}/scene0000_00.aggregation.json",
... segments_path=f"{scene_dir}/scene0000_00.segs.json",
... label_to_idx=label_to_idx,
... )
>>> scene # doctest: +SKIP
{'points': tensor([[...]]), 'color': tensor([[...]]), 'normal': tensor([[...]]),
'instance': tensor([...]), 'labels': tensor([...])}}
tile_scannet_scene [source] ΒΆ
tile_scannet_scene(
scene: Dict[str, Any],
block_size: float = 1.5,
block_stride: float = 0.75,
num_nodes: int = 8192,
min_num_nodes: int = 100,
scene_index: Optional[int] = None,
) -> List[Dict[str, Any]]
Split a single ScanNet scene dict into fixed-size spatial blocks.
Sweeps a \(\text{block\_size} \times \text{block\_size}\) window (full Z extent) over the scene with the given stride, matching the tiling procedure used in the DGCNN ScanNet evaluation protocol.
Parameters:
-
scene(Dict[str, Any]) βDict with at least
DataKeys.POS(float32, \((N, 3)\)). All other tensors with a leading dimension of \(N\) are sliced in parallel. -
block_size(float, default:1.5) βSide length of each square block in meters.
-
block_stride(float, default:0.75) βStep size for the sliding window in meters.
-
num_nodes(int, default:8192) βFixed number of nodes per block.
-
min_num_nodes(int, default:100) βMinimum number of raw nodes for a block to be kept.
-
scene_index(Optional[int], default:None) βIf provided, each block will include
scene_indexandnum_scene_pointsentries.
Returns:
-
List[Dict[str, Any]]βList of dicts, one per retained block. Each block has exactly
num_nodesnodes and extra -
List[Dict[str, Any]]βscene_max(scene-level coordinate maxima, useful for downstream normalization), -
List[Dict[str, Any]]βblock_center, andpoint_indicesentries.