Overview
Optional PyTorch Lightning integration: modules, datamodule, callbacks, and metrics.
Modules:
-
callbacksβLightning callbacks for batch norm momentum scheduling and metric logging.
-
datamoduleβLightning datamodule wrapping point cloud datasets with the packed-batch collate.
-
metricsβEvaluation metrics for 3D detection, instance segmentation, and part segmentation.
-
moduleβLightning modules for classification, segmentation, and detection training.
Classes:
-
BNMomentumSchedulerβExponentially decay BatchNorm momentum over training epochs.
-
MetricCallbackβAccumulate and log a torchmetrics metric over a validation/test epoch.
-
PointCloudDataModuleβLightningDataModule wrapping point cloud datasets with the packed-batch collate.
-
BoxAveragePrecisionβPacked 3D-detection per-class average precision as a
torchmetricsmetric. -
BoxMeanAveragePrecisionβPacked 3D-detection mean average precision as a
torchmetricsmetric. -
InstanceAveragePrecisionβPoint-mask instance-segmentation AP as a
torchmetricsmetric. -
InstancePartMeanIntersectionOverUnionβShapeNetPart instance / class mean IoU as a
torchmetricsmetric. -
NuScenesDetectionβThe official nuScenes detection metrics as a
torchmetricsmetric. -
LitClassificationModelβLightningModule for a point cloud classification model, built from the registry.
-
LitDetectionModelβLightningModule for a 3D object detection model, built from the registry.
-
LitModelβShared base for the task-specific Lightning wrappers.
-
LitPartSegmentationModelβLightningModule for a part segmentation model, built from the registry.
-
LitSemanticSegmentationModelβLightningModule for a point cloud semantic segmentation model, built from the registry.
BNMomentumScheduler [source] ΒΆ
BNMomentumScheduler(
bn_momentum_init: float = 0.5,
bn_decay_rate: float = 0.5,
bn_decay_step: int = 20,
bn_momentum_clip: float = 0.001,
)
Bases: Callback
Exponentially decay BatchNorm momentum over training epochs.
Reference implementation: facebookresearch/votenet (train.py).
At the start of each training epoch, every nn.BatchNorm* module in pl_module.model has its momentum set to
with \(m_0\) the initial momentum, \(\gamma\) the decay rate, \(s\) the decay step (epochs) and \(m_\text{clip}\) the floor (torch_pointcloud.optim.bn_momentum).
Parameters:
-
bn_momentum_init(float, default:0.5) βInitial BatchNorm momentum \(m_0\).
-
bn_decay_rate(float, default:0.5) βPer-step multiplicative decay \(\gamma\).
-
bn_decay_step(int, default:20) βNumber of epochs between decay steps \(s\).
-
bn_momentum_clip(float, default:0.001) βLower bound on the momentum \(m_\text{clip}\).
Methods:
-
on_train_epoch_startβSet the decayed momentum on every BatchNorm module of the model.
MetricCallback [source] ΒΆ
MetricCallback(
metric: Metric,
name: str,
*,
stages: Sequence[str] = ("val", "test"),
preds_key: str = "preds",
target_key: str = "target",
batch_key: Optional[str] = None,
prog_bar: bool = True,
)
Bases: Callback
Accumulate and log a torchmetrics metric over a validation/test epoch.
Model- and task-agnostic: the LightningModule's validation_step / test_step returns a {preds_key: ..., target_key: ...} dict (the repo's Lit* modules do), and this callback updates a torchmetrics Metric with it each batch, logging the epoch value as {stage}/{name}. List one per metric to plug accuracy, mIoU, mAP, ... onto any model.
metric is a ready torchmetrics Metric whose num_classes and ignore_index the caller sets to match the model and the criterion, so the callback holds it as-is and stays model-agnostic.
A step output may carry extra entries beyond preds_key / target_key (the Lit* modules' metric_input_keys passthrough); entries matching a parameter name of the metric's update signature (inspected once at construction) are forwarded as keyword arguments and the rest are ignored, so each metric declares the inputs it consumes.
A metric whose compute returns a dict (e.g. BoxMeanAveragePrecision returning mAP@0.25 / mAP@0.5) is logged one entry per key as {stage}/{key}; a scalar metric is logged as {stage}/{name}.
Parameters:
-
metric(Metric) βA torchmetrics
Metric, e.g.JaccardIndex(task="multiclass", num_classes=..., ignore_index=...). -
name(str) βMetric name; logged as
{stage}/{name}(ignored for dict-valued metrics, whose keys name themselves). -
stages(Sequence[str], default:('val', 'test')) βStages to score; each listed stage's
*_stepmust returnpreds_key/target_key. -
preds_key(str, default:'preds') βKey in the step output holding predictions (logits, probabilities, labels, or detections).
-
target_key(str, default:'target') βKey in the step output holding the targets.
-
batch_key(Optional[str], default:None) βOptional key in the step output holding the per-point shape index, forwarded as a third positional argument to
metric.update(packed multi-shape metrics likeInstancePartMeanIntersectionOverUnionneed it). LeaveNonefor two-argument metrics. -
prog_bar(bool, default:True) βWhether to show the metric on the progress bar.
Methods:
-
on_validation_epoch_startβReset the metric when
valis scored. -
on_validation_batch_endβUpdate the metric with the step output when
valis scored. -
on_validation_epoch_endβCompute and log the metric when
valis scored. -
on_test_epoch_startβReset the metric when
testis scored. -
on_test_batch_endβUpdate the metric with the step output when
testis scored. -
on_test_epoch_endβCompute and log the metric when
testis scored.
on_validation_batch_end [source] ΒΆ
on_validation_batch_end(
trainer: Trainer,
pl_module: LightningModule,
outputs: Any,
batch: Dict[str, Any],
batch_idx: int,
dataloader_idx: int = 0,
) -> None
Update the metric with the step output when val is scored.
PointCloudDataModule [source] ΒΆ
PointCloudDataModule(
train_dataset: Optional[Dataset] = None,
val_dataset: Optional[Dataset] = None,
test_dataset: Optional[Dataset] = None,
*,
train_ratios: Optional[Sequence[int]] = None,
stack_keys: Optional[Sequence[str]] = None,
cat_keys: Optional[Sequence[str]] = None,
batch_size: int = 1,
eval_batch_size: Optional[int] = None,
num_workers: int = 0,
pin_memory: bool = False,
drop_last: bool = True,
timeout: float = 0.0,
prefetch_factor: Optional[int] = None,
persistent_workers: bool = False,
pin_memory_device: str = "",
)
Bases: LightningDataModule
LightningDataModule wrapping point cloud datasets with the packed-batch collate.
Each dataset is passed through as-is. To lengthen an epoch, wrap the training dataset with torch_pointcloud.datasets.RepeatDataset(dataset, k=...) before passing it in.
Loaders are built with torch_pointcloud.utils.data.PointCloudDataLoader, which collates to the packed-batch torch_pointcloud.utils.data.collate. Collation specs are never read off the dataset (transforms rewrite keys downstream); pass stack_keys / cat_keys to control how per-scene ground truth is batched (e.g. cat_keys=("box",) for a detection dataset). shuffle is forced to True for train and False for val/test. Without a val_dataset, val_dataloader returns an empty list so Trainer.fit runs train-only.
Parameters:
-
train_dataset(Optional[Dataset], default:None) βDataset for the training loop.
-
train_ratios(Optional[Sequence[int]], default:None) βOne positive integer sampling weight per child dataset of a
ConcatDatasettrain set. When set, the train loader draws single-dataset batches interleaved by these ratios viatorch_pointcloud.datasets.SingleDatasetBatchSampler, so every batch stays single-domain (required by per-dataset normalization such as PDNorm). LeaveNonefor a single dataset. -
val_dataset(Optional[Dataset], default:None) βDataset for the validation loop.
-
test_dataset(Optional[Dataset], default:None) βDataset for the test loop.
-
stack_keys(Optional[Sequence[str]], default:None) βKeys collated by stacking to a leading batch dim instead of concatenating.
-
cat_keys(Optional[Sequence[str]], default:None) βPacked keys that additionally emit a
batch_<key>per-element scene index. -
batch_size(int, default:1) βNumber of point clouds per batch.
-
eval_batch_size(Optional[int], default:None) βBatch size of the val/test loaders; defaults to
batch_size. Evaluation often runs full-resolution scenes while training runs crops, so the two memory envelopes differ (a benchmark protocol is typically one scene per batch). -
num_workers(int, default:0) βNumber of worker processes for data loading.
-
pin_memory(bool, default:False) βPin tensors in pinned (page-locked) memory before transfer.
-
drop_last(bool, default:True) βDrop the last incomplete batch. Applied to the train loader only; val/test always set
drop_last=False. -
timeout(float, default:0.0) βTimeout for collecting a batch from the workers.
-
prefetch_factor(Optional[int], default:None) βNumber of batches each worker prefetches ahead.
-
persistent_workers(bool, default:False) βKeep workers alive between epochs.
-
pin_memory_device(str, default:'') βTarget device for
pin_memory(e.g."cuda").
Methods:
-
setupβGraft the model's evaluation transform onto datasets that have none, and collate its inverse key.
-
configure_dataloaderβBuild a
PointCloudDataLoaderover the dataset with the module's collation and worker settings. -
train_dataloaderβBuild the shuffled train loader, drawing single-dataset batches when
train_ratiosis set. -
val_dataloaderβBuild the unshuffled validation loader, or an empty list when no validation set was given.
-
test_dataloaderβBuild the unshuffled test loader, falling back to the validation set when no test set was given.
setup [source] ΒΆ
Graft the model's evaluation transform onto datasets that have none, and collate its inverse key.
A segmentation module (LitSemanticSegmentationModel, LitPartSegmentationModel) with an inverse_key needs that key in cat_keys so multi-scene eval batches carry its batch_<key> scene index; it is added here. collate ignores cat_keys absent from the samples, so pipelines that write no inverse map are unaffected.
The LightningModule (built from the registry) carries its transform; an experiment leaves a dataset's transform as None to use it, or sets one explicitly for custom augmentation. A wrapper dataset (e.g. MixDataset) whose wrapped dataset already carries a transform is left alone: the recipe lives on the wrapped dataset and must not be applied a second time on its output. Wrappers that apply no transform of their own (RepeatDataset, ConcatDataset) are traversed so the transform lands on the wrapped datasets that actually run it.
configure_dataloader [source] ΒΆ
configure_dataloader(
dataset: Optional[Dataset],
*,
shuffle: bool,
drop_last: bool,
batch_size: Optional[int] = None,
sampler: Optional[Union[Sampler, Iterable]] = None,
batch_sampler: Optional[
Union[Sampler, Iterable]
] = None,
) -> DataLoader
Build a PointCloudDataLoader over the dataset with the module's collation and worker settings.
train_dataloader [source] ΒΆ
Build the shuffled train loader, drawing single-dataset batches when train_ratios is set.
BoxAveragePrecision [source] ΒΆ
BoxAveragePrecision(
*,
iou_per_class: Mapping[int, float],
class_names: Optional[Sequence[str]] = None,
interpolation: Interpolation = "all",
**kwargs: Any,
)
Bases: Metric
Packed 3D-detection per-class average precision as a torchmetrics metric.
A stateful wrapper of box_average_precision: each update reduces one batch's packed predictions and ground truth to its compact box_matches record, and compute returns one AP/<class> entry per class plus their mean as mAP, each class matched at its own IoU threshold (the KITTI / nuScenes convention, e.g. Car@0.7 and Pedestrian/Cyclist@0.5). Targets may carry an ignore_mask so predictions overlapping an ignore region are not counted as false positives. An ignore_mask passed to update is used as the predictions' ignore_mask entry, excluding the flagged predictions from scoring entirely (the KITTI min-height rule). The state is a per-process list of records (not gathered across processes), so run detection validation on a single device.
Parameters:
-
iou_per_class(Mapping[int, float]) βMapping of class index to the IoU threshold used to match its boxes. Keys are coerced to
int(YAML / OmegaConf mappings may arrive with string keys). -
class_names(Optional[Sequence[str]], default:None) βOptional class names used in the returned keys (defaults to the class index).
-
interpolation(Interpolation, default:'all') βAP interpolation:
"all"integrates the full precision-recall curve;"r11"/"r40"sample the KITTI 11- / 40-point recall grids. -
kwargs(Any, default:{}) βForwarded to
torchmetrics.Metric.
Methods:
-
updateβReduce one batch's packed predictions and ground truth to its
box_matchesrecord and append it. -
computeβScore the accumulated batches and return one
AP/<class>entry per class plus theirmAP.
update [source] ΒΆ
update(
preds: Detection3D,
target: Boxes3D,
ignore_mask: OptTensor = None,
) -> None
Reduce one batch's packed predictions and ground truth to its box_matches record and append it.
Parameters:
-
preds(Detection3D) βPacked predictions (one
decodeoutput),{"boxes", "scores", "labels", "batch"}. -
target(Boxes3D) βPacked ground truth aligned to
preds,{"boxes", "labels", "batch"}with an optionalignore_mask. -
ignore_mask(OptTensor, default:None) βOptional per-prediction ignore mask, shape \((N,)\) bool, used as the predictions'
ignore_maskentry; flagged predictions are excluded from scoring entirely.
BoxMeanAveragePrecision [source] ΒΆ
BoxMeanAveragePrecision(
*,
iou_thresholds: Sequence[float] = (0.25, 0.5),
interpolation: Interpolation = "all",
**kwargs: Any,
)
Bases: Metric
Packed 3D-detection mean average precision as a torchmetrics metric.
A stateful wrapper of box_average_precision: each update reduces one batch's packed predictions and ground truth to its compact box_matches record, and compute returns {"mAP@t": ...} (averaged over the classes present in the targets) for each IoU threshold. An ignore_mask passed to update is used as the predictions' ignore_mask entry, excluding the flagged predictions from scoring entirely (the KITTI min-height rule). The state is a per-process list of records (not gathered across processes), so run detection validation on a single device.
Parameters:
-
iou_thresholds(Sequence[float], default:(0.25, 0.5)) βIoU thresholds at which
mAP@tis reported. -
interpolation(Interpolation, default:'all') βAP interpolation:
"all"integrates the full precision-recall curve;"r11"/"r40"sample the KITTI 11- / 40-point recall grids. -
kwargs(Any, default:{}) βForwarded to
torchmetrics.Metric.
Methods:
-
updateβReduce one batch's packed predictions and ground truth to its
box_matchesrecord and append it. -
computeβScore the accumulated batches and return one
mAP@tentry per IoU threshold.
update [source] ΒΆ
update(
preds: Detection3D,
target: Boxes3D,
ignore_mask: OptTensor = None,
) -> None
Reduce one batch's packed predictions and ground truth to its box_matches record and append it.
Parameters:
-
preds(Detection3D) βPacked predictions (one
decodeoutput),{"boxes", "scores", "labels", "batch"}. -
target(Boxes3D) βPacked ground truth aligned to
preds,{"boxes", "labels", "batch"}. -
ignore_mask(OptTensor, default:None) βOptional per-prediction ignore mask, shape \((N,)\) bool, used as the predictions'
ignore_maskentry; flagged predictions are excluded from scoring entirely.
InstanceAveragePrecision [source] ΒΆ
InstanceAveragePrecision(
*,
num_classes: int,
class_names: Optional[Sequence[str]] = None,
min_points: int = 100,
**kwargs: Any,
)
Bases: Metric
Point-mask instance-segmentation AP as a torchmetrics metric.
A stateful wrapper of instance_average_precision: each update appends one scene's instance_matches record (the compact per-scene reduction of predicted masks against ground-truth instances), and compute returns {"AP/<class>": ..., "mAP": ..., "mAP@0.5": ..., "mAP@0.25": ...} following the standard indoor instance-segmentation protocol. The state is a per-process list of records (not gathered across processes), so run instance validation on a single device.
Parameters:
-
num_classes(int) βNumber of instance classes.
-
class_names(Optional[Sequence[str]], default:None) βOptional names for the
AP/<class>keys; falls back to the class index. -
min_points(int, default:100) βMinimum point count for a prediction or ground-truth instance to be scored; smaller ground-truth instances count as ignore regions.
-
kwargs(Any, default:{}) βForwarded to
torchmetrics.Metric.
Methods:
-
updateβAppend one scene's
instance_matchesrecord. -
computeβScore the accumulated scene records and return the per-class average precisions and their mean.
update [source] ΒΆ
update(match: InstanceMatches) -> None
Append one scene's instance_matches record.
Parameters:
-
match(InstanceMatches) βThe per-scene record returned by
instance_matches(per-instance counts, labels, scores and same-class pairwise intersections).
InstancePartMeanIntersectionOverUnion [source] ΒΆ
InstancePartMeanIntersectionOverUnion(
*,
part_ids: Optional[Sequence[Sequence[int]]] = None,
restrict_to_category: bool = False,
**kwargs: Any,
)
Bases: Metric
ShapeNetPart instance / class mean IoU as a torchmetrics metric.
A stateful wrapper of part_intersection_over_union: each shape is scored only over the part labels its category owns (a part absent from both the prediction and the target counts as IoU \(1\)), per-category IoU sums and shape counts accumulate across update calls (summed across processes), and compute returns the protocol's two numbers: ins_mIoU (mean over shapes) and cls_mIoU (mean per category, then over the categories seen). The category of each shape is read off its target labels, since every category owns a disjoint part range.
Parameters:
-
part_ids(Optional[Sequence[Sequence[int]]], default:None) βPart labels owned by each category; defaults to the 16-category / 50-part ShapeNetPart table (
ShapeNetPart.seg_ids). -
restrict_to_category(bool, default:False) βIf
True, the argmax of 2-Dpredsis taken over the shape's own category parts only (logits of the other parts are masked out), the protocol of PointNet, Point-MAE and Point-M2AE. The default is the global argmax over all parts (DGCNN, PointNeXt). -
kwargs(Any, default:{}) βForwarded to
torchmetrics.Metric.
Methods:
NuScenesDetection [source] ΒΆ
NuScenesDetection(
*,
class_names: Sequence[str],
class_ranges: Optional[Mapping[str, float]] = None,
dist_thresholds: Sequence[float] = (0.5, 1.0, 2.0, 4.0),
tp_threshold: float = 2.0,
max_boxes_per_sample: int = 500,
min_recall: float = 0.1,
min_precision: float = 0.1,
**kwargs: Any,
)
Bases: Metric
The official nuScenes detection metrics as a torchmetrics metric.
A stateful wrapper of nuscenes_detection_metrics: each update appends one batch's packed predictions and ground truth together with the optional velocity, attribute and point-count extras, and compute returns the functional's flat dict (AP/<class>, mAP, the five TP errors and the NDS). The predictions' velocity entry and the velocity argument are appended to the boxes as \((v_x, v_y)\) columns, the \((M, 9)\) layout the functional scores; prediction attributes are derived from the accumulated prediction velocities in compute with the standard speed heuristic (nuscenes_velocity_attributes). Sample indices are offset per update by the number of samples seen so far (read off the batch tensors), so scenes of different updates never collide. The state is a per-process list of batches (not gathered across processes), so run detection validation on a single device.
Parameters:
-
class_names(Sequence[str]) βClass name per label index;
barrierandtraffic_coneget their official special handling by name. -
class_ranges(Optional[Mapping[str, float]], default:None) βMaximum BEV evaluation range per class name; defaults to the official ranges.
-
dist_thresholds(Sequence[float], default:(0.5, 1.0, 2.0, 4.0)) βMatching thresholds in meters the AP is averaged over.
-
tp_threshold(float, default:2.0) βMatching threshold in meters of the TP-error metrics.
-
max_boxes_per_sample(int, default:500) βPer-sample cap on scored predictions (highest scores kept).
-
min_recall(float, default:0.1) βRecall up to which the AP and TP-error curves are clipped.
-
min_precision(float, default:0.1) βPrecision subtracted before the AP mean.
-
kwargs(Any, default:{}) βForwarded to
torchmetrics.Metric.
Methods:
-
updateβAppend one batch's packed predictions and ground truth with the optional nuScenes extras.
-
computeβScore the accumulated samples and return the official nuScenes metrics,
NDSincluded.
update [source] ΒΆ
update(
preds: Detection3D,
target: Boxes3D,
*,
velocity: OptTensor = None,
num_points: OptTensor = None,
attribute: OptTensor = None,
) -> None
Append one batch's packed predictions and ground truth with the optional nuScenes extras.
The keyword names match the dataset's ground-truth keys (velocity, num_points, attribute), so a Lightning module's metric_input_keys passthrough feeds them directly; the prediction-side velocity lives inside preds.
Parameters:
-
preds(Detection3D) βPacked predictions (one
decodeoutput),{"boxes", "scores", "labels", "batch"}; an optionalvelocityentry \((M, 2)\) is appended to the boxes as \((v_x, v_y)\) columns. -
target(Boxes3D) βPacked ground truth aligned to
preds,{"boxes", "labels", "batch"}. -
velocity(OptTensor, default:None) βOptional ground-truth per-box BEV velocity, shape \((K, 2)\), appended to the target boxes.
-
num_points(OptTensor, default:None) βOptional ground-truth per-box point count, shape \((K,)\); boxes with exactly \(0\) points are removed (unknown counts of \(-1\) are kept).
-
attribute(OptTensor, default:None) βOptional ground-truth per-box attribute id, shape \((K,)\); a negative id marks a box without an attribute.
LitClassificationModel [source] ΒΆ
Bases: LitModel
LightningModule for a point cloud classification model, built from the registry.
Parameters:
-
name(str) βRegistered classification model name (e.g.
pointnet2-ssg.modelnet40.xu-yan); built viacreate_model(name, task="classification"). -
**kwargs(Any, default:{}) βForwarded to the base
LitModel(e.g.optimizer,scheduler,criterion) andcreate_model(e.g.pretrained=True, or registry-hparam overrides).
Methods:
-
predictβForward the batch and return the logits tensor (the predictor handed to the inferer).
-
stepβPredict the batch, log the criterion loss, and return the logits, targets and loss.
-
training_stepβRun the shared
stepand return the loss to optimize. -
validation_stepβReturn the evaluation predictions and targets, plus the batch's
metric_input_keys. -
test_stepβReturn the inferer's predictions and targets, plus the batch's
metric_input_keys. -
configure_optimizersβBuild the configured optimizer (over
param_groupswhen given) and its optional scheduler.
predict [source] ΒΆ
Forward the batch and return the logits tensor (the predictor handed to the inferer).
step [source] ΒΆ
Predict the batch, log the criterion loss, and return the logits, targets and loss.
validation_step [source] ΒΆ
Return the evaluation predictions and targets, plus the batch's metric_input_keys.
LitDetectionModel [source] ΒΆ
LitDetectionModel(
name: str,
*,
criterion: Union[
Module, Callable[..., Module], None
] = None,
score_threshold: float = 0.05,
nms_iou: float = 0.25,
nms_rotated: bool = False,
min_points: Optional[int] = None,
label_key: str = LABEL,
ignore_mask_key: Optional[str] = None,
**kwargs: Any,
)
Bases: LitModel
LightningModule for a 3D object detection model, built from the registry.
Detection breaks the shared classification/segmentation loop in three places, so this subclass overrides them and reuses the base for everything else (model construction, forward, optimizer wiring, training_step):
- the loss is either a ready-built
nn.Module(the general case: an anchor / center / set-matching loss whose geometry params are set explicitly in config) or a factory completed at build time with the model's head-geometry params (theVoteNetLosscarve-out, which readsnum_heading_bins,num_size_clusters,num_classes,mean_sizesoff the model); without acriterionthe module is evaluation-only (no loss is logged, training raises); step(training only) feeds the whole forward output and the batch to the loss, which returns a dict of named components (each logged), and reports the totalloss;- the eval steps are metric-driven, not loss-driven: they run the model's raw
decode, postprocess it (optionalmin_pointsfilter, drop boxes belowscore_threshold, per-class 3Dnms3datnms_iouon the rotated BEV IoU whennms_rotated, and the indoor per-class expansion whendecodeemitsclass_probs), and pair the result with the ground truth for aMetricCallback(e.g.BoxMeanAveragePrecision,BoxAveragePrecision); any other per-boxdecodeentry (e.g. the nuScenes heads'velocity) is filtered alongside the boxes and kept in the predictions dict, and when the batch carriesDataKeys.CALIB/DataKeys.IMAGE_SHAPE(stacked per-frame \((B, 3, 4)\) / \((B, 2)\)) the sub-25 pxprojected_ignore_maskof the surviving boxes is attached as the predictions'ignore_mask(the KITTI min-height rule); the ground-truth boxes areDataKeys.BOXpacked as \((K, 7)\) rows \([c_x, c_y, c_z, d_x, d_y, d_z, \theta]\) (full extents, counter-clockwise heading \(\theta\)), with per-box classes underlabel_key. No loss is computed at validation, so a two-stage detector whose inference forward differs from its training forward (its eval output carries decoded proposals, not loss targets) validates cleanly.
A model is swappable as long as it returns a prediction dict from forward and a raw Detection3D from decode(output), and (for training) is paired with a criterion(output, data).
Parameters:
-
name(str) βRegistered detection model name; built via
create_model(name, task="detection"). -
criterion(Union[Module, Callable[..., Module], None], default:None) βThe training loss, in one of two forms. A ready-built
nn.Moduleis used as-is (the general case: instantiate it in config with its geometry params, e.g.AnchorHeadLoss). A callable factory is completed with the model's head-geometry params, i.e. called ascriterion(num_heading_bins=..., num_size_clusters=..., num_classes=..., mean_sizes=...)(theVoteNetLosscarve-out). Either way itsforward(output, data)returns a dict whoselossentry is the total to optimize. LeaveNoneto benchmark a detector whose training loss is not ported. -
score_threshold(float, default:0.05) βMinimum score to keep a decoded box in the eval postprocess.
-
nms_iou(float, default:0.25) βIoU threshold of the per-class 3D NMS in the eval postprocess.
-
nms_rotated(bool, default:False) βSuppress on the exact rotated BEV IoU instead of the axis-aligned 3D IoU (see
nms3d); the KITTI outdoor protocol. -
min_points(Optional[int], default:None) βOptional minimum number of points inside a decoded box for it to be kept (the VoteNet / 3DETR indoor protocol uses \(5\)).
-
label_key(str, default:LABEL) βBatch-dict key of the per-box ground-truth class labels (defaults to
DataKeys.LABEL). -
ignore_mask_key(Optional[str], default:None) βOptional batch-dict key of a per-box ignore mask forwarded to the metric with the ground truth (KITTI-style ignore regions).
-
**kwargs(Any, default:{}) βForwarded to
create_modeland the base (e.g.optimizer,scheduler,input_keys). The base'sinfererdoes not apply: detection eval is the decode / postprocess path above.
Methods:
-
predictβForward the batch and return the logits tensor (the predictor handed to the inferer).
-
training_stepβRun the shared
stepand return the loss to optimize. -
validation_stepβReturn the evaluation predictions and targets, plus the batch's
metric_input_keys. -
test_stepβReturn the inferer's predictions and targets, plus the batch's
metric_input_keys. -
configure_optimizersβBuild the configured optimizer (over
param_groupswhen given) and its optional scheduler. -
stepβForward the batch, log every named loss component, and return the output and the total loss.
predict [source] ΒΆ
Forward the batch and return the logits tensor (the predictor handed to the inferer).
validation_step [source] ΒΆ
Return the evaluation predictions and targets, plus the batch's metric_input_keys.
test_step [source] ΒΆ
Return the inferer's predictions and targets, plus the batch's metric_input_keys.
LitModel [source] ΒΆ
LitModel(
name: str,
task: Task,
*,
optimizer: Optional[Callable[..., Optimizer]] = None,
scheduler: Optional[Callable[..., Any]] = None,
criterion: Optional[Module] = None,
inferer: Optional[Inferer] = None,
input_keys: Optional[Sequence[str]] = None,
target_key: str = LABEL,
metric_input_keys: Sequence[str] = (),
scheduler_interval: str = "epoch",
param_groups: Optional[Dict[str, Any]] = None,
**kwargs: Any,
)
Bases: LightningModule
Shared base for the task-specific Lightning wrappers.
The task-specific subclasses build their model through create_model; this base only holds the built model (and its registered evaluation transform) and implements the shared train/val/test loop. input_keys, target_key and scheduler_interval are read from self.hparams, which the subclass populates via save_hyperparameters. Without an optimizer the module is evaluation-only (benchmark mode): Trainer.test works and Trainer.fit raises.
Parameters:
-
name(str) βRegistered model name; built via
create_model(name, task=...). -
task(Task) βRegistry of the model (
"classification","semantic-segmentation","part-segmentation","detection"); set by the subclass. -
optimizer(Optional[Callable[..., Optimizer]], default:None) βA callable that takes parameters and returns an optimizer (a
_partial_target). -
scheduler(Optional[Callable[..., Any]], default:None) βAn optional callable that takes an optimizer and returns a learning-rate scheduler.
-
criterion(Optional[Module], default:None) βThe loss module; defaults to
CrossEntropyLoss. -
inferer(Optional[Inferer], default:None) βTest-time inference strategy (e.g.
TTAInferer,SlidingWindowInferer) run in place of the plain forward on test batches; defaults toSimpleInferer(one forward on the whole batch), so every test prediction goes through an inferer. Training and validation are unaffected. The inferer may return probabilities instead of logits (torchmetrics handles both), so notest/lossis logged. -
input_keys(Optional[Sequence[str]], default:None) βBatch-dict keys passed positionally to the model's forward (see
select_inputs);None(the default) uses the registeredinput_keysof the model. -
target_key(str, default:LABEL) βBatch-dict key for the per-cloud label.
-
metric_input_keys(Sequence[str], default:()) βBatch-dict keys copied as-is into the
validation_step/test_stepoutput dict, alongside the predictions and targets, for metrics whoseupdateconsumes extra inputs (MetricCallbackforwards the keys each metric declares). A listed key missing from the batch raises. -
scheduler_interval(str, default:'epoch') βWhether the scheduler steps per
"epoch"or"step". -
param_groups(Optional[Dict[str, Any]], default:None) βOptional dict of kwargs forwarded to
torch_pointcloud.optim.generate_param_groups. -
**kwargs(Any, default:{}) βForwarded to
create_model(e.g.pretrained=True, or registry-hparam overrides).
Methods:
-
predictβForward the batch and return the logits tensor (the predictor handed to the inferer).
-
stepβPredict the batch, log the criterion loss, and return the logits, targets and loss.
-
training_stepβRun the shared
stepand return the loss to optimize. -
validation_stepβReturn the evaluation predictions and targets, plus the batch's
metric_input_keys. -
test_stepβReturn the inferer's predictions and targets, plus the batch's
metric_input_keys. -
configure_optimizersβBuild the configured optimizer (over
param_groupswhen given) and its optional scheduler.
predict [source] ΒΆ
Forward the batch and return the logits tensor (the predictor handed to the inferer).
step [source] ΒΆ
Predict the batch, log the criterion loss, and return the logits, targets and loss.
validation_step [source] ΒΆ
Return the evaluation predictions and targets, plus the batch's metric_input_keys.
LitPartSegmentationModel [source] ΒΆ
LitPartSegmentationModel(
name: str,
inverse_key: Optional[str] = None,
origin_target_key: Optional[str] = None,
target_key: str = SEGMENT,
**kwargs: Any,
)
Bases: _LitSegmentationModel
LightningModule for a part segmentation model, built from the registry.
The model also reads the one-hot object category, which the registered input_keys of part segmentation models list (("x", "pos", "batch", "category")).
Parameters:
-
name(str) βRegistered part segmentation model name; built via
create_model(name, task="part-segmentation"). -
inverse_key(Optional[str], default:None) βBatch-dict key of the source-to-predictor row map written by the transform (
inverse; see the transforms module docs on sampling keys). When set, eval predictions are broadcast to source resolution (preds[batch[inverse_key]]) and scored againstorigin_target_key; the loss stays at predictor resolution againsttarget_key. Multi-scene batches need the key in the loader'scat_keysso the per-scene maps can be offset into the packed layout; the datamodule adds it. -
origin_target_key(Optional[str], default:None) βBatch-dict key of the source-resolution labels scored with
inverse_key; required with it. -
target_key(str, default:SEGMENT) βBatch-dict key of the per-point labels.
-
**kwargs(Any, default:{}) βForwarded to the base
LitModel(e.g.inferer,optimizer,criterion) andcreate_model(e.g.pretrained=True, or registry-hparam overrides).
Methods:
-
predictβForward the batch and return the logits tensor (the predictor handed to the inferer).
-
stepβPredict the batch, log the criterion loss, and return the logits, targets and loss.
-
training_stepβRun the shared
stepand return the loss to optimize. -
validation_stepβReturn the evaluation predictions and targets, plus the batch's
metric_input_keys. -
test_stepβReturn the inferer's predictions and targets, plus the batch's
metric_input_keys. -
configure_optimizersβBuild the configured optimizer (over
param_groupswhen given) and its optional scheduler.
predict [source] ΒΆ
Forward the batch and return the logits tensor (the predictor handed to the inferer).
step [source] ΒΆ
Predict the batch, log the criterion loss, and return the logits, targets and loss.
validation_step [source] ΒΆ
Return the evaluation predictions and targets, plus the batch's metric_input_keys.
LitSemanticSegmentationModel [source] ΒΆ
LitSemanticSegmentationModel(
name: str,
inverse_key: Optional[str] = None,
origin_target_key: Optional[str] = None,
target_key: str = SEGMENT,
**kwargs: Any,
)
Bases: _LitSegmentationModel
LightningModule for a point cloud semantic segmentation model, built from the registry.
Parameters:
-
name(str) βRegistered semantic segmentation model name; built via
create_model(name, task="semantic-segmentation"). -
inverse_key(Optional[str], default:None) βBatch-dict key of the source-to-predictor row map written by the transform (
inverse; see the transforms module docs on sampling keys). When set, eval predictions are broadcast to source resolution (preds[batch[inverse_key]]) and scored againstorigin_target_key; the loss stays at predictor resolution againsttarget_key. Multi-scene batches need the key in the loader'scat_keysso the per-scene maps can be offset into the packed layout; the datamodule adds it. -
origin_target_key(Optional[str], default:None) βBatch-dict key of the source-resolution labels scored with
inverse_key; required with it. -
target_key(str, default:SEGMENT) βBatch-dict key of the per-point labels.
-
**kwargs(Any, default:{}) βForwarded to the base
LitModel(e.g.inferer,optimizer,criterion) andcreate_model(e.g.pretrained=True, or registry-hparam overrides).
Methods:
-
predictβForward the batch and return the logits tensor (the predictor handed to the inferer).
-
stepβPredict the batch, log the criterion loss, and return the logits, targets and loss.
-
training_stepβRun the shared
stepand return the loss to optimize. -
validation_stepβReturn the evaluation predictions and targets, plus the batch's
metric_input_keys. -
test_stepβReturn the inferer's predictions and targets, plus the batch's
metric_input_keys. -
configure_optimizersβBuild the configured optimizer (over
param_groupswhen given) and its optional scheduler.
predict [source] ΒΆ
Forward the batch and return the logits tensor (the predictor handed to the inferer).
step [source] ΒΆ
Predict the batch, log the criterion loss, and return the logits, targets and loss.
validation_step [source] ΒΆ
Return the evaluation predictions and targets, plus the batch's metric_input_keys.