timm documentation

MobileViT

Hugging Face's logo
Join the Hugging Face community

and get access to the augmented documentation experience

to get started

MobileViT

Category: Efficient/Mobile · Code: timm/models/mobilevit.py · Architectures: 10 · Pretrained weights: 16 (16 with ImageNet-1k results)

MobileViT combines MobileNet-V2 inverted residual blocks with MobileViT blocks, which apply transformers to unfolded patches for global processing. MobileViT-V2 uses separable self-attention. Built on the ByobNet class.

Papers

Usage

See the Quickstart for loading pretrained weights, image preprocessing and fine-tuning, and Feature Extraction for using the models as backbones.

>>> import timm
>>> model = timm.create_model('mobilevitv2_200.cvnets_in1k', pretrained=True)
>>> data_config = timm.data.resolve_model_data_config(model)

Model API support

FeatureByobNet
features_only=True feature maps✓ (strides 2, 4, 8, 16, 32)
forward_intermediates()✓
prune_intermediate_layers()✓
Any input size, no changes needed✓
set_input_size()–
dynamic_img_size=True–
set_grad_checkpointing()✓
Layer-wise LR decay (group_matcher())✓
reset_classifier()✓

✓ supported, ✓ (square) works for square sizes only, ✗ not supported, – not needed (the model already accepts any input size). Checked by running each feature on a randomly initialized model (ByobNet with mobilevit_xxs at 256), other architectures of the same class are expected to behave the same. See the Model API page for details.

Architectures

ArchitectureParams (M)GMACsInput sizePretrained weights
mobilevit_s5.582.032561
mobilevit_xs2.321.052561
mobilevit_xxs1.270.422561
mobilevitv2_0501.370.482561
mobilevitv2_0752.871.052561
mobilevitv2_1004.901.842561
mobilevitv2_1257.482.862561
mobilevitv2_15010.594.092563
mobilevitv2_17514.255.542563
mobilevitv2_20018.457.222563

GMACs and parameter counts are for the default input size and classifier of each architecture, from the benchmark results.

Pretrained weights

Top-1 is ImageNet-1k validation accuracy from results-imagenet.csv at the listed eval size, - if the weight has no ImageNet-1k result (e.g. pretraining or image-text weights). Classes is the size of the pretrained classifier, none for weights without one.

WeightInput sizeTop-1 (%)Eval sizeClassesLicenseHub
mobilevit_s.cvnets_in1k25678.2982561000cvnets-licensetimm
mobilevit_xs.cvnets_in1k25674.6182561000cvnets-licensetimm
mobilevit_xxs.cvnets_in1k25668.9362561000cvnets-licensetimm
mobilevitv2_050.cvnets_in1k25670.1562561000cvnets-licensetimm
mobilevitv2_075.cvnets_in1k25675.6122561000cvnets-licensetimm
mobilevitv2_100.cvnets_in1k25678.0882561000cvnets-licensetimm
mobilevitv2_125.cvnets_in1k25679.6822561000cvnets-licensetimm
mobilevitv2_150.cvnets_in1k25680.3802561000cvnets-licensetimm
mobilevitv2_150.cvnets_in22k_ft_in1k25681.4662561000cvnets-licensetimm
mobilevitv2_150.cvnets_in22k_ft_in1k_38438482.6063841000cvnets-licensetimm
mobilevitv2_175.cvnets_in1k25680.8702561000cvnets-licensetimm
mobilevitv2_175.cvnets_in22k_ft_in1k25681.9502561000cvnets-licensetimm
mobilevitv2_175.cvnets_in22k_ft_in1k_38438482.9203841000cvnets-licensetimm
mobilevitv2_200.cvnets_in1k25681.1482561000cvnets-licensetimm
mobilevitv2_200.cvnets_in22k_ft_in1k25682.3202561000cvnets-licensetimm
mobilevitv2_200.cvnets_in22k_ft_in1k_38438483.4303841000cvnets-licensetimm
Update on GitHub