minerva.models.nets.deeplabv3

Classes

DeepLabV3

A DeeplabV3 with a ResNet50 backbone

DeepLabV3Backbone

A ResNet50 backbone for DeepLabV3

DeepLabV3PredictionHead

The prediction head for DeepLabV3

Module Contents

class minerva.models.nets.deeplabv3.DeepLabV3(backbone=None, pred_head=None, loss_fn=None, learning_rate=0.001, num_classes=6, train_metrics=None, val_metrics=None, test_metrics=None)

Bases: minerva.models.nets.base.SimpleSupervisedModel

A DeeplabV3 with a ResNet50 backbone

References

Liang-Chieh Chen, George Papandreou, Florian Schroff, Hartwig Adam. “Rethinking Atrous Convolution for Semantic Image Segmentation”, 2017

Initializes a DeepLabV3 model.

Parameters

backbone: Optional[nn.Module]

The backbone network. Defaults to None.

pred_head: Optional[nn.Module]

The prediction head network. Defaults to None.

loss_fn: Optional[nn.Module]

The loss function. Defaults to None.

learning_rate: float

The learning rate for the optimizer. Defaults to 0.001.

num_classes: int

The number of classes for prediction. Defaults to 6.

train_metrics: Optional[Dict[str, Metric]]

The metrics to be computed during training. Defaults to None.

val_metrics: Optional[Dict[str, Metric]]

The metrics to be computed during validation. Defaults to None.

test_metrics: Optional[Dict[str, Metric]]

The metrics to be computed during testing. Defaults to None.

_loss_func(y_hat, y)

Calculate the loss between the output and the input data.

Parameters

y_hattorch.Tensor

The output data from the forward pass.

ytorch.Tensor

The input data/label.

Returns

torch.Tensor

The loss value.

Parameters:
  • y_hat (torch.Tensor)

  • y (torch.Tensor)

Return type:

torch.Tensor

configure_optimizers()
forward(x)

Perform a forward pass with the input data on the backbone model.

Parameters

xtorch.Tensor

The input data.

Returns

torch.Tensor

The output data from the forward pass.

Parameters:

x (torch.Tensor)

Return type:

torch.Tensor

Parameters:
  • backbone (Optional[torch.nn.Module])

  • pred_head (Optional[torch.nn.Module])

  • loss_fn (Optional[torch.nn.Module])

  • learning_rate (float)

  • num_classes (int)

  • train_metrics (Optional[Dict[str, torchmetrics.Metric]])

  • val_metrics (Optional[Dict[str, torchmetrics.Metric]])

  • test_metrics (Optional[Dict[str, torchmetrics.Metric]])

class minerva.models.nets.deeplabv3.DeepLabV3Backbone(num_classes=6)

Bases: torch.nn.Module

A ResNet50 backbone for DeepLabV3

Initializes the DeepLabV3 model.

Parameters

num_classes: int

The number of classes for classification. Default is 6.

forward(x)
freeze_weights()
unfreeze_weights()
Parameters:

num_classes (int)

class minerva.models.nets.deeplabv3.DeepLabV3PredictionHead(in_channels=2048, num_classes=6, atrous_rates=(12, 24, 36))

Bases: torch.nn.Sequential

The prediction head for DeepLabV3

Initializes the DeepLabV3 model.

Parameters

in_channels: int

Number of input channels. Defaults to 2048.

num_classes: int

Number of output classes. Defaults to 6.

atrous_rates: Sequence[int]

A sequence of atrous rates for the ASPP module. Defaults to (12, 24, 36).

Parameters:
  • in_channels (int)

  • num_classes (int)

  • atrous_rates (Sequence[int])