--- title: Models keywords: fastai sidebar: home_sidebar summary: "Pytorch segmentation models." description: "Pytorch segmentation models." nb_path: "nbs/01_models.ipynb" ---
Pytorch implementation adapted from https://github.com/jvanvugt/pytorch-unet
Args:\
in_channels
(int): the number of input channels.\
n_classes
(int): the number of output channels. \
depth
(int): depth of the network.\
wf
(int): number of filters in the first layer is 2^wf
padding
(bool): if True, apply padding such that the input shape is the same as the output. This may introduce artifacts\
batch_norm
(bool): Use BatchNorm after layers with an activation function\
up_mode
(str): one of 'upconv' or 'upsample'. 'upconv' will use transposed convolutions for learned upsampling. 'upsample' will use bilinear upsampling.\
neg_slope
(float): Controls the angle of the negative slope for LeakyReLU. Standard ReLU if set to 0.
Original U-Net architecture based on Ronneberger, Olaf, Philipp Fischer, and Thomas Brox. "U-net: Convolutional networks for biomedical image segmentation." International Conference on Medical image computing and computer-assisted intervention. Springer, Cham, 2015.
U-Net architecture based on Falk, Thorsten, et al. "U-Net: deep learning for cell counting, detection, and morphometry." Nature methods 16.1 (2019): 67-70.
U-Net model optimized for deepflash2
tst = unet_deepflash2()
tst = unet_deepflash2(pretrained='wue_cFOS')
tst = unet_deepflash2(n_classes=3, pretrained='wue_cFOS')
UneXt50 Architecture adapted from Maxim Shugaev on Kaggle
tst = unext50_deepflash2(pretrained='wue_cFOS')
tst = unext50_deepflash2(in_channels=3, n_classes=5)
x = torch.randn(2, 3, 518, 518)
y = tst(x)
test_eq(y.shape, [2, 5, 392, 392])
From the website:
See https://github.com/qubvel/segmentation_models.pytorch for API details.
tst = load_smp_model(arch='DeepLabV3', in_channels=3, classes=5)
x = torch.randn(2, 3, 512, 512)
y = tst(x)
test_eq(y.shape, [2, 5, 512, 512])
Helper functions for default input and masks shapes, depending on model architecture