timm documentation

DeiT

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

DeiT

Category: ViT Β· Code: timm/models/deit.py Β· Architectures: 16 Β· Pretrained weights: 24 (24 with ImageNet-1k results)

Data-efficient Image Transformers (DeiT) are Vision Transformers trained on ImageNet-1k only, optionally with a distillation token that learns from a CNN teacher. DeiT III models are trained with an improved recipe.

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

Model API support

FeatureVisionTransformerVisionTransformerDistilled
features_only=True feature mapsβœ“ (strides 16, 16, 16)βœ“ (strides 16, 16, 16)
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 deit_tiny_patch16_224 at 224, VisionTransformerDistilled with deit_tiny_distilled_patch16_224 at 224), other architectures of the same class are expected to behave the same. See the Model API page for details.

Architectures

ArchitectureClassParams (M)GMACsInput sizePretrained weights
deit3_base_patch16_224VisionTransformer86.5917.582242
deit3_base_patch16_384VisionTransformer86.8855.543842
deit3_huge_patch14_224VisionTransformer632.13167.402242
deit3_large_patch16_224VisionTransformer304.3761.602242
deit3_large_patch16_384VisionTransformer304.76191.213842
deit3_medium_patch16_224VisionTransformer38.858.002242
deit3_small_patch16_224VisionTransformer22.064.612242
deit3_small_patch16_384VisionTransformer22.2115.523842
deit_base_distilled_patch16_224VisionTransformerDistilled87.3417.682241
deit_base_distilled_patch16_384VisionTransformerDistilled87.6355.653841
deit_base_patch16_224VisionTransformer86.5717.582241
deit_base_patch16_384VisionTransformer86.8655.543841
deit_small_distilled_patch16_224VisionTransformerDistilled22.444.632241
deit_small_patch16_224VisionTransformer22.054.612241
deit_tiny_distilled_patch16_224VisionTransformerDistilled5.911.272241
deit_tiny_patch16_224VisionTransformer5.721.262241

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.

WeightInput sizeTop-1 (%)Eval sizeClassesLicenseHub
deit3_base_patch16_224.fb_in1k22483.8002241000apache-2.0timm
deit3_base_patch16_224.fb_in22k_ft_in1k22485.7282241000apache-2.0timm
deit3_base_patch16_384.fb_in1k38485.0883841000apache-2.0timm
deit3_base_patch16_384.fb_in22k_ft_in1k38486.7423841000apache-2.0timm
deit3_huge_patch14_224.fb_in1k22485.2042241000apache-2.0timm
deit3_huge_patch14_224.fb_in22k_ft_in1k22487.1802241000apache-2.0timm
deit3_large_patch16_224.fb_in1k22484.7722241000apache-2.0timm
deit3_large_patch16_224.fb_in22k_ft_in1k22486.9902241000apache-2.0timm
deit3_large_patch16_384.fb_in1k38485.8203841000apache-2.0timm
deit3_large_patch16_384.fb_in22k_ft_in1k38487.7363841000apache-2.0timm
deit3_medium_patch16_224.fb_in1k22483.0902241000apache-2.0timm
deit3_medium_patch16_224.fb_in22k_ft_in1k22484.5502241000apache-2.0timm
deit3_small_patch16_224.fb_in1k22481.3822241000apache-2.0timm
deit3_small_patch16_224.fb_in22k_ft_in1k22483.0822241000apache-2.0timm
deit3_small_patch16_384.fb_in1k38483.4323841000apache-2.0timm
deit3_small_patch16_384.fb_in22k_ft_in1k38484.8463841000apache-2.0timm
deit_base_distilled_patch16_224.fb_in1k22483.3842241000apache-2.0timm
deit_base_distilled_patch16_384.fb_in1k38485.4383841000apache-2.0timm
deit_base_patch16_224.fb_in1k22481.9802241000apache-2.0timm
deit_base_patch16_384.fb_in1k38483.1083841000apache-2.0timm
deit_small_distilled_patch16_224.fb_in1k22481.2042241000apache-2.0timm
deit_small_patch16_224.fb_in1k22479.8562241000apache-2.0timm
deit_tiny_distilled_patch16_224.fb_in1k22474.5382241000apache-2.0timm
deit_tiny_patch16_224.fb_in1k22472.1902241000apache-2.0timm
Update on GitHub