docs/source/en/model_doc/levit.md
This model was released on 2021-04-02 and added to Hugging Face Transformers on 2022-06-01.
The LeViT model was proposed in LeViT: Introducing Convolutions to Vision Transformers by Ben Graham, Alaaeldin El-Nouby, Hugo Touvron, Pierre Stock, Armand Joulin, Hervé Jégou, Matthijs Douze. LeViT improves the Vision Transformer (ViT) in performance and efficiency by a few architectural differences such as activation maps with decreasing resolutions in Transformers and the introduction of an attention bias to integrate positional information.
The abstract from the paper is the following:
We design a family of image classification architectures that optimize the trade-off between accuracy and efficiency in a high-speed regime. Our work exploits recent findings in attention-based architectures, which are competitive on highly parallel processing hardware. We revisit principles from the extensive literature on convolutional neural networks to apply them to transformers, in particular activation maps with decreasing resolutions. We also introduce the attention bias, a new way to integrate positional information in vision transformers. As a result, we propose LeVIT: a hybrid neural network for fast inference image classification. We consider different measures of efficiency on different hardware platforms, so as to best reflect a wide range of application scenarios. Our extensive experiments empirically validate our technical choices and show they are suitable to most architectures. Overall, LeViT significantly outperforms existing convnets and vision transformers with respect to the speed/accuracy tradeoff. For example, at 80% ImageNet top-1 accuracy, LeViT is 5 times faster than EfficientNet on CPU.
<small> LeViT Architecture. Taken from the <a href="https://huggingface.co/papers/2104.01136">original paper</a>.</small>
This model was contributed by anugunj. The original code can be found here.
LevitForImageClassification] and (2) corresponds to [LevitForImageClassificationWithTeacher].LevitModel] or [LevitForImageClassification].
Techniques like data augmentation, optimization, and regularization were used in order to simulate training on a much larger dataset
(while only using ImageNet-1k for pre-training). The 5 variants available are (all trained on images of size 224x224):
facebook/levit-128S, facebook/levit-128, facebook/levit-192, facebook/levit-256 and
facebook/levit-384. Note that one should use [LevitImageProcessor] in order to
prepare images for the model.LevitForImageClassificationWithTeacher] currently supports only inference and not training or fine-tuning.ViTImageProcessor] by [LevitImageProcessor] and [ViTForImageClassification] by [LevitForImageClassification] or [LevitForImageClassificationWithTeacher]).A list of official Hugging Face and community (indicated by 🌎) resources to help you get started with LeViT.
<PipelineTag pipeline="image-classification"/>LevitForImageClassification] is supported by this example script and notebook.If you're interested in submitting a resource to be included here, please feel free to open a Pull Request and we'll review it! The resource should ideally demonstrate something new instead of duplicating an existing resource.
[[autodoc]] LevitConfig
[[autodoc]] LevitImageProcessor - preprocess
[[autodoc]] LevitImageProcessorPil - preprocess
[[autodoc]] LevitModel - forward
[[autodoc]] LevitForImageClassification - forward
[[autodoc]] LevitForImageClassificationWithTeacher - forward