W-Net

class src.pipelines.tensorflow_v2.models.wnet.ConvBridgeBlock(channels, activation, initializer)[source]

A Convolutional Bridge Block to be used in a W-Net

call(x)[source]

Applies a ConvBridgeBlock to the an input

Parameters

x (Tensor) – the input to apply the ConvBridgeBlock to

Return type

Tensor

Returns

the output of the ConvBridgeBlock

class src.pipelines.tensorflow_v2.models.wnet.MiniUnet(output_channels, activation='relu', initializer='he_normal', filters=0)[source]

A mini U-Net, two of these are joined to make a W-Net model

call(inputs)[source]

Applies a mini U-Net to the input.

Parameters

inputs (Tensor) – an input image

Return type

Tensor

Returns

the output of a mini U-Net

model(shape=(512, 512, 1))[source]

Returns a U-Net model as tf.keras.Model. This is a workaround to use the functional api, which allows the model to be viewed.

Parameters

shape (Tuple[int, int, int]) – the shape of the input

Return type

Model

Returns

the tf.keras.Model instantiated using the functional api

print_all_layers()[source]

Prints all the layers in the model, including the layers in the subclasses which make up the model. This uses the model() workaround function.

Return type

None

Returns

None

get_all_layers()[source]

Returns all the layers in the model, including the layers in the subclasses which make up the model. This uses the model() workaround function.

Return type

List[Layer]

Returns

a list of layers

class src.pipelines.tensorflow_v2.models.wnet.WNet(output_channels, activation='relu', initializer='he_normal', filters=0)[source]

A W-Net model. This model combines two Mini U-Nets where the prediction of the first Mini U-Net is concatenated to the first

call(input_tensor, training=True)[source]

Applies a W-Net model to an input image, which is a call of two sequent mini U-Nets. If the W-Net is not training then only the output of the second mini U-Net is returned.

Parameters
  • input_tensor (Tensor) – an input image

  • training (bool) – whether the W-Net is being applied to a training sample

Return type

Tuple[Tensor, Tensor]

Returns

either the ouput of both mini U-Nets or the output of the second mini U-Net

model(shape=(512, 512, 1))[source]

Returns a U-Net model as tf.keras.Model. This is a workaround to use the functional api, which allows the model to be viewed.

Parameters

shape (Tuple[int, int, int]) – the shape of the input

Return type

Model

Returns

the tf.keras.Model instantiated using the functional api

print_all_layers()[source]

Prints all the layers in the model, including the layers in the subclasses which make up the model. This uses the model() workaround function.

Return type

None

Returns

None

get_all_layers()[source]

Returns all the layers in the model, including the layers in the subclasses which make up the model. This uses the model() workaround function.

Return type

List[Layer]

Returns

a list of layers