Overview
PyTorch library for 3D point cloud deep learning: models, datasets, transforms, and pretrained weights.
Modules:
-
configβCache and data directories of the package.
-
datasetsβBenchmark point cloud datasets with disk caching and download helpers.
-
inferersβInference strategies for scenes larger than one forward pass: tiling, windows, and refinement.
-
layersβReusable neural network blocks shared across the model architectures.
-
lightningβOptional PyTorch Lightning integration: modules, datamodule, callbacks, and metrics.
-
lossesβTraining criteria.
-
metricsβEvaluation metrics for classification, segmentation, detection and instance segmentation.
-
modelsβModel architectures, the
create_modelfactory, and the pretrained weight registry. -
opsβTensor operations on packed point clouds: neighbor search, voxelization, geometry, boxes, and serialization.
-
optimβOptimization helpers that
torch.optimdoes not ship. -
transformsβDict-based transforms and their tensor-level functional equivalents.
-
utilsβData keys and collation, conversions, the Hub token, optional imports, I/O, random state, checkpoints, and types.
Functions:
-
create_modelβBuild a registered model, optionally loading pretrained or local checkpoint weights.
-
deprecated_modelβKeep a renamed model reachable under its former
name, placed above itsregister_modeldecorator. -
list_modelsβList registered model names, sorted alphabetically.
-
register_modelβRegister a model entry point under
namefortask.
create_model [source] ΒΆ
create_model(
name: str,
task: Literal["pretraining"],
*,
pretrained: bool = False,
checkpoint_path: Optional[PathLike] = None,
return_info: Literal[True],
**kwargs: Any,
) -> Tuple[Module, ModelInfoDict]
create_model(
name: str,
task: Literal["pretraining"],
*,
pretrained: bool = False,
checkpoint_path: Optional[PathLike] = None,
return_info: Literal[False] = False,
**kwargs: Any,
) -> Module
create_model(
name: str,
task: Literal["classification"],
*,
pretrained: bool = False,
checkpoint_path: Optional[PathLike] = None,
return_info: Literal[True],
**kwargs: Any,
) -> Tuple[ClassificationModel, ModelInfoDict]
create_model(
name: str,
task: Literal["classification"],
*,
pretrained: bool = False,
checkpoint_path: Optional[PathLike] = None,
return_info: Literal[False] = False,
**kwargs: Any,
) -> ClassificationModel
create_model(
name: str,
task: Literal["semantic-segmentation"],
*,
pretrained: bool = False,
checkpoint_path: Optional[PathLike] = None,
return_info: Literal[True],
**kwargs: Any,
) -> Tuple[SemanticSegmentationModel, ModelInfoDict]
create_model(
name: str,
task: Literal["semantic-segmentation"],
*,
pretrained: bool = False,
checkpoint_path: Optional[PathLike] = None,
return_info: Literal[False] = False,
**kwargs: Any,
) -> SemanticSegmentationModel
create_model(
name: str,
task: Literal["part-segmentation"],
*,
pretrained: bool = False,
checkpoint_path: Optional[PathLike] = None,
return_info: Literal[True],
**kwargs: Any,
) -> Tuple[PartSegmentationModel, ModelInfoDict]
create_model(
name: str,
task: Literal["part-segmentation"],
*,
pretrained: bool = False,
checkpoint_path: Optional[PathLike] = None,
return_info: Literal[False] = False,
**kwargs: Any,
) -> PartSegmentationModel
create_model(
name: str,
task: Literal["detection"],
*,
pretrained: bool = False,
checkpoint_path: Optional[PathLike] = None,
return_info: Literal[True],
**kwargs: Any,
) -> Tuple[DetectionModel, ModelInfoDict]
create_model(
name: str,
task: Literal["detection"],
*,
pretrained: bool = False,
checkpoint_path: Optional[PathLike] = None,
return_info: Literal[False] = False,
**kwargs: Any,
) -> DetectionModel
create_model(
name: str,
task: None = None,
*,
pretrained: bool = False,
checkpoint_path: Optional[PathLike] = None,
return_info: Literal[True],
**kwargs: Any,
) -> Tuple[Module, ModelInfoDict]
create_model(
name: str,
task: Optional[Task] = None,
*,
pretrained: bool = False,
checkpoint_path: Optional[PathLike] = None,
return_info: bool = False,
**kwargs: Any,
) -> Any
Build a registered model, optionally loading pretrained or local checkpoint weights.
Registered weights load into the registered configuration, then an overridden num_classes rebuilds the head at its fresh initialization (0 drops it). Other overrides (e.g. in_channels) keep the matching weights, and the keys whose shape changed keep their initialization. Model keys missing from the checkpoint raise.
Parameters:
-
name(str) βRegistered model name (see
list_models). -
task(Optional[Task], default:None) βRegistry the model belongs to (
pretraining,classification,semantic-segmentation,part-segmentationordetection). Optional whennameis registered under a single task. -
pretrained(bool, default:False) βLoad the registered pretrained weights, warning when their license is non-commercial. Mutually exclusive with
checkpoint_path. -
checkpoint_path(Optional[PathLike], default:None) βLocal checkpoint to load instead of the registered weights. Supports
torch.savefiles,.safetensors, and Lightning checkpoints (the wrapped network is extracted). -
return_info(bool, default:False) βAlso return the registry entry (
ModelInfoDict), with the resolvedtaskand the effectivehparams. -
**kwargs(Any, default:{}) βOverrides merged into the registered
hparamsand passed to the model constructor.
Returns:
-
AnyβThe model, or a
(model, info)tuple whenreturn_infois true.
Raises:
-
ValueErrorβIf
taskornameis unknown, iftaskis omitted for a name registered under several tasks, if bothpretrainedandcheckpoint_pathare passed, or ifpretrainedis requested for an entry that registers no weights. -
TypeErrorβIf the entry registers architecture hparams only and the data-dependent arguments (typically
in_channelsandnum_classes) are not passed. -
ImportErrorβIf the model needs an optional dependency that is not installed or does not meet its version requirement; the original error is chained.
-
FileNotFoundErrorβIf the checkpoint file does not exist, or if the registered weights are absent from the models cache and cannot be downloaded.
Building a registered model, overriding its registered hparams, and inspecting its registry entry:
deprecated_model [source] ΒΆ
deprecated_model(
name: str,
*,
deprecated_in: str,
removed_in: Optional[str] = None,
message: Optional[str] = None,
) -> Callable[[F], F]
Keep a renamed model reachable under its former name, placed above its register_model decorator.
create_model and model_info resolve name to the registered name under its task with a FutureWarning that names both releases. list_models never lists former names, and a model of the same name registered under another task is not affected. Stack one decorator per former name, and delete it in the removed_in release.
Parameters:
-
name(str) βFormer registry name of the entry, under the task it is registered for.
-
deprecated_in(str) βRelease that renamed the model (e.g.
0.0.17). -
removed_in(Optional[str], default:None) βRelease that drops the former name, named in the warning;
Noneleaves it unscheduled. -
message(Optional[str], default:None) βSentence appended to the warning, e.g. what else changed with the rename.
Returns:
-
Callable[[F], F]βThe decorator adding the former name to the registry entry of its target callable.
Raises:
-
ValueErrorβIf
deprecated_inorremoved_inis not a version string, ifremoved_inis not a later release thandeprecated_in, if the decorated callable is not registered under exactly one name (the decorator belongs aboveregister_model), or ifnameis the registered name itself, a registered model of its task or already a former name under its task.
Renaming a registered model while keeping its former name loadable for one release:
from torch_pointcloud.models import PointNetClassification, deprecated_model, register_model
@deprecated_model("pointnet.scanobjectnn", deprecated_in="0.0.17", removed_in="0.0.18")
@register_model("pointnet-base.scanobjectnn", task="classification", hparams=dict(in_channels=0, num_classes=15))
def pointnet_base(**hparams):
return PointNetClassification(**hparams)
list_models [source] ΒΆ
list_models(
name: str = "*",
*,
task: Optional[Task] = None,
pretrained: bool = False,
) -> List[str]
List registered model names, sorted alphabetically.
Parameters:
-
name(str, default:'*') βWildcard filter on the registered name (
fnmatchsyntax, e.g."pointnext*"). -
task(Optional[Task], default:None) βRestrict the listing to one registry;
Nonelists across all tasks (duplicates removed). -
pretrained(bool, default:False) βOnly list models that ship pretrained weights.
Returns:
-
List[str]βThe matching model names.
Filtering by name pattern, task, and weight availability:
register_model [source] ΒΆ
register_model(
name: str,
*,
hparams: Optional[Dict[str, Any]] = None,
transform: Optional[Transform] = None,
input_keys: Sequence[str] = ("x", "pos", "batch"),
weights: Union[str, WeightsDict, None] = None,
task: Literal["pretraining"],
) -> Callable[
[Callable[..., Module]], Callable[..., Module]
]
register_model(
name: str,
*,
hparams: Optional[Dict[str, Any]] = None,
transform: Optional[Transform] = None,
input_keys: Sequence[str] = ("x", "pos", "batch"),
weights: Union[str, WeightsDict, None] = None,
task: Literal["classification"],
) -> Callable[
[Callable[..., ClassificationModel]],
Callable[..., ClassificationModel],
]
register_model(
name: str,
*,
hparams: Optional[Dict[str, Any]] = None,
transform: Optional[Transform] = None,
input_keys: Sequence[str] = ("x", "pos", "batch"),
weights: Union[str, WeightsDict, None] = None,
task: Literal["semantic-segmentation"],
) -> Callable[
[Callable[..., SemanticSegmentationModel]],
Callable[..., SemanticSegmentationModel],
]
register_model(
name: str,
*,
hparams: Optional[Dict[str, Any]] = None,
transform: Optional[Transform] = None,
input_keys: Sequence[str] = ("x", "pos", "batch"),
weights: Union[str, WeightsDict, None] = None,
task: Literal["part-segmentation"],
) -> Callable[
[Callable[..., PartSegmentationModel]],
Callable[..., PartSegmentationModel],
]
register_model(
name: str,
*,
hparams: Optional[Dict[str, Any]] = None,
transform: Optional[Transform] = None,
input_keys: Sequence[str] = ("x", "pos", "batch"),
weights: Union[str, WeightsDict, None] = None,
task: Literal["detection"],
) -> Callable[
[Callable[..., DetectionModel]],
Callable[..., DetectionModel],
]
register_model(
name: str,
*,
task: Task,
hparams: Optional[Dict[str, Any]] = None,
transform: Optional[Transform] = None,
input_keys: Sequence[str] = ("x", "pos", "batch"),
weights: Union[str, WeightsDict, None] = None,
) -> Callable
Register a model entry point under name for task.
The decorated callable becomes reachable through create_model. A bare weights URL string is normalized to a WeightsDict, so registry consumers always see the structured form. A deprecated_model decorator placed above adds the former names of the entry.
Parameters:
-
name(str) βRegistry name,
<architecture>[.<dataset tag>](e.g.pointnext-sm.scanobjectnn-hardest.openpoints). -
task(Task) βRegistry the model belongs to (
pretraining,classification,semantic-segmentation,part-segmentationordetection). -
hparams(Optional[Dict[str, Any]], default:None) βDefault keyword arguments the entry point is called with;
create_modelkwargs override them. -
transform(Optional[Transform], default:None) βEvaluation transform reproducing the preprocessing the weights were trained with.
-
input_keys(Sequence[str], default:('x', 'pos', 'batch')) βBatch keys
forwardtakes positionally, in order; a dotted key reads an attribute (e.g.octree.depth).utils.data.select_inputsgathers them from a collated batch. -
weights(Union[str, WeightsDict, None], default:None) βPretrained checkpoint, either a URL string or a
WeightsDictwith metadata.
Returns:
-
CallableβThe decorator registering its target callable.
Raises:
-
ValueErrorβIf
taskis unknown, or ifnameis the former name of another model oftask.
Registering a classification entry point with weight metadata:
from torch_pointcloud.models import PointNetClassification, WeightsDict, register_model
@register_model(
"pointnet-demo.scanobjectnn",
task="classification",
hparams=dict(in_channels=0, num_classes=15),
weights=WeightsDict(
url="hf://my-org/pointnet-demo.scanobjectnn/resolve/main/model.safetensors",
dataset="scanobjectnn",
metrics={"OA": 88.20},
),
)
def pointnet_demo(**hparams):
return PointNetClassification(**hparams)