bob.ip.binseg.models.m2unet

Functions

m2unet([pretrained_backbone, progress])

Builds M2U-Net for segmentation by adding backbone and head together

Classes

DecoderBlock(up_in_c, x_in_c[, ...])

Decoder block: upsample and concatenate with features maps from the encoder part

LastDecoderBlock(x_in_c[, upsamplemode, ...])

M2UNet([in_channels_list, upsamplemode, ...])

M2U-Net head module

class bob.ip.binseg.models.m2unet.DecoderBlock(up_in_c, x_in_c, upsamplemode='bilinear', expand_ratio=0.15)[source]

Bases: Module

Decoder block: upsample and concatenate with features maps from the encoder part

forward(up_in, x_in)[source]

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class bob.ip.binseg.models.m2unet.LastDecoderBlock(x_in_c, upsamplemode='bilinear', expand_ratio=0.15)[source]

Bases: Module

forward(up_in, x_in)[source]

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class bob.ip.binseg.models.m2unet.M2UNet(in_channels_list=None, upsamplemode='bilinear', expand_ratio=0.15)[source]

Bases: Module

M2U-Net head module

Parameters

in_channels_list (list) – number of channels for each feature map that is returned from backbone

forward(x)[source]
Parameters

x (list) – list of tensors as returned from the backbone network. First element: height and width of input image. Remaining elements: feature maps for each feature level.

Returns

tensor

Return type

torch.Tensor

bob.ip.binseg.models.m2unet.m2unet(pretrained_backbone=True, progress=True)[source]

Builds M2U-Net for segmentation by adding backbone and head together

Parameters
  • pretrained_backbone (bool, Optional) – If set to True, then loads a pre-trained version of the backbone (not the head) for the DRIU network using VGG-16 trained for ImageNet classification.

  • progress (bool, Optional) – If set to True, and you decided to use a pretrained_backbone, then, shows a progress bar of the backbone model downloading if download is necesssary.

Returns

module – Network model for M2U-Net (segmentation)

Return type

torch.nn.Module