# EfficientViT (MIT)

**Category:** Efficient/Mobile · **Code:**
[`timm/models/efficientvit_mit.py`](https://github.com/huggingface/pytorch-image-models/blob/main/timm/models/efficientvit_mit.py)
· **Architectures:** 7 · **Pretrained weights:** 19 (19 with ImageNet-1k results)

EfficientViT from the MIT Han Lab, a vision backbone for high-resolution, low-computation recognition that uses
multi-scale linear attention.

## Papers

* [EfficientViT: Multi-Scale Linear Attention for High-Resolution Dense Prediction](https://arxiv.org/abs/2205.14756)

## Usage

See the [Quickstart](../quickstart) for loading pretrained weights, image preprocessing and fine-tuning, and [Feature
Extraction](../feature_extraction) for using the models as backbones.

```py
>>> import timm
>>> model = timm.create_model('efficientvit_b2.r224_in1k', pretrained=True)
>>> data_config = timm.data.resolve_model_data_config(model)
```

## Model API support

| Feature | `EfficientVit` | `EfficientVitLarge` |
|---|---|---|
| [`features_only=True` feature maps](../model_api#intermediate-features) | ✓ (strides 4, 8, 16, 32) | ✓ (strides 4, 8, 16, 32) |
| [`forward_intermediates()`](../model_api#intermediate-features) | ✓ | ✓ |
| [`prune_intermediate_layers()`](../model_api#intermediate-features) | ✓ | ✓ |
| [Any input size, no changes needed](../model_api#input-size) | ✓ | ✓ |
| [`set_input_size()`](../model_api#input-size) | – | – |
| [`dynamic_img_size=True`](../model_api#input-size) | – | – |
| [`set_grad_checkpointing()`](../model_api#training-hooks) | ✓ | ✓ |
| [Layer-wise LR decay (`group_matcher()`)](../model_api#training-hooks) | ✓ | ✓ |
| [`reset_classifier()`](../model_api#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 (`EfficientVit` with `efficientvit_b0` at 224,
`EfficientVitLarge` with `efficientvit_l1` at 224), other architectures of the same class are expected to behave the
same. See the [Model API](../model_api) page for details.

## Architectures

| Architecture | Class | Params (M) | GMACs | Input size | Pretrained weights |
|---|---|---:|---:|---:|---:|
| `efficientvit_b0` | `EfficientVit` | 3.41 | 0.10 | 224 | 1 |
| `efficientvit_b1` | `EfficientVit` | 9.10 | 0.53 | 224 | 3 |
| `efficientvit_b2` | `EfficientVit` | 24.33 | 1.60 | 224 | 3 |
| `efficientvit_b3` | `EfficientVit` | 48.65 | 3.99 | 224 | 3 |
| `efficientvit_l1` | `EfficientVitLarge` | 52.65 | 5.27 | 224 | 1 |
| `efficientvit_l2` | `EfficientVitLarge` | 63.71 | 6.97 | 224 | 4 |
| `efficientvit_l3` | `EfficientVitLarge` | 246.04 | 27.62 | 224 | 4 |

GMACs and parameter counts are for the default input size and classifier of each architecture, from the [benchmark
results](https://github.com/huggingface/pytorch-image-models/tree/main/results).

## Pretrained weights

Top-1 is ImageNet-1k validation accuracy from
[`results-imagenet.csv`](https://github.com/huggingface/pytorch-image-models/blob/main/results/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.

| Weight | Input size | Top-1 (%) | Eval size | Classes | License | Hub |
|---|---:|---:|---:|---:|---|---|
| `efficientvit_b0.r224_in1k` | 224 | 71.408 | 224 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/efficientvit_b0.r224_in1k) |
| `efficientvit_b1.r224_in1k` | 224 | 79.254 | 224 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/efficientvit_b1.r224_in1k) |
| `efficientvit_b1.r256_in1k` | 256 | 79.734 | 256 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/efficientvit_b1.r256_in1k) |
| `efficientvit_b1.r288_in1k` | 288 | 80.322 | 288 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/efficientvit_b1.r288_in1k) |
| `efficientvit_b2.r224_in1k` | 224 | 82.162 | 224 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/efficientvit_b2.r224_in1k) |
| `efficientvit_b2.r256_in1k` | 256 | 82.712 | 256 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/efficientvit_b2.r256_in1k) |
| `efficientvit_b2.r288_in1k` | 288 | 83.078 | 288 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/efficientvit_b2.r288_in1k) |
| `efficientvit_b3.r224_in1k` | 224 | 83.444 | 224 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/efficientvit_b3.r224_in1k) |
| `efficientvit_b3.r256_in1k` | 256 | 83.782 | 256 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/efficientvit_b3.r256_in1k) |
| `efficientvit_b3.r288_in1k` | 288 | 84.162 | 288 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/efficientvit_b3.r288_in1k) |
| `efficientvit_l1.r224_in1k` | 224 | 84.464 | 224 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/efficientvit_l1.r224_in1k) |
| `efficientvit_l2.r224_in1k` | 224 | 85.046 | 224 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/efficientvit_l2.r224_in1k) |
| `efficientvit_l2.r256_in1k` | 256 | 85.380 | 256 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/efficientvit_l2.r256_in1k) |
| `efficientvit_l2.r288_in1k` | 288 | 85.614 | 288 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/efficientvit_l2.r288_in1k) |
| `efficientvit_l2.r384_in1k` | 384 | 85.984 | 384 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/efficientvit_l2.r384_in1k) |
| `efficientvit_l3.r224_in1k` | 224 | 85.810 | 224 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/efficientvit_l3.r224_in1k) |
| `efficientvit_l3.r256_in1k` | 256 | 85.952 | 256 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/efficientvit_l3.r256_in1k) |
| `efficientvit_l3.r320_in1k` | 320 | 86.230 | 320 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/efficientvit_l3.r320_in1k) |
| `efficientvit_l3.r384_in1k` | 384 | 86.396 | 384 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/efficientvit_l3.r384_in1k) |

