Other models

This is the API reference for some of the models supported by Metalhead.jl that do not fit into the other categories.

The higher-level model constructors

Metalhead.AlexNetType
AlexNet(; pretrain::Bool = false, inchannels::Integer = 3,
        nclasses::Integer = 1000)

Create a AlexNet. (reference).

Arguments

  • pretrain: set to true to load pre-trained weights for ImageNet
  • inchannels: The number of input channels.
  • nclasses: the number of output classes
Warning

AlexNet does not currently support pretrained weights.

See also alexnet.

source
Metalhead.VGGType
VGG(depth::Integer; pretrain::Bool = false, batchnorm::Bool = false,
    inchannels::Integer = 3, nclasses::Integer = 1000)

Create a VGG style model with specified depth. (reference).

Warning

VGG does not currently support pretrained weights for the batchnorm = true option.

Arguments

  • depth: the depth of the VGG model. Must be one of [11, 13, 16, 19].
  • pretrain: set to true to load pre-trained model weights for ImageNet
  • batchnorm: set to true to use batch normalization after each convolution
  • inchannels: number of input channels
  • nclasses: number of output classes

See also vgg.

source
Metalhead.SqueezeNetType
SqueezeNet(; pretrain::Bool = false, inchannels::Integer = 3,
           nclasses::Integer = 1000)

Create a SqueezeNet (reference).

Arguments

  • pretrain: set to true to load the pre-trained weights for ImageNet
  • inchannels: number of input channels.
  • nclasses: the number of output classes.

See also squeezenet.

source
Metalhead.UNetType
UNet(imsize::Dims{2} = (256, 256), inchannels::Integer = 3, outplanes::Integer = 3,
     encoder_backbone = Metalhead.backbone(DenseNet(121)); pretrain::Bool = false)

Creates a UNet model with an encoder built of specified backbone. By default it uses DenseNet backbone, but any ResNet-like Metalhead model can be used for the encoder. (reference).

Arguments

  • imsize: size of input image
  • inchannels: number of channels in input image
  • outplanes: number of output feature planes.
  • encoder_backbone: The backbone layers of specified model to be used as encoder. For example, Metalhead.backbone(Metalhead.ResNet(18)) can be passed to instantiate a UNet with layers of resnet18 as encoder.
  • pretrain: Whether to load the pre-trained weights for ImageNet
Warning

UNet does not currently support pretrained weights.

See also Metalhead.unet.

source

The mid-level functions

Metalhead.alexnetFunction
alexnet(; dropout_prob = 0.5, inchannels::Integer = 3, nclasses::Integer = 1000)

Create an AlexNet model (reference).

Arguments

  • dropout_prob: dropout probability for the classifier
  • inchannels: The number of input channels.
  • nclasses: the number of output classes
source
Metalhead.vggFunction
vgg(imsize::Dims{2}; config, batchnorm::Bool = false, fcsize::Integer = 4096,
    dropout_prob = 0.0, inchannels::Integer = 3, nclasses::Integer = 1000)

Create a VGG model (reference).

Arguments

  • imsize: input image width and height as a tuple
  • config: the configuration for the convolution layers (see Metalhead.vgg_convolutional_layers)
  • inchannels: number of input channels
  • batchnorm: set to true to use batch normalization after each convolution
  • nclasses: number of output classes
  • fcsize: intermediate fully connected layer size (see Metalhead.vgg_classifier_layers)
  • dropout_prob: dropout level between fully connected layers
source
Metalhead.squeezenetFunction
squeezenet(; dropout_prob = 0.5, inchannels::Integer = 3, nclasses::Integer = 1000)

Create a SqueezeNet model. (reference).

Arguments

  • dropout_prob: dropout probability for the classifier head. Set to nothing to disable dropout.
  • inchannels: number of input channels.
  • nclasses: the number of output classes.
source
Metalhead.unetFunction
unet(encoder_backbone, imgdims, outplanes::Integer, final::Any = unet_final_block,
     fdownscale::Integer = 0)

Creates a UNet model with specified convolutional backbone. Backbone of any Metalhead ResNet-like model can be used as encoder (reference).

Arguments

- `encoder_backbone`: The backbone layers of specified model to be used as encoder.
	For example, `Metalhead.backbone(Metalhead.ResNet(18))` can be passed 
	to instantiate a UNet with layers of resnet18 as encoder.
- `inputsize`: size of input image
- `outplanes`: number of output feature planes
- `final`: final block as described in original paper
- `fdownscale`: downscale factor
source

Block-level functions

Metalhead.vgg_blockFunction
vgg_block(ifilters, ofilters, depth, batchnorm)

A VGG block of convolution layers (reference).

Arguments

  • ifilters: number of input feature maps
  • ofilters: number of output feature maps
  • depth: number of convolution/convolution + batch norm layers
  • batchnorm: set to true to include batch normalization after each convolution
source
Metalhead.vgg_convolutional_layersFunction
vgg_convolutional_layers(config, batchnorm, inchannels)

Create VGG convolution layers (reference).

Arguments

  • config: vector of tuples (output_channels, num_convolutions) for each block (see Metalhead.vgg_block)
  • batchnorm: set to true to include batch normalization after each convolution
  • inchannels: number of input channels
source
Metalhead.vgg_classifier_layersFunction
vgg_classifier_layers(imsize, nclasses, fcsize, dropout_prob)

Create VGG classifier (fully connected) layers (reference).

Arguments

  • imsize: tuple (width, height, channels) indicating the size after the convolution layers (see Metalhead.vgg_convolutional_layers)
  • nclasses: number of output classes
  • fcsize: input and output size of the intermediate fully connected layer
  • dropout_prob: the dropout level between each fully connected layer
source