composer.models.deeplabv3.deeplabv3#

DeepLabV3 model extending ComposerClassifier.

Functions

deeplabv3_builder

Helper function to build a torchvision DeepLabV3 model with a 3x3 convolution layer and dropout removed.

Classes

ComposerDeepLabV3

DeepLabV3 model extending ComposerClassifier.

class composer.models.deeplabv3.deeplabv3.ComposerDeepLabV3(num_classes, backbone_arch='resnet101', is_backbone_pretrained=True, backbone_url='', sync_bn=True, use_plus=True, initializers=[])[source]#

Bases: composer.models.base.ComposerModel

DeepLabV3 model extending ComposerClassifier. Logs Mean Intersection over Union (MIoU) and Cross Entropy during training and validation.

From Rethinking Atrous Convolution for Semantic Image Segmentation (Chen et al, 2017).

Parameters
  • num_classes (int) โ€“ Number of classes in the segmentation task.

  • backbone_arch (str, optional) โ€“ The architecture to use for the backbone. Must be either ['resnet50', 'resnet101']. Default: 'resnet101'.

  • is_backbone_pretrained (bool, optional) โ€“ If True, use pretrained weights for the backbone. Default: True.

  • backbone_url (str, optional) โ€“ Url used to download model weights. If empty, the PyTorch url will be used. Default: ''.

  • sync_bn (bool, optional) โ€“ If True, replace all BatchNorm layers with SyncBatchNorm layers. Default: True.

  • use_plus (bool, optional) โ€“ If True, use DeepLabv3+ head instead of DeepLabv3. Default: True.

  • initializers (List[Initializer], optional) โ€“ Initializers for the model. [] for no initialization. Default: [].

Example:

from composer.models import ComposerDeepLabV3

model = ComposerDeepLabV3(num_classes=150, backbone_arch='resnet101', is_backbone_pretrained=False)
composer.models.deeplabv3.deeplabv3.deeplabv3_builder(num_classes, backbone_arch='resnet101', is_backbone_pretrained=True, backbone_url='', sync_bn=True, use_plus=True, initializers=[])[source]#

Helper function to build a torchvision DeepLabV3 model with a 3x3 convolution layer and dropout removed.

Parameters
  • num_classes (int) โ€“ Number of classes in the segmentation task.

  • backbone_arch (str, optional) โ€“ The architecture to use for the backbone. Must be either ['resnet50', 'resnet101']. Default: 'resnet101'.

  • is_backbone_pretrained (bool, optional) โ€“ If True, use pretrained weights for the backbone. Default: True.

  • backbone_url (str, optional) โ€“ Url used to download model weights. If empty, the PyTorch url will be used. Default: ''.

  • sync_bn (bool, optional) โ€“ If True, replace all BatchNorm layers with SyncBatchNorm layers. Default: True.

  • use_plus (bool, optional) โ€“ If True, use DeepLabv3+ head instead of DeepLabv3. Default: True.

  • initializers (List[Initializer], optional) โ€“ Initializers for the model. [] for no initialization. Default: [].

Returns

deeplabv3 โ€“ A DeepLabV3 torch.nn.Module.

Example:

from composer.models.deeplabv3.deeplabv3 import deeplabv3_builder

pytorch_model = deeplabv3_builder(num_classes=150, backbone_arch='resnet101', is_backbone_pretrained=False)