Skip to content

Computer Vision Models (Vision API)

Native Lux Models

Boltz.Vision.AlexNet Type
julia
AlexNet(; pretrained=false)

Create an AlexNet model [4].

Keyword Arguments

  • pretrained: Valid Options are false, true, :DEFAULT, :ImageNet1K or :ImageNet1K_V1. :DEFAULT, true and :ImageNet1K weights currently corresponds to :ImageNet1K_V1.
source
Boltz.Vision.EfficientNet Type
julia
EfficientNet(variant::Union{String,Symbol}; pretrained::Bool=false, in_channels::Int=3,
             nclasses::Int=1000)

Create an EfficientNet model [5].

Arguments

  • variant::Union{String,Symbol}: The variant of the EfficientNet model to use. Valid variants are :b0, :b1, :b2, :b3, :b4, :b5, :b6, :b7.

Keyword Arguments

  • pretrained::Bool=false: If true, loads pretrained weights when LuxCore.setup is called.

  • in_channels::Int=3: The number of input channels. (Must be 3 for pretrained models.)

  • nclasses::Int=1000: The number of output classes. (Must be 1000 for pretrained models.)

source
Boltz.Vision.VGG Type
julia
VGG(imsize; config, inchannels, batchnorm = false, nclasses, fcsize, dropout)

Create a VGG model [6].

Arguments

  • imsize: input image width and height as a tuple

  • config: the configuration for the convolution 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

  • dropout: dropout level between fully connected layers

source
julia
VGG(depth::Int; batchnorm::Bool=false, pretrained::Bool=false)

Create a VGG model [6] with ImageNet Configuration.

Arguments

  • depth::Int: the depth of the VGG model. Choices: {11, 13, 16, 19}.

Keyword Arguments

  • batchnorm = false: set to true to use batch normalization after each convolution.

  • pretrained::Bool=false: If true, loads pretrained weights when LuxCore.setup is called.

source
Boltz.Vision.VisionTransformer Type
julia
VisionTransformer(name::Symbol; pretrained=false)

Creates a Vision Transformer model with the specified configuration.

Arguments

  • name::Symbol: name of the Vision Transformer model to create. The following models are available – :tiny, :small, :base, :large, :huge, :giant, :gigantic.

Keyword Arguments

  • pretrained::Bool=false: If true, loads pretrained weights when LuxCore.setup is called.
source

Imported from Metalhead.jl

Load Metalhead

You need to load Metalhead before using these models.

Boltz.Vision.ConvMixer Function
julia
ConvMixer(name::Symbol; pretrained::Bool=false)

Create a ConvMixer model [7].

Arguments

  • name::Symbol: The name of the ConvMixer model. Must be one of :base, :small, or :large.

Keyword Arguments

  • pretrained::Bool=false: If true, loads pretrained weights when LuxCore.setup is called.
source
Boltz.Vision.DenseNet Function
julia
DenseNet(depth::Int; pretrained::Bool=false)

Create a DenseNet model [8].

Arguments

  • depth::Int: The depth of the DenseNet model. Must be one of 121, 161, 169, or 201.

Keyword Arguments

  • pretrained::Bool=false: If true, loads pretrained weights when LuxCore.setup is called.
source
Boltz.Vision.GoogLeNet Function
julia
GoogLeNet(; pretrained::Bool=false)

Create a GoogLeNet model [9].

Keyword Arguments

  • pretrained::Bool=false: If true, loads pretrained weights when LuxCore.setup is called.
source
Boltz.Vision.MobileNet Function
julia
MobileNet(name::Symbol; pretrained::Bool=false)

Create a MobileNet model [1012].

Arguments

  • name::Symbol: The name of the MobileNet model. Must be one of :v1, :v2, :v3_small, or :v3_large.

Keyword Arguments

  • pretrained::Bool=false: If true, loads pretrained weights when LuxCore.setup is called.
source
Boltz.Vision.ResNet Function
julia
ResNet(depth::Int; pretrained::Bool=false)

Create a ResNet model [13].

Arguments

  • depth::Int: The depth of the ResNet model. Must be one of 18, 34, 50, 101, or 152.

Keyword Arguments

  • pretrained::Bool=false: If true, loads pretrained weights when LuxCore.setup is called.
source
Boltz.Vision.ResNeXt Function
julia
ResNeXt(depth::Int; cardinality=32, base_width=nothing, pretrained::Bool=false)

Create a ResNeXt model [14].

Arguments

  • depth::Int: The depth of the ResNeXt model. Must be one of 50, 101, or 152.

Keyword Arguments

  • pretrained::Bool=false: If true, loads pretrained weights when LuxCore.setup is called.

  • cardinality: The cardinality of the ResNeXt model. Defaults to 32.

  • base_width: The base width of the ResNeXt model. Defaults to 8 for depth 101 and 4 otherwise.

source
Boltz.Vision.SqueezeNet Function
julia
SqueezeNet(; pretrained::Bool=false)

Create a SqueezeNet model [15].

Keyword Arguments

  • pretrained::Bool=false: If true, loads pretrained weights when LuxCore.setup is called.
source
Boltz.Vision.WideResNet Function
julia
WideResNet(depth::Int; pretrained::Bool=false)

Create a WideResNet model [16].

Arguments

  • depth::Int: The depth of the WideResNet model. Must be one of 18, 34, 50, 101, or 152.

Keyword Arguments

  • pretrained::Bool=false: If true, loads pretrained weights when LuxCore.setup is called.
source

Pretrained Models (ImageNet1K)

Load Pretrained Weights

Pass pretrained=true to the model constructor to load the pretrained weights.

MODELAdditional PackagesTOP 1 ACCURACY (%)TOP 5 ACCURACY (%)
AlexNet()JLD254.4877.72
VGG(11)JLD267.3587.91
VGG(13)JLD268.4088.48
VGG(16)JLD270.2489.80
VGG(19)JLD271.0990.27
VGG(11; batchnorm=true)JLD269.0988.94
VGG(13; batchnorm=true)JLD269.6689.49
VGG(16; batchnorm=true)JLD272.1191.02
VGG(19; batchnorm=true)JLD272.9591.32
EfficientNet(:b0)Pickle--
EfficientNet(:b1)Pickle--
EfficientNet(:b2)Pickle--
EfficientNet(:b3)Pickle--
EfficientNet(:b4)Pickle--
EfficientNet(:b5)Pickle--
EfficientNet(:b6)Pickle--
EfficientNet(:b7)Pickle--
ResNet(18)JLD2, Metalhead--
ResNet(34)JLD2, Metalhead--
ResNet(50)JLD2, Metalhead--
ResNet(101)JLD2, Metalhead--
ResNet(152)JLD2, Metalhead--
ResNeXt(50; cardinality=32, base_width=4)JLD2, Metalhead--
ResNeXt(101; cardinality=32, base_width=8)JLD2, Metalhead--
ResNeXt(101; cardinality=64, base_width=4)JLD2, Metalhead--
SqueezeNet()JLD2, Metalhead--
WideResNet(50)JLD2, Metalhead--
WideResNet(101)JLD2, Metalhead--

Pretrained Models from Metalhead

For Models imported from Metalhead, the pretrained weights can be loaded if they are available in Metalhead. Refer to the Metalhead.jl docs for a list of available pretrained models.

Preprocessing

All the pretrained models require that the images be normalized with the parameters mean = [0.485f0, 0.456f0, 0.406f0] and std = [0.229f0, 0.224f0, 0.225f0].