deepdraw.models.lwnet#

Little W-Net.

Code was originally developed by Adrian Galdran (https://github.com/agaldran/lwnet), loosely inspired on https://github.com/jvanvugt/pytorch-unet

It is based on two simple U-Nets with 3 layers concatenated to each other. The first U-Net produces a segmentation map that is used by the second to better guide segmentation.

Reference: [GALDRAN-2020]

Functions

lunet([input_channels, output_classes])

Builds Little U-Net segmentation network (uninitialized)

lwnet([input_channels, output_classes])

Builds Little W-Net segmentation network (uninitialized)

Classes

ConvBlock(in_c, out_c[, k_sz, shortcut, pool])

ConvBridgeBlock(channels[, k_sz])

LittleUNet(in_c, n_classes, layers[, k_sz, ...])

Little U-Net model.

LittleWNet([n_classes, in_c, layers, ...])

Little W-Net model, concatenating two Little U-Net models.

UpConvBlock(in_c, out_c[, k_sz, up_mode, ...])

UpsampleBlock(in_c, out_c[, up_mode])

class deepdraw.models.lwnet.ConvBlock(in_c, out_c, k_sz=3, shortcut=False, pool=True)[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.

class deepdraw.models.lwnet.UpsampleBlock(in_c, out_c, up_mode='transp_conv')[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.

class deepdraw.models.lwnet.ConvBridgeBlock(channels, k_sz=3)[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.

class deepdraw.models.lwnet.UpConvBlock(in_c, out_c, k_sz=3, up_mode='up_conv', conv_bridge=False, shortcut=False)[source]#

Bases: Module

forward(x, skip)[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 deepdraw.models.lwnet.LittleUNet(in_c, n_classes, layers, k_sz=3, up_mode='transp_conv', conv_bridge=True, shortcut=True)[source]#

Bases: Module

Little U-Net model.

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.

class deepdraw.models.lwnet.LittleWNet(n_classes=1, in_c=3, layers=(8, 16, 32), conv_bridge=True, shortcut=True, mode='train')[source]#

Bases: Module

Little W-Net model, concatenating two Little U-Net models.

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.

deepdraw.models.lwnet.lunet(input_channels=3, output_classes=1)[source]#

Builds Little U-Net segmentation network (uninitialized)

Parameters:
  • input_channels (int, Optional) – Number of input channels the network should operate with

  • output_classes (int, Optional) – Number of output classes

Returns:

deepdraw.models.lwnet.lwnet(input_channels=3, output_classes=1)[source]#

Builds Little W-Net segmentation network (uninitialized)

Parameters:
  • input_channels (int, Optional) – Number of input channels the network should operate with

  • output_classes (int, Optional) – Number of output classes

Returns: