PointCloudSegmentation¶
- class flash.pointcloud.segmentation.model.PointCloudSegmentation(num_classes, backbone='randlanet', backbone_kwargs=None, head=None, loss_fn=<function cross_entropy>, optimizer='Adam', lr_scheduler=None, metrics=None, learning_rate=None, multi_label=False)[source]¶
The
PointCloudClassifieris aClassificationTaskthat classifies pointcloud data.- Parameters
num_classes¶ (
int) – The number of classes (outputs) for thisTask.backbone¶ (
Union[str,Tuple[Module,int]]) – The backbone name (or a tuple ofnn.Module, output size) to use.backbone_kwargs¶ (
Optional[Dict]) – Any additional kwargs to pass to the backbone constructor.head¶ (
Optional[Module]) – a nn.Module to use on top of the backbone. The output dimension should match the num_classes argument. If not set will default to a single linear layer.loss_fn¶ (
TypeVar(LOSS_FN_TYPE,Callable,Mapping,Sequence,None)) – The loss function to use. IfNone, a default will be selected by theClassificationTaskdepending on themulti_labelargument.optimizer¶ (
TypeVar(OPTIMIZER_TYPE,str,Callable,Tuple[str,Dict[str,Any]],None)) – Optimizer to use for training.lr_scheduler¶ (
Optional[TypeVar(LR_SCHEDULER_TYPE,str,Callable,Tuple[str,Dict[str,Any]],Tuple[str,Dict[str,Any],Dict[str,Any]],None)]) – The LR scheduler to use during training.metrics¶ (
Optional[TypeVar(METRICS_TYPE,Metric,Mapping,Sequence,None)]) – Any metrics to use with thisTask. IfNone, a default will be selected by theClassificationTaskdepending on themulti_labelargument.learning_rate¶ (
Optional[float]) – The learning rate for the optimizer.multi_label¶ (
bool) – IfTrue, this will be treated as a multi-label classification problem.
- classmethod available_finetuning_strategies(cls)¶
Returns a list containing the keys of the available Finetuning Strategies.
- classmethod available_lr_schedulers(cls)¶
Returns a list containing the keys of the available LR schedulers.
- classmethod available_optimizers(cls)¶
Returns a list containing the keys of the available Optimizers.
- classmethod available_outputs(cls)¶
Returns the list of available outputs (that can be used during prediction or serving) for this
Task.Examples
..testsetup:
>>> from flash import Task
>>> print(Task.available_outputs()) ['preds', 'raw']
- classmethod load_from_checkpoint(cls, checkpoint_path, map_location=None, hparams_file=None, strict=True, **kwargs)¶
Primary way of loading a model from a checkpoint. When Lightning saves a checkpoint it stores the arguments passed to
__init__in the checkpoint under"hyper_parameters".Any arguments specified through **kwargs will override args stored in
"hyper_parameters".- Parameters
checkpoint_path¶ (
Union[str,Path,IO]) – Path to checkpoint. This can also be a URL, or file-like objectmap_location¶ (
Union[device,str,int,Callable[[Union[device,str,int]],Union[device,str,int]],Dict[Union[device,str,int],Union[device,str,int]],None]) – If your checkpoint saved a GPU model and you now load on CPUs or a different number of GPUs, use this to map to the new setup. The behaviour is the same as intorch.load().hparams_file¶ (
Union[str,Path,None]) –Optional path to a
.yamlor.csvfile with hierarchical structure as in this example:drop_prob: 0.2 dataloader: batch_size: 32
You most likely won’t need this since Lightning will always save the hyperparameters to the checkpoint. However, if your checkpoint weights don’t have the hyperparameters saved, use this method to pass in a
.yamlfile with the hparams you’d like to use. These will be converted into adictand passed into yourLightningModulefor use.If your model’s
hparamsargument isNamespaceand.yamlfile has hierarchical structure, you need to refactor your model to treathparamsasdict.strict¶ (
bool) – Whether to strictly enforce that the keys incheckpoint_pathmatch the keys returned by this module’s state dict.**kwargs¶ – Any extra keyword args needed to init the model. Can also be used to override saved hyperparameter values.
- Return type
Self- Returns
LightningModuleinstance with loaded weights and hyperparameters (if available).
Note
load_from_checkpointis a class method. You should use yourLightningModuleclass to call it instead of theLightningModuleinstance.Example:
# load weights without mapping ... model = MyLightningModule.load_from_checkpoint('path/to/checkpoint.ckpt') # or load weights mapping all weights from GPU 1 to GPU 0 ... map_location = {'cuda:1':'cuda:0'} model = MyLightningModule.load_from_checkpoint( 'path/to/checkpoint.ckpt', map_location=map_location ) # or load weights and hyperparameters from separate files. model = MyLightningModule.load_from_checkpoint( 'path/to/checkpoint.ckpt', hparams_file='/path/to/hparams_file.yaml' ) # override some of the params with new values model = MyLightningModule.load_from_checkpoint( PATH, num_layers=128, pretrained_ckpt_path=NEW_PATH, ) # predict pretrained_model.eval() pretrained_model.freeze() y_hat = pretrained_model(x)