timm documentation

XCiT

Hugging Face's logo
Join the Hugging Face community

and get access to the augmented documentation experience

to get started

XCiT

Category: ViT · Code: timm/models/xcit.py · Architectures: 28 · Pretrained weights: 42 (42 with ImageNet-1k results)

Cross-Covariance Image Transformers (XCiT) replace token self-attention with cross-covariance attention across feature channels, linear in the number of tokens, and add local patch interaction layers.

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

Model API support

FeatureXcit
features_only=True feature maps✓ (strides 8, 8, 8)
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 (Xcit with xcit_nano_12_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
xcit_large_24_p8_224188.93141.232242
xcit_large_24_p8_384188.93415.003841
xcit_large_24_p16_224189.1035.862242
xcit_large_24_p16_384189.10105.353841
xcit_medium_24_p8_22484.3263.532242
xcit_medium_24_p8_38484.32186.673841
xcit_medium_24_p16_22484.4016.132242
xcit_medium_24_p16_38484.4047.393841
xcit_nano_12_p8_2243.052.162242
xcit_nano_12_p8_3843.056.343841
xcit_nano_12_p16_2243.050.562242
xcit_nano_12_p16_3843.051.643841
xcit_small_12_p8_22426.2118.692242
xcit_small_12_p8_38426.2154.923841
xcit_small_12_p16_22426.254.822242
xcit_small_12_p16_38426.2514.143841
xcit_small_24_p8_22447.6335.812242
xcit_small_24_p8_38447.63105.243841
xcit_small_24_p16_22447.679.102242
xcit_small_24_p16_38447.6726.723841
xcit_tiny_12_p8_2246.714.812242
xcit_tiny_12_p8_3846.7114.133841
xcit_tiny_12_p16_2246.721.242242
xcit_tiny_12_p16_3846.723.643841
xcit_tiny_24_p8_22412.119.212242
xcit_tiny_24_p8_38412.1127.053841
xcit_tiny_24_p16_22412.122.342242
xcit_tiny_24_p16_38412.126.873841

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
xcit_large_24_p8_224.fb_dist_in1k22485.3962241000apache-2.0timm
xcit_large_24_p8_224.fb_in1k22484.3802241000apache-2.0timm
xcit_large_24_p8_384.fb_dist_in1k38486.0243841000apache-2.0timm
xcit_large_24_p16_224.fb_dist_in1k22484.9362241000apache-2.0timm
xcit_large_24_p16_224.fb_in1k22482.8862241000apache-2.0timm
xcit_large_24_p16_384.fb_dist_in1k38485.7783841000apache-2.0timm
xcit_medium_24_p8_224.fb_dist_in1k22485.0782241000apache-2.0timm
xcit_medium_24_p8_224.fb_in1k22483.7442241000apache-2.0timm
xcit_medium_24_p8_384.fb_dist_in1k38485.8423841000apache-2.0timm
xcit_medium_24_p16_224.fb_dist_in1k22484.2922241000apache-2.0timm
xcit_medium_24_p16_224.fb_in1k22482.6302241000apache-2.0timm
xcit_medium_24_p16_384.fb_dist_in1k38485.4343841000apache-2.0timm
xcit_nano_12_p8_224.fb_dist_in1k22476.3302241000apache-2.0timm
xcit_nano_12_p8_224.fb_in1k22473.9002241000apache-2.0timm
xcit_nano_12_p8_384.fb_dist_in1k38477.8103841000apache-2.0timm
xcit_nano_12_p16_224.fb_dist_in1k22472.3182241000apache-2.0timm
xcit_nano_12_p16_224.fb_in1k22469.9822241000apache-2.0timm
xcit_nano_12_p16_384.fb_dist_in1k38475.4603841000apache-2.0timm
xcit_small_12_p8_224.fb_dist_in1k22484.2522241000apache-2.0timm
xcit_small_12_p8_224.fb_in1k22483.3542241000apache-2.0timm
xcit_small_12_p8_384.fb_dist_in1k38485.0683841000apache-2.0timm
xcit_small_12_p16_224.fb_dist_in1k22483.3542241000apache-2.0timm
xcit_small_12_p16_224.fb_in1k22481.9822241000apache-2.0timm
xcit_small_12_p16_384.fb_dist_in1k38484.7343841000apache-2.0timm
xcit_small_24_p8_224.fb_dist_in1k22484.8782241000apache-2.0timm
xcit_small_24_p8_224.fb_in1k22483.8542241000apache-2.0timm
xcit_small_24_p8_384.fb_dist_in1k38485.5803841000apache-2.0timm
xcit_small_24_p16_224.fb_dist_in1k22483.8802241000apache-2.0timm
xcit_small_24_p16_224.fb_in1k22482.5882241000apache-2.0timm
xcit_small_24_p16_384.fb_dist_in1k38485.1023841000apache-2.0timm
xcit_tiny_12_p8_224.fb_dist_in1k22481.2142241000apache-2.0timm
xcit_tiny_12_p8_224.fb_in1k22479.7102241000apache-2.0timm
xcit_tiny_12_p8_384.fb_dist_in1k38482.3943841000apache-2.0timm
xcit_tiny_12_p16_224.fb_dist_in1k22478.5722241000apache-2.0timm
xcit_tiny_12_p16_224.fb_in1k22477.1222241000apache-2.0timm
xcit_tiny_12_p16_384.fb_dist_in1k38480.9543841000apache-2.0timm
xcit_tiny_24_p8_224.fb_dist_in1k22482.5782241000apache-2.0timm
xcit_tiny_24_p8_224.fb_in1k22481.8882241000apache-2.0timm
xcit_tiny_24_p8_384.fb_dist_in1k38483.7843841000apache-2.0timm
xcit_tiny_24_p16_224.fb_dist_in1k22480.4622241000apache-2.0timm
xcit_tiny_24_p16_224.fb_in1k22479.4742241000apache-2.0timm
xcit_tiny_24_p16_384.fb_dist_in1k38482.5803841000apache-2.0timm
Update on GitHub