opensi·si

timm/models/fastvit.py ·

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

  • FastViT: A Fast Hybrid Vision Transformer using Structural Reparameterization
  • MobileCLIP: Fast Image-Text Models through Multi-Modal Reinforced Training
  • MobileCLIP2: Improving Multi-Modal Reinforced Training

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

Feature FastVit
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

Table (13 rows)
Architecture Params (M) GMACs Input size Pretrained weights
fastvit_ma36 43.98 7.82 256 2
fastvit_mci0 11.36 2.39 256 2
fastvit_mci1 21.46 4.67 256 1
fastvit_mci2 35.70 7.85 256 2
fastvit_mci3 125.07 14.82 256 1
fastvit_mci4 321.57 27.78 256 1
fastvit_s12 9.43 1.80 256 2
fastvit_sa12 11.55 1.94 256 2
fastvit_sa24 21.50 3.77 256 2
fastvit_sa36 31.46 5.59 256 2
fastvit_t8 4.00 0.69 256 2
fastvit_t12 7.51 1.39 256 2

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

Table (19 rows)
Weight Input size Top-1 (%) Eval size Classes License Hub
fastvit_ma36.apple_dist_in1k 256 84.608 256 1000 fastvit-license timm
fastvit_ma36.apple_in1k 256 83.884 256 1000 fastvit-license timm
fastvit_mci0.apple_mclip2_dfndr2b 256 - - 512 apple-amlr timm
fastvit_mci2.apple_mclip2_dfndr2b 256 - - 512 apple-amlr timm
fastvit_mci3.apple_mclip2_dfndr2b 256 - - 768 apple-amlr timm
fastvit_mci4.apple_mclip2_dfndr2b 256 - - 768 apple-amlr timm
fastvit_s12.apple_dist_in1k 256 81.074 256 1000 fastvit-license timm
fastvit_s12.apple_in1k 256 79.882 256 1000 fastvit-license timm
fastvit_sa12.apple_dist_in1k 256 81.838 256 1000 fastvit-license timm
fastvit_sa12.apple_in1k 256 80.846 256 1000 fastvit-license timm
fastvit_sa24.apple_dist_in1k 256 83.368 256 1000 fastvit-license timm
fastvit_sa24.apple_in1k 256 82.706 256 1000 fastvit-license timm
fastvit_sa36.apple_dist_in1k 256 84.028 256 1000 fastvit-license timm
fastvit_sa36.apple_in1k 256 83.502 256 1000 fastvit-license timm
fastvit_t8.apple_dist_in1k 256 77.170 256 1000 fastvit-license timm
fastvit_t8.apple_in1k 256 76.184 256 1000 fastvit-license timm
fastvit_t12.apple_dist_in1k 256 80.364 256 1000 fastvit-license timm
fastvit_t12.apple_in1k 256 79.276 256 1000 fastvit-license timm

apple

Hosted by apple on the Hugging Face Hub.

Weight Input size Top-1 (%) Eval size Classes License Hub
fastvit_mci0.apple_mclip 256 - - 512 apple-amlr apple/mobileclip_s0_timm
fastvit_mci1.apple_mclip 256 - - 512 apple-amlr apple/mobileclip_s1_timm
fastvit_mci2.apple_mclip 256 - - 512 apple-amlr apple/mobileclip_s2_timm

Source and license

Source: timm documentation, adapted for this site. Licensing and attribution follow the terms of the upstream project.