utils¶

Define utility layers and operators for models in tiatoolbox.

Functions

argmax_last_axis

Define the post-processing of this class of model.

centre_crop

A function to center crop image with given crop shape.

centre_crop_to_shape

A function to center crop image to shape.

compile_model

A decorator to compile a model using torch-compile.

eval_model_if_nn_module

Run model.eval() if the model is a torch module.

is_torch_compile_compatible

Check if the current GPU is compatible with torch-compile.

nms_on_detection_maps

Apply NMS to pre-processed peak maps to handle cross-channel conflicts.

patch_first_conv

Update the first convolution layer for a new input channel size.

peak_detection_map_overlap

Post-processing function for peak detection.

replace_strides_with_dilation

Replace strides with dilation in Conv2d layers.

Classes

AttentionModule

Attention module to apply attention mechanism on feature maps.

Conv2dReLU

Conv2d + BatchNorm + ReLU block.

EncoderMixin

Mixin class adding encoder-specific functionality.

SCSEModule

Spatial and Channel Squeeze & Excitation (SCSE) module.

SegmentationHead

Segmentation head for UNet++ architecture.

UpSample2x

A layer to scale input by a factor of 2.