fusionlab.segmentation.transunet.transunet module#

class fusionlab.segmentation.transunet.transunet.Attention(num_attention_heads=12, hidden_size=768, attention_dropout_rate=0.1)[source]#

Bases: Module

forward(hidden_states)[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.

training: bool#
transpose_for_scores(x)[source]#
class fusionlab.segmentation.transunet.transunet.Conv2dReLU(in_channels, out_channels, kernel_size, padding=0, stride=1, use_batchnorm=True)[source]#

Bases: Sequential

class fusionlab.segmentation.transunet.transunet.DecoderBlock(in_channels, out_channels, skip_channels=0, use_batchnorm=True)[source]#

Bases: Module

forward(x, skip=None)[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.

training: bool#
class fusionlab.segmentation.transunet.transunet.Embeddings(patch_size, img_size, num_layers, width_factor=1, in_channels=3, hidden_size=768, dropout_rate=0.1)[source]#

Bases: Module

Construct the embeddings from patch, position embeddings.

forward(x)[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.

training: bool#
class fusionlab.segmentation.transunet.transunet.MLP(hidden_size=768, mlp_dim=3072, dropout_rate=0.1)[source]#

Bases: Module

forward(x)[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.

training: bool#
class fusionlab.segmentation.transunet.transunet.PreActBottleneck(cin, cout=None, cmid=None, stride=1)[source]#

Bases: Module

Pre-activation (v2) bottleneck block.

forward(x)[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.

training: bool#
class fusionlab.segmentation.transunet.transunet.ResNetV2(block_units, width_factor)[source]#

Bases: Module

Implementation of Pre-activation (v2) ResNet mode.

forward(x, return_features=True)[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.

training: bool#
class fusionlab.segmentation.transunet.transunet.SegmentationHead(in_channels, out_channels, kernel_size=3, upsampling=1)[source]#

Bases: Sequential

class fusionlab.segmentation.transunet.transunet.StdConv2d(in_channels, out_channels, kernel_size, stride=1, padding=0, dilation=1, groups=1, bias=True, padding_mode='zeros', device=None, dtype=None)[source]#

Bases: Conv2d

bias: Tensor | None#
dilation: Tuple[int, ...]#
forward(x)[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.

groups: int#
in_channels: int#
kernel_size: Tuple[int, ...]#
out_channels: int#
output_padding: Tuple[int, ...]#
padding: str | Tuple[int, ...]#
padding_mode: str#
stride: Tuple[int, ...]#
transposed: bool#
weight: Tensor#
class fusionlab.segmentation.transunet.transunet.TransUNet(in_channels=3, img_size=224, num_classes=2, zero_head=False, decoder_channels=[256, 128, 64, 16], hidden_size=768, n_skip=3, skip_channels=[512, 256, 64, 16], patch_size=(16, 16))[source]#

Bases: Module

forward(x)[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.

training: bool#
class fusionlab.segmentation.transunet.transunet.TransUNetDecoder(decoder_channels, hidden_size, n_skip, skip_channels, head_channels=512)[source]#

Bases: Module

forward(hidden_states, features=None)[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.

training: bool#
class fusionlab.segmentation.transunet.transunet.Transformer(in_channels, img_size, patch_size=(16, 16))[source]#

Bases: Module

forward(input_ids)[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.

training: bool#
class fusionlab.segmentation.transunet.transunet.TransformerEncoder(num_layers=12, hidden_size=768, mlp_dim=3072, dropout_rate=0.1)[source]#

Bases: Module

forward(hidden_states)[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.

training: bool#
class fusionlab.segmentation.transunet.transunet.TransformerEncoderBlock(hidden_size=768, mlp_dim=3072, dropout_rate=0.1)[source]#

Bases: Module

forward(x)[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.

training: bool#
fusionlab.segmentation.transunet.transunet.conv1x1(cin, cout, stride=1, bias=False)[source]#
fusionlab.segmentation.transunet.transunet.conv3x3(cin, cout, stride=1, groups=1, bias=False)[source]#