Skip to content

ModelNet

ModelNet10/40 shape classification datasets, including normal-resampled and HDF5 variants.

First page of 3D ShapeNets: A Deep Representation for Volumetric Shapes

1406.5670 · June 2014

Classes:

  • ModelNet10 –

    The ModelNet10 dataset as described in the paper

  • ModelNet40 –

    The ModelNet40 dataset as described in the paper

  • ModelNetNormalResampled –

    The ModelNet shapes resampled to 10,000 surface points with normals, as described in the paper

  • ModelNet40Hdf5 –

    The pre-sampled HDF5 version of ModelNet40 (modelnet40_ply_hdf5_2048), introduced with

Functions:

ModelNet10

ModelNet10(
    root: PathLike,
    train: bool = True,
    classes: Union[str, Sequence[str]] = "all",
    transform: Optional[
        Callable[[Dict[str, Any]], Dict[str, Any]]
    ] = None,
    download: bool = False,
    force_download: bool = False,
    force_process: bool = False,
    show_progress: bool = True,
    num_workers: Optional[int] = None,
)

Bases: _ModelNet

The ModelNet10 dataset as described in the paper 3D ShapeNets: A Deep Representation for Volumetric Shapes.

You can download the official dataset from the Princeton dedicated website.

The ModelNet10 dataset consists of 10 classes, containing 3,991 training and 908 test examples.

Parameters:

  • root (PathLike) –

    Root directory where the dataset should be stored.

  • train (bool, default: True ) –

    If True, loads the training set, otherwise the test set.

  • classes (Union[str, Sequence[str]], default: 'all' ) –

    The class names to include in the dataset. If "all", all classes are included.

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

    A function/transform that takes in a dictionary containing the data and returns a transformed version.

  • download (bool, default: False ) –

    If True, downloads the dataset from the internet and puts it in root.

  • force_download (bool, default: False ) –

    If True, forces to download the dataset from the internet, even if it is already downloaded.

  • force_process (bool, default: False ) –

    If True, forces to process the dataset, even if it is already processed.

  • show_progress (bool, default: True ) –

    If True, displays a progress bar of the download and processing.

  • num_workers (Optional[int], default: None ) –

    The number of workers to use for parallel processing.

Example
from torch_pointcloud.datasets import ModelNet10

train_dataset = ModelNet10(root="data", train=True, download=True)
test_dataset = ModelNet10(root="data", train=False, download=True)

Attributes:

  • 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 (str) –

    Path to the processed cache directory.

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.

processed_dir property

processed_dir: str

Path to the processed cache directory.

ModelNet40

ModelNet40(
    root: PathLike,
    train: bool = True,
    classes: Union[str, Sequence[str]] = "all",
    transform: Optional[
        Callable[[Dict[str, Any]], Dict[str, Any]]
    ] = None,
    download: bool = False,
    force_download: bool = False,
    force_process: bool = False,
    show_progress: bool = True,
    num_workers: Optional[int] = None,
)

Bases: _ModelNet

The ModelNet40 dataset as described in the paper 3D ShapeNets: A Deep Representation for Volumetric Shapes.

You can download the official dataset from the Princeton dedicated website.

The ModelNet40 dataset consists of 40 classes, containing 9,843 training and 2,468 test examples.

Parameters:

  • root (PathLike) –

    Root directory where the dataset should be stored.

  • train (bool, default: True ) –

    If True, loads the training set, otherwise the test set.

  • classes (Union[str, Sequence[str]], default: 'all' ) –

    The class names to include in the dataset. If "all", all classes are included.

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

    A function/transform that takes in a dictionary containing the data and returns a transformed version.

  • download (bool, default: False ) –

    If True, downloads the dataset from the internet and puts it in root.

  • force_download (bool, default: False ) –

    If True, forces to download the dataset from the internet, even if it is already downloaded.

  • force_process (bool, default: False ) –

    If True, forces to process the dataset, even if it is already processed.

  • show_progress (bool, default: True ) –

    If True, displays a progress bar of the download and processing.

  • num_workers (Optional[int], default: None ) –

    The number of workers to use for parallel processing.

Example
from torch_pointcloud.datasets import ModelNet40

train_dataset = ModelNet40(root="data", train=True, download=True)
test_dataset = ModelNet40(root="data", train=False, download=True)

Attributes:

  • 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 (str) –

    Path to the processed cache directory.

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.

processed_dir property

processed_dir: str

Path to the processed cache directory.

ModelNetNormalResampled

ModelNetNormalResampled(
    root: PathLike,
    variant: Literal["10", "40"],
    train: bool = True,
    classes: Union[str, Sequence[str]] = "all",
    transform: Optional[
        Callable[[Dict[str, Any]], Dict[str, Any]]
    ] = None,
    download: bool = False,
    force_download: bool = False,
    force_process: bool = False,
    show_progress: bool = True,
    num_workers: Optional[int] = None,
)

Bases: PointCloudDataset

The ModelNet shapes resampled to 10,000 surface points with normals, as described in the paper PointNet++: Deep Hierarchical Feature Learning on Point Sets in a Metric Space.

Each shape from ModelNet10 / ModelNet40 (see ModelNet10 and ModelNet40 for the mesh datasets) is stored as a .txt file of 10,000 rows with six comma-separated columns: the \(xyz\) coordinates (normalized to the unit sphere) followed by the surface normal. This is the standard input for the point-based classification benchmarks (PointNet++, PointMLP, Point-MAE, ...), which typically sample the first \(1024\) points. The variant selects the 10-class or 40-class label set from the same resampled release.

Parameters:

  • root (PathLike) –

    Root directory where the dataset should be stored.

  • variant (Literal['10', '40']) –

    The label set to load, "10" (ModelNet10 classes) or "40" (ModelNet40 classes).

  • train (bool, default: True ) –

    If True, loads the training set, otherwise the test set.

  • classes (Union[str, Sequence[str]], default: 'all' ) –

    The class names to include in the dataset. If "all", all classes are included.

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

    A function/transform that takes in a dictionary containing the data and returns a transformed version.

  • download (bool, default: False ) –

    If True, downloads the dataset from the internet and puts it in root.

  • force_download (bool, default: False ) –

    If True, forces to download the dataset from the internet, even if it is already downloaded.

  • force_process (bool, default: False ) –

    If True, forces to process the dataset, even if it is already processed.

  • show_progress (bool, default: True ) –

    If True, displays a progress bar of the download and processing.

  • num_workers (Optional[int], default: None ) –

    The number of workers to use for parallel processing.

Shape
  • pos: \((10000, 3)\) unit-sphere coordinates.
  • normal: \((10000, 3)\) surface normals.
  • label: scalar class index.
Example
from torch_pointcloud.datasets import ModelNetNormalResampled

train_dataset = ModelNetNormalResampled(root="data", variant="40", train=True, download=True)
test_dataset = ModelNetNormalResampled(root="data", variant="40", train=False, download=True)

Attributes:

  • original_classes (Tuple[str, ...]) –

    Class names of the variant, in the original release order.

  • class_to_idx (dict[str, int]) –

    Mapping from class name to label index.

  • 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 (str) –

    Path to the processed cache directory.

original_classes property

original_classes: Tuple[str, ...]

Class names of the variant, in the original release order.

class_to_idx property

class_to_idx: dict[str, int]

Mapping from class name to label index.

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.

processed_dir property

processed_dir: str

Path to the processed cache directory.

ModelNet40Hdf5

ModelNet40Hdf5(
    root: PathLike,
    train: bool = True,
    transform: Optional[
        Callable[[Dict[str, Any]], Dict[str, Any]]
    ] = None,
    download: bool = False,
    force_download: bool = False,
    force_process: bool = False,
    show_progress: bool = True,
)

Bases: PointCloudDataset

The pre-sampled HDF5 version of ModelNet40 (modelnet40_ply_hdf5_2048), introduced with PointNet: Deep Learning on Point Sets for 3D Classification and Segmentation.

Each ModelNet40 mesh is sampled to 2,048 surface points with normals, normalized to the unit sphere, and the pre-shuffled clouds are sharded into HDF5 files listed by train_files.txt / test_files.txt (9,840 train and 2,468 test clouds). This is the standard evaluation input for point-based classification benchmarks (DGCNN, PointMLP, PointNeXt, ...), which take the first \(N\) points of each cloud rather than resampling.

Each sample is a dict with the following keys:

Key Shape Dtype Description
pos \((2048, 3)\) float32 Unit-sphere XYZ coordinates
normal \((2048, 3)\) float32 Surface normals
label scalar int64 Class index (40 classes)

The HDF5 shards are used directly (no separate processed cache): force_process is accepted for contract parity and is a no-op.

Parameters:

  • root (PathLike) –

    Root directory where the dataset should be stored.

  • train (bool, default: True ) –

    If True, loads the training set, otherwise the test set.

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

    A function/transform that takes in a dictionary containing the data and returns a transformed version.

  • download (bool, default: False ) –

    If True, downloads the dataset from the internet and puts it in root.

  • force_download (bool, default: False ) –

    If True, forces to download the dataset from the internet, even if it is already downloaded.

  • force_process (bool, default: False ) –

    Accepted for contract parity; the HDF5 shards are used directly, so this is a no-op.

  • show_progress (bool, default: True ) –

    If True, displays a progress bar of the download and loading.

Example
from torch_pointcloud.datasets import ModelNet40Hdf5

train_dataset = ModelNet40Hdf5(root="data", train=True, download=True)
test_dataset = ModelNet40Hdf5(root="data", train=False, download=True)

Attributes:

  • split_file (str) –

    Path to the raw file list of the split.

  • 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 (str) –

    Path to the processed cache directory.

split_file property

split_file: str

Path to the raw file list of the split.

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.

processed_dir property

processed_dir: str

Path to the processed cache directory.

load_modelnet_data

load_modelnet_data(
    file_path: PathLike, target: int
) -> Dict[str, Tensor]

Load one ModelNet mesh from a raw OFF file.

Parameters:

  • file_path (PathLike) –

    Path to a raw <class>/<split>/<model_id>.off mesh.

  • target (int) –

    Label index of the shape.

Returns:

  • Dict[str, Tensor] –

    The mesh's pos \((N, 3)\) vertices, face \((F, 3)\) triangles and scalar label.

load_modelnet_normal_resampled_data

load_modelnet_normal_resampled_data(
    file_path: PathLike, target: int
) -> Dict[str, Tensor]

Load one ModelNet shape from a raw normal-resampled .txt file.

Parameters:

  • file_path (PathLike) –

    Path to a raw <class>/<model_id>.txt shape.

  • target (int) –

    Label index of the shape.

Returns:

  • Dict[str, Tensor] –

    The shape's pos \((N, 3)\), normal \((N, 3)\) and scalar label.