timm documentation

FastViT

You are viewing main version, which requires installation from source. If you'd like regular pip install, checkout the latest stable version (v1.0.30).
Hugging Face's logo
Join the Hugging Face community

and get access to the augmented documentation experience

to get started

FastViT

Category: Efficient/Mobile · Code: timm/models/fastvit.py · Architectures: 12 · Pretrained weights: 21 (14 with ImageNet-1k results)

FastViT is a hybrid convolutional / transformer network that uses structural reparameterization to remove skip connections at inference. The module also includes the MobileCLIP image encoders (fastvit_mci*).

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('fastvit_sa24.apple_dist_in1k', pretrained=True)
>>> data_config = timm.data.resolve_model_data_config(model)

Model API support

FeatureFastVit
features_only=True feature maps✓ (strides 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 (FastVit with fastvit_t8 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
fastvit_ma3643.987.822562
fastvit_mci011.362.392562
fastvit_mci121.464.672561
fastvit_mci235.707.852562
fastvit_mci3125.0714.822561
fastvit_mci4321.5727.782561
fastvit_s129.431.802562
fastvit_sa1211.551.942562
fastvit_sa2421.503.772562
fastvit_sa3631.465.592562
fastvit_t84.000.692562
fastvit_t127.511.392562

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.

Weights are grouped by source: the paper or origin given in the pretrained config, else a Hub organization other than timm, else the first part of the pretrained tag (architecture.tag). Sources with a single weight are listed under other.

apple tags

WeightInput sizeTop-1 (%)Eval sizeClassesLicenseHub
fastvit_ma36.apple_dist_in1k25684.6082561000fastvit-licensetimm
fastvit_ma36.apple_in1k25683.8842561000fastvit-licensetimm
fastvit_mci0.apple_mclip2_dfndr2b256--512apple-amlrtimm
fastvit_mci2.apple_mclip2_dfndr2b256--512apple-amlrtimm
fastvit_mci3.apple_mclip2_dfndr2b256--768apple-amlrtimm
fastvit_mci4.apple_mclip2_dfndr2b256--768apple-amlrtimm
fastvit_s12.apple_dist_in1k25681.0742561000fastvit-licensetimm
fastvit_s12.apple_in1k25679.8822561000fastvit-licensetimm
fastvit_sa12.apple_dist_in1k25681.8382561000fastvit-licensetimm
fastvit_sa12.apple_in1k25680.8462561000fastvit-licensetimm
fastvit_sa24.apple_dist_in1k25683.3682561000fastvit-licensetimm
fastvit_sa24.apple_in1k25682.7062561000fastvit-licensetimm
fastvit_sa36.apple_dist_in1k25684.0282561000fastvit-licensetimm
fastvit_sa36.apple_in1k25683.5022561000fastvit-licensetimm
fastvit_t8.apple_dist_in1k25677.1702561000fastvit-licensetimm
fastvit_t8.apple_in1k25676.1842561000fastvit-licensetimm
fastvit_t12.apple_dist_in1k25680.3642561000fastvit-licensetimm
fastvit_t12.apple_in1k25679.2762561000fastvit-licensetimm

apple

Hosted by apple on the Hugging Face Hub.

WeightInput sizeTop-1 (%)Eval sizeClassesLicenseHub
fastvit_mci0.apple_mclip256--512apple-amlrapple/mobileclip_s0_timm
fastvit_mci1.apple_mclip256--512apple-amlrapple/mobileclip_s1_timm
fastvit_mci2.apple_mclip256--512apple-amlrapple/mobileclip_s2_timm
Update on GitHub