Computer Vision Models (Vision API)
Native Lux Models
Boltz.Vision.AlexNet Type
AlexNet(; pretrained=false)Create an AlexNet model [6].
Keyword Arguments
pretrained: Valid Options arefalse,true,:DEFAULT,:ImageNet1Kor:ImageNet1K_V1.:DEFAULT,trueand:ImageNet1Kweights currently corresponds to:ImageNet1K_V1.
Boltz.Vision.EfficientNet Type
EfficientNet(variant::Union{String,Symbol}; pretrained::Bool=false, in_channels::Int=3,
nclasses::Int=1000)Create an EfficientNet model [7].
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: Iftrue, loads pretrained weights whenLuxCore.setupis called.in_channels::Int=3: The number of input channels. (Must be3for pretrained models.)nclasses::Int=1000: The number of output classes. (Must be1000for pretrained models.)
Boltz.Vision.VGG Type
VGG(imsize; config, inchannels, batchnorm = false, nclasses, fcsize, dropout)Create a VGG model [8].
Arguments
imsize: input image width and height as a tupleconfig: the configuration for the convolution layersinchannels: number of input channelsbatchnorm: set totrueto use batch normalization after each convolutionnclasses: number of output classesfcsize: intermediate fully connected layer sizedropout: dropout level between fully connected layers
VGG(depth::Int; batchnorm::Bool=false, pretrained::Bool=false)Create a VGG model [8] with ImageNet Configuration.
Arguments
depth::Int: the depth of the VGG model. Choices: {11,13,16,19}.
Keyword Arguments
batchnorm = false: set totrueto use batch normalization after each convolution.pretrained::Bool=false: Iftrue, loads pretrained weights whenLuxCore.setupis called.
Boltz.Vision.VisionTransformer Type
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: Iftrue, loads pretrained weights whenLuxCore.setupis called.
Imported from Metalhead.jl
Load Metalhead
You need to load Metalhead before using these models.
Boltz.Vision.ConvMixer Function
ConvMixer(name::Symbol; pretrained::Bool=false)Create a ConvMixer model [9].
Arguments
name::Symbol: The name of the ConvMixer model. Must be one of:base,:small, or:large.
Keyword Arguments
pretrained::Bool=false: Iftrue, loads pretrained weights whenLuxCore.setupis called.
Boltz.Vision.DenseNet Function
DenseNet(depth::Int; pretrained::Bool=false)Create a DenseNet model [10].
Arguments
depth::Int: The depth of the DenseNet model. Must be one of 121, 161, 169, or 201.
Keyword Arguments
pretrained::Bool=false: Iftrue, loads pretrained weights whenLuxCore.setupis called.
Boltz.Vision.GoogLeNet Function
GoogLeNet(; pretrained::Bool=false)Create a GoogLeNet model [11].
Keyword Arguments
pretrained::Bool=false: Iftrue, loads pretrained weights whenLuxCore.setupis called.
Boltz.Vision.MobileNet Function
MobileNet(name::Symbol; pretrained::Bool=false)Create a MobileNet model [12–14].
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: Iftrue, loads pretrained weights whenLuxCore.setupis called.
Boltz.Vision.ResNet Function
ResNet(depth::Int; pretrained::Bool=false)Create a ResNet model [15].
Arguments
depth::Int: The depth of the ResNet model. Must be one of 18, 34, 50, 101, or 152.
Keyword Arguments
pretrained::Bool=false: Iftrue, loads pretrained weights whenLuxCore.setupis called.
Boltz.Vision.ResNeXt Function
ResNeXt(depth::Int; cardinality=32, base_width=nothing, pretrained::Bool=false)Create a ResNeXt model [16].
Arguments
depth::Int: The depth of the ResNeXt model. Must be one of 50, 101, or 152.
Keyword Arguments
pretrained::Bool=false: Iftrue, loads pretrained weights whenLuxCore.setupis 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.
Boltz.Vision.SqueezeNet Function
SqueezeNet(; pretrained::Bool=false)Create a SqueezeNet model [17].
Keyword Arguments
pretrained::Bool=false: Iftrue, loads pretrained weights whenLuxCore.setupis called.
Boltz.Vision.WideResNet Function
WideResNet(depth::Int; pretrained::Bool=false)Create a WideResNet model [18].
Arguments
depth::Int: The depth of the WideResNet model. Must be one of 18, 34, 50, 101, or 152.
Keyword Arguments
pretrained::Bool=false: Iftrue, loads pretrained weights whenLuxCore.setupis called.
Pretrained Models (ImageNet1K)
Load Pretrained Weights
Pass pretrained=true to the model constructor to load the pretrained weights.
| MODEL | Additional Packages | TOP 1 ACCURACY (%) | TOP 5 ACCURACY (%) |
|---|---|---|---|
AlexNet() | JLD2 | 54.48 | 77.72 |
VGG(11) | JLD2 | 67.35 | 87.91 |
VGG(13) | JLD2 | 68.40 | 88.48 |
VGG(16) | JLD2 | 70.24 | 89.80 |
VGG(19) | JLD2 | 71.09 | 90.27 |
VGG(11; batchnorm=true) | JLD2 | 69.09 | 88.94 |
VGG(13; batchnorm=true) | JLD2 | 69.66 | 89.49 |
VGG(16; batchnorm=true) | JLD2 | 72.11 | 91.02 |
VGG(19; batchnorm=true) | JLD2 | 72.95 | 91.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].