ai_ct_scans.models module

class ai_ct_scans.models.Infiller(input_height=256, input_width=256, output_height=256, output_width=256, num_encoder_convs=3, encoder_filts_per_layer=10, neurons_per_dense=512, num_dense_layers=3, decoder_filts_per_layer=10, kernel_size=3, num_decoder_convs=3)

Bases: Module

A class for building a model capapble of predicting masked central patches in images

build_decoder_convs()

Create a ModuleList of SingleDecoderLayers with exponentially decreasing filter number after each layer

Returns

The layers of the decoder

Return type

(ModuleList)

build_encoder_convs()

Create a ModuleList of SingleEncoderLayers with exponentially increasing filter number after each layer, in Unet style

Returns

The layers of the encoder

Return type

(ModuleList)

build_latent_space_bridge()

Create a ModuleList of Linear layers that define the ‘latent space bridge’, connecting the output of the convolutional encoder to the convolutional decoder, and allows for additional neurons defining the plane, body part and slice location to be passed to the model. Not currently included in the forward of the overall model, but may be useful in future work

Returns

The layers of the decoder

Return type

(ModuleList)

forward(batch)

Perform the forward pass of the model. Currently a Unet implementation

Parameters
  • batch (dict of tensors) – A batch, e.g. as built by ai_ct_scans.model_trainers.InfillTrainer.build_batch,

  • 'input_images' (having at minimum a 4D stack of tensors at) –

Returns

A tensor the same shape as input

Return type

(Tensor)

training: bool
class ai_ct_scans.models.SingleDecoderLayer(num_input_filters, num_output_filters, kernel_size, conv_bias=True)

Bases: Module

forward(x)

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 ai_ct_scans.models.SingleEncoderLayer(num_input_filters, num_output_filters, kernel_size, conv_bias=True)

Bases: Module

forward(x)

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