Shortcuts

VideoClassifier

class flash.video.classification.model.VideoClassifier(num_classes, backbone='x3d_xs', backbone_kwargs=None, pretrained=True, loss_fn=torch.nn.functional.cross_entropy, optimizer='SGD', lr_scheduler=None, metrics=torchmetrics.Accuracy, learning_rate=0.001, head=None, output=None)[source]

Task that classifies videos.

Parameters
  • num_classes (int) – Number of classes to classify.

  • backbone (Union[str, Module]) – A string mapped to pytorch_video backbones or nn.Module, defaults to "slowfast_r50".

  • backbone_kwargs (Optional[Dict]) – Arguments to customize the backbone from PyTorchVideo.

  • pretrained (bool) – Use a pretrained backbone, defaults to True.

  • loss_fn (Union[Callable, Mapping, Sequence, None]) – Loss function for training, defaults to torch.nn.functional.cross_entropy().

  • optimizer (Union[str, Callable, Tuple[str, Dict[str, Any]]]) – Optimizer to use for training, defaults to torch.optim.SGD.

  • lr_scheduler (Union[str, Callable, Tuple[str, Dict[str, Any]], Tuple[str, Dict[str, Any], Dict[str, Any]], None]) – The scheduler or scheduler class to use.

  • metrics (Union[Metric, Mapping, Sequence, None]) – Metrics to compute for training and evaluation. Can either be an metric from the torchmetrics package, a custom metric inherenting from torchmetrics.Metric, a callable function or a list/dict containing a combination of the aforementioned. In all cases, each metric needs to have the signature metric(preds,target) and return a single scalar tensor. Defaults to torchmetrics.Accuracy.

  • learning_rate (float) – Learning rate to use for training, defaults to 1e-3.

  • head (Union[function, Module, None]) – either a nn.Module or a callable function that converts the features extrated from the backbone into class log probabilities (assuming default loss function). If None, will default to using a single linear layer.

  • output (Optional[Output]) – The Output to use when formatting prediction outputs.

modules_to_freeze()[source]

Return the module attributes of the model to be frozen.

Return type

Union[Module, Iterable[Union[Module, Iterable]]]

Read the Docs v: latest
Versions
latest
stable
0.5.2
0.5.1
0.5.0
0.4.0
0.3.2
0.3.1
0.3.0
0.2.3
0.2.2
0.2.1
0.2.0
0.1.0post1
Downloads
html
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.