timm documentation

Hybrid Vision Transformer

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

Hybrid Vision Transformer

Category: Hybrid · Code: timm/models/vision_transformer_hybrid.py · Architectures: 14 · Pretrained weights: 14 (7 with ImageNet-1k results)

Vision Transformers whose patch tokens come from a convolutional backbone (ResNet / ResNetV2 stem or stages) instead of a linear patch embedding, using the VisionTransformer 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('vit_small_r26_s32_224.augreg_in21k_ft_in1k', pretrained=True)
>>> data_config = timm.data.resolve_model_data_config(model)

Model API support

FeatureVisionTransformer
features_only=True feature maps✓ (strides 32, 32, 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 (VisionTransformer with vit_tiny_r_s16_p8_224 at 224), 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
vit_base_mci_22486.3517.732243
vit_base_r26_s32_224101.386.812240
vit_base_r50_s16_22497.8921.662241
vit_base_r50_s16_38498.9567.433841
vit_base_resnet26d_224101.406.972240
vit_base_resnet50d_224110.978.732240
vit_large_r50_s32_224328.9919.582242
vit_large_r50_s32_384329.0957.433841
vit_small_r26_s32_22436.433.562242
vit_small_r26_s32_38436.4710.433841
vit_small_resnet26d_22463.615.072240
vit_small_resnet50d_s16_22457.5313.482240
vit_tiny_r_s16_p8_2246.340.442242
vit_tiny_r_s16_p8_3846.361.343841

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.

augreg tags

WeightInput sizeTop-1 (%)Eval sizeClassesLicenseHub
vit_large_r50_s32_224.augreg_in21k224--21843apache-2.0timm
vit_large_r50_s32_224.augreg_in21k_ft_in1k22484.4342241000apache-2.0timm
vit_large_r50_s32_384.augreg_in21k_ft_in1k38486.1883841000apache-2.0timm
vit_small_r26_s32_224.augreg_in21k224--21843apache-2.0timm
vit_small_r26_s32_224.augreg_in21k_ft_in1k22481.8562241000apache-2.0timm
vit_small_r26_s32_384.augreg_in21k_ft_in1k38484.0663841000apache-2.0timm
vit_tiny_r_s16_p8_224.augreg_in21k224--21843apache-2.0timm
vit_tiny_r_s16_p8_224.augreg_in21k_ft_in1k22471.8002241000apache-2.0timm
vit_tiny_r_s16_p8_384.augreg_in21k_ft_in1k38475.9623841000apache-2.0timm

orig tags

WeightInput sizeTop-1 (%)Eval sizeClassesLicenseHub
vit_base_r50_s16_224.orig_in21k224--noneapache-2.0timm
vit_base_r50_s16_384.orig_in21k_ft_in1k38484.9883841000apache-2.0timm

apple

Hosted by apple on the Hugging Face Hub.

WeightInput sizeTop-1 (%)Eval sizeClassesLicenseHub
vit_base_mci_224.apple_mclip224--512apple-amlrapple/mobileclip_b_timm
vit_base_mci_224.apple_mclip_lt224--512apple-amlrapple/mobileclip_b_lt_timm

Other

WeightInput sizeTop-1 (%)Eval sizeClassesLicenseHub
vit_base_mci_224.apple_mclip2_dfndr2b224--512apple-amlrtimm
Update on GitHub