# XCiT

**Categoria:** ViT · **Código:** [`timm/models/xcit.py`](https://github.com/huggingface/pytorch-image-models/blob/main/timm/models/xcit.py) · **Arquiteturas:** 28 · **Pesos pré-treinados:** 42 (42 com resultados no ImageNet-1k)

Os Cross-Covariance Image Transformers (XCiT) substituem a autoatenção de tokens pela atenção de covariância cruzada entre canais de recursos, linear no número de tokens, e adicionam camadas de interação local de patches.

## Artigos

* [XCiT: Cross-Covariance Image Transformers](https://arxiv.org/abs/2106.09681)

## Uso

Veja o [Início rápido](../quickstart) para carregar pesos pré-treinados, pré-processar imagens e fazer fine-tuning, e [Extração de recursos](../feature_extraction) para usar os modelos como backbones.

```py
>>> 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)
```

## Suporte à API de modelos

| Recurso | `Xcit` |
|---|---|
| [mapas de recursos de `features_only=True`](../model_api#intermediate-features) | ✓ (passos 8, 8, 8) |
| [`forward_intermediates()`](../model_api#intermediate-features) | ✓ |
| [`prune_intermediate_layers()`](../model_api#intermediate-features) | ✓ |
| [Qualquer tamanho de entrada, sem necessidade de alterações](../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) | ✓ |
| [Decaimento de LR por camada (`group_matcher()`)](../model_api#training-hooks) | ✓ |
| [`reset_classifier()`](../model_api#classifier) | ✓ |

✓ suportado, ✓ (quadrado) funciona apenas para tamanhos quadrados, ✗ não suportado, – não necessário (o modelo já aceita qualquer tamanho de entrada). Verificado executando cada recurso em um modelo inicializado aleatoriamente (`Xcit` com `xcit_nano_12_p8_224` em 224); espera-se que outras arquiteturas da mesma classe se comportem da mesma forma. Consulte a página [Model API](../model_api) para mais detalhes.

## Arquiteturas

| Arquitetura | Parâmetros (M) | GMACs | Tamanho da entrada | Pesos pré-treinados |
|---|---:|---:|---:|---:|
| `xcit_large_24_p8_224` | 188.93 | 141.23 | 224 | 2 |
| `xcit_large_24_p8_384` | 188.93 | 415.00 | 384 | 1 |
| `xcit_large_24_p16_224` | 189.10 | 35.86 | 224 | 2 |
| `xcit_large_24_p16_384` | 189.10 | 105.35 | 384 | 1 |
| `xcit_medium_24_p8_224` | 84.32 | 63.53 | 224 | 2 |
| `xcit_medium_24_p8_384` | 84.32 | 186.67 | 384 | 1 |
| `xcit_medium_24_p16_224` | 84.40 | 16.13 | 224 | 2 |
| `xcit_medium_24_p16_384` | 84.40 | 47.39 | 384 | 1 |
| `xcit_nano_12_p8_224` | 3.05 | 2.16 | 224 | 2 |
| `xcit_nano_12_p8_384` | 3.05 | 6.34 | 384 | 1 |
| `xcit_nano_12_p16_224` | 3.05 | 0.56 | 224 | 2 |
| `xcit_nano_12_p16_384` | 3.05 | 1.64 | 384 | 1 |
| `xcit_small_12_p8_224` | 26.21 | 18.69 | 224 | 2 |
| `xcit_small_12_p8_384` | 26.21 | 54.92 | 384 | 1 |
| `xcit_small_12_p16_224` | 26.25 | 4.82 | 224 | 2 |
| `xcit_small_12_p16_384` | 26.25 | 14.14 | 384 | 1 |
| `xcit_small_24_p8_224` | 47.63 | 35.81 | 224 | 2 |
| `xcit_small_24_p8_384` | 47.63 | 105.24 | 384 | 1 |
| `xcit_small_24_p16_224` | 47.67 | 9.10 | 224 | 2 |
| `xcit_small_24_p16_384` | 47.67 | 26.72 | 384 | 1 |
| `xcit_tiny_12_p8_224` | 6.71 | 4.81 | 224 | 2 |
| `xcit_tiny_12_p8_384` | 6.71 | 14.13 | 384 | 1 |
| `xcit_tiny_12_p16_224` | 6.72 | 1.24 | 224 | 2 |
| `xcit_tiny_12_p16_384` | 6.72 | 3.64 | 384 | 1 |
| `xcit_tiny_24_p8_224` | 12.11 | 9.21 | 224 | 2 |
| `xcit_tiny_24_p8_384` | 12.11 | 27.05 | 384 | 1 |
| `xcit_tiny_24_p16_224` | 12.12 | 2.34 | 224 | 2 |
| `xcit_tiny_24_p16_384` | 12.12 | 6.87 | 384 | 1 |

Os GMACs e as contagens de parâmetros são para o tamanho de entrada e o classificador padrão de cada arquitetura, a partir dos [resultados do benchmark](https://github.com/huggingface/pytorch-image-models/tree/main/results).

## Pesos pré-treinados

Top-1 é a acurácia de validação no ImageNet-1k a partir de [`results-imagenet.csv`](https://github.com/huggingface/pytorch-image-models/blob/main/results/results-imagenet.csv) no tamanho de avaliação listado, - se o peso não tiver resultado no ImageNet-1k (por exemplo, pesos de pré-treinamento ou de imagem-texto). Classes é o tamanho do classificador pré-treinado, nenhum para pesos sem um.

| Peso | Tamanho da entrada | Top-1 (%) | Tamanho da avaliação | Classes | Licença | Hub |
|---|---:|---:|---:|---:|---|---|
| `xcit_large_24_p8_224.fb_dist_in1k` | 224 | 85.396 | 224 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/xcit_large_24_p8_224.fb_dist_in1k) |
| `xcit_large_24_p8_224.fb_in1k` | 224 | 84.380 | 224 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/xcit_large_24_p8_224.fb_in1k) |
| `xcit_large_24_p8_384.fb_dist_in1k` | 384 | 86.024 | 384 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/xcit_large_24_p8_384.fb_dist_in1k) |
| `xcit_large_24_p16_224.fb_dist_in1k` | 224 | 84.936 | 224 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/xcit_large_24_p16_224.fb_dist_in1k) |
| `xcit_large_24_p16_224.fb_in1k` | 224 | 82.886 | 224 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/xcit_large_24_p16_224.fb_in1k) |
| `xcit_large_24_p16_384.fb_dist_in1k` | 384 | 85.778 | 384 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/xcit_large_24_p16_384.fb_dist_in1k) |
| `xcit_medium_24_p8_224.fb_dist_in1k` | 224 | 85.078 | 224 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/xcit_medium_24_p8_224.fb_dist_in1k) |
| `xcit_medium_24_p8_224.fb_in1k` | 224 | 83.744 | 224 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/xcit_medium_24_p8_224.fb_in1k) |
| `xcit_medium_24_p8_384.fb_dist_in1k` | 384 | 85.842 | 384 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/xcit_medium_24_p8_384.fb_dist_in1k) |
| `xcit_medium_24_p16_224.fb_dist_in1k` | 224 | 84.292 | 224 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/xcit_medium_24_p16_224.fb_dist_in1k) |
| `xcit_medium_24_p16_224.fb_in1k` | 224 | 82.630 | 224 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/xcit_medium_24_p16_224.fb_in1k) |
| `xcit_medium_24_p16_384.fb_dist_in1k` | 384 | 85.434 | 384 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/xcit_medium_24_p16_384.fb_dist_in1k) |
| `xcit_nano_12_p8_224.fb_dist_in1k` | 224 | 76.330 | 224 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/xcit_nano_12_p8_224.fb_dist_in1k) |
| `xcit_nano_12_p8_224.fb_in1k` | 224 | 73.900 | 224 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/xcit_nano_12_p8_224.fb_in1k) |
| `xcit_nano_12_p8_384.fb_dist_in1k` | 384 | 77.810 | 384 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/xcit_nano_12_p8_384.fb_dist_in1k) |
| `xcit_nano_12_p16_224.fb_dist_in1k` | 224 | 72.318 | 224 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/xcit_nano_12_p16_224.fb_dist_in1k) |
| `xcit_nano_12_p16_224.fb_in1k` | 224 | 69.982 | 224 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/xcit_nano_12_p16_224.fb_in1k) |
| `xcit_nano_12_p16_384.fb_dist_in1k` | 384 | 75.460 | 384 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/xcit_nano_12_p16_384.fb_dist_in1k) |
| `xcit_small_12_p8_224.fb_dist_in1k` | 224 | 84.252 | 224 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/xcit_small_12_p8_224.fb_dist_in1k) |
| `xcit_small_12_p8_224.fb_in1k` | 224 | 83.354 | 224 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/xcit_small_12_p8_224.fb_in1k) |
| `xcit_small_12_p8_384.fb_dist_in1k` | 384 | 85.068 | 384 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/xcit_small_12_p8_384.fb_dist_in1k) |
| `xcit_small_12_p16_224.fb_dist_in1k` | 224 | 83.354 | 224 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/xcit_small_12_p16_224.fb_dist_in1k) |
| `xcit_small_12_p16_224.fb_in1k` | 224 | 81.982 | 224 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/xcit_small_12_p16_224.fb_in1k) |
| `xcit_small_12_p16_384.fb_dist_in1k` | 384 | 84.734 | 384 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/xcit_small_12_p16_384.fb_dist_in1k) |
| `xcit_small_24_p8_224.fb_dist_in1k` | 224 | 84.878 | 224 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/xcit_small_24_p8_224.fb_dist_in1k) |
| `xcit_small_24_p8_224.fb_in1k` | 224 | 83.854 | 224 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/xcit_small_24_p8_224.fb_in1k) |
| `xcit_small_24_p8_384.fb_dist_in1k` | 384 | 85.580 | 384 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/xcit_small_24_p8_384.fb_dist_in1k) |
| `xcit_small_24_p16_224.fb_dist_in1k` | 224 | 83.880 | 224 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/xcit_small_24_p16_224.fb_dist_in1k) |
| `xcit_small_24_p16_224.fb_in1k` | 224 | 82.588 | 224 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/xcit_small_24_p16_224.fb_in1k) |
| `xcit_small_24_p16_384.fb_dist_in1k` | 384 | 85.102 | 384 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/xcit_small_24_p16_384.fb_dist_in1k) |
| `xcit_tiny_12_p8_224.fb_dist_in1k` | 224 | 81.214 | 224 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/xcit_tiny_12_p8_224.fb_dist_in1k) |
| `xcit_tiny_12_p8_224.fb_in1k` | 224 | 79.710 | 224 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/xcit_tiny_12_p8_224.fb_in1k) |
| `xcit_tiny_12_p8_384.fb_dist_in1k` | 384 | 82.394 | 384 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/xcit_tiny_12_p8_384.fb_dist_in1k) |
| `xcit_tiny_12_p16_224.fb_dist_in1k` | 224 | 78.572 | 224 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/xcit_tiny_12_p16_224.fb_dist_in1k) |
| `xcit_tiny_12_p16_224.fb_in1k` | 224 | 77.122 | 224 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/xcit_tiny_12_p16_224.fb_in1k) |
| `xcit_tiny_12_p16_384.fb_dist_in1k` | 384 | 80.954 | 384 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/xcit_tiny_12_p16_384.fb_dist_in1k) |
| `xcit_tiny_24_p8_224.fb_dist_in1k` | 224 | 82.578 | 224 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/xcit_tiny_24_p8_224.fb_dist_in1k) |
| `xcit_tiny_24_p8_224.fb_in1k` | 224 | 81.888 | 224 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/xcit_tiny_24_p8_224.fb_in1k) |
| `xcit_tiny_24_p8_384.fb_dist_in1k` | 384 | 83.784 | 384 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/xcit_tiny_24_p8_384.fb_dist_in1k) |
| `xcit_tiny_24_p16_224.fb_dist_in1k` | 224 | 80.462 | 224 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/xcit_tiny_24_p16_224.fb_dist_in1k) |
| `xcit_tiny_24_p16_224.fb_in1k` | 224 | 79.474 | 224 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/xcit_tiny_24_p16_224.fb_in1k) |
| `xcit_tiny_24_p16_384.fb_dist_in1k` | 384 | 82.580 | 384 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/xcit_tiny_24_p16_384.fb_dist_in1k) |

