opensi·si

timm/models/repvit.py ·

RepViT

Category: Efficient/Mobile · Code: timm/models/repvit.py · Architectures: 8 · Pretrained weights: 13 (13 with ImageNet-1k results)

RepViT is a mobile CNN that brings design choices of lightweight vision transformers into MobileNet-V3 style blocks, with structural re-parameterization.

Papers

  • RepViT: Revisiting Mobile CNN From ViT Perspective

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

Model API support

Feature RepVit
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 (RepVit with repvit_m1 at 224), other architectures of the same class are expected to behave the same. See the Model API page for details.

Architectures

Architecture Params (M) GMACs Input size Pretrained weights
repvit_m0_9 5.07 0.82 224 2
repvit_m1 5.07 0.82 224 1
repvit_m1_0 6.81 1.11 224 2
repvit_m1_1 8.24 1.34 224 2
repvit_m1_5 14.05 2.27 224 2
repvit_m2 8.24 1.34 224 1
repvit_m2_3 22.93 4.52 224 2
repvit_m3 10.12 1.86 224 1

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.

Tabla (14 filas)
Weight Input size Top-1 (%) Eval size Classes License Hub
repvit_m0_9.dist_300e_in1k 224 78.652 224 1000 apache-2.0 timm
repvit_m0_9.dist_450e_in1k 224 79.058 224 1000 apache-2.0 timm
repvit_m1.dist_in1k 224 78.542 224 1000 apache-2.0 timm
repvit_m1_0.dist_300e_in1k 224 80.152 224 1000 apache-2.0 timm
repvit_m1_0.dist_450e_in1k 224 80.430 224 1000 apache-2.0 timm
repvit_m1_1.dist_300e_in1k 224 80.826 224 1000 apache-2.0 timm
repvit_m1_1.dist_450e_in1k 224 81.314 224 1000 apache-2.0 timm
repvit_m1_5.dist_300e_in1k 224 82.382 224 1000 apache-2.0 timm
repvit_m1_5.dist_450e_in1k 224 82.520 224 1000 apache-2.0 timm
repvit_m2.dist_in1k 224 80.468 224 1000 apache-2.0 timm
repvit_m2_3.dist_300e_in1k 224 83.524 224 1000 apache-2.0 timm
repvit_m2_3.dist_450e_in1k 224 83.746 224 1000 apache-2.0 timm
repvit_m3.dist_in1k 224 81.494 224 1000 apache-2.0 timm

Citation

@misc{wang2023repvit,
      title={RepViT: Revisiting Mobile CNN From ViT Perspective},
      author={Ao Wang and Hui Chen and Zijia Lin and Hengjun Pu and Guiguang Ding},
      year={2023},
      eprint={2307.09283},
      archivePrefix={arXiv},
      primaryClass={cs.CV}
}

Source and license

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