Overview
ViT (Vision Transformer) applies the standard Transformer architecture directly to sequences of non-overlapping image patches β no convolutions. Introduced in An Image is Worth 16x16 Words (Dosovitskiy et al., ICLR 2021), ViT demonstrates that a pure transformer pre-trained on large data transfers strongly to standard image recognition benchmarks.
Pretrained weights are sourced from torchvision (BSD-3-Clause), trained on ImageNet-1K using a DeiT-style recipe. Each exported ONNX model is a single-input classification graph that outputs 1000-class ImageNet logits [1, 1000].
Model Variants
| Model | Architecture | Params | Top-1 Acc | Validated Devices | Config |
|---|---|---|---|---|---|
vit_b_16 |
ViT-Base/16 | 86.6M | 81.1% | TDA4VH | vit_b_16_config.yaml |
vit_b_32 |
ViT-Base/32 | 88.2M | 75.9% | TDA4VH | vit_b_32_config.yaml |
vit_l_16 |
ViT-Large/16 | 304.3M | 79.7% | TDA4VH | vit_l_16_config.yaml |
vit_l_32 |
ViT-Large/32 | 306.5M | 77.0% | TDA4VH | vit_l_32_config.yaml |
Recommended for edge deployment: vit_b_16 (best accuracy/compute trade-off)
Quick Start
Prerequisites
pip install torch torchvision onnx>=1.22.0 onnxruntime>=1.23.2
# Optional but recommended for model optimization:
pip install onnx-simplifier
Export the Model
# Export the default model (vit_b_16)
python prepare_model.py
# Export a specific model variant
python prepare_model.py --model vit_b_32
# Export all supported models
python prepare_model.py --model all
# List all available variants
python prepare_model.py --list-models
The script automatically:
- Downloads pretrained ImageNet-1K weights from torchvision (first run only)
- Exports the model to ONNX (opset 17) with static input shape
[1, 3, 224, 224] - Runs ONNX shape inference
- Optionally simplifies the graph with onnx-simplifier
Compile and Infer uing edgeai-tidlrunner
Note: Run the commands below from inside the
tidlrunnerdirectory (the cloned edgeai-tidlrunner repository), with--config_pathpointing to this model's config file.
Compile using edgeai-tidlrunner - on PC
cd /path/to/edgeai-tidlrunner
tidlrunner-cli compile --target_device J784S4 \
--config_path /path/to/vit_b_16_config.yaml
Run Inference Benchmark - on device
cd /path/to/edgeai-tidlrunner
tidlrunner-cli infer --target_device J784S4 \
--config_path /path/to/vit_b_16_config.yaml
Compile and Infer using edgeai-tidl-tools (Advanced):
Follow the instructions at https://github.com/TexasInstruments/edgeai-tidl-tools
Deploy using edgeai-tidl-tools:
Deplyment can be done using edgeai-tidl-tools. For ONNX models, onnxruntime-tidl with TIDL acceleration can be used. Consult the documentation of edgeai-tidl-tools for more details.
Citation
@inproceedings{dosovitskiy2021image,
title = {An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale},
author = {Dosovitskiy, Alexey and Beyer, Lucas and Kolesnikov, Alexander and
Weissenborn, Dirk and Zhai, Xiaohua and Unterthiner, Thomas and
Dehghani, Mostafa and Minderer, Matthias and Heigold, Georg and
Gelly, Sylvain and Uszkoreit, Jakob and Houlsby, Neil},
booktitle = {International Conference on Learning Representations (ICLR)},
year = {2021},
url = {https://arxiv.org/abs/2010.11929}
}
π Resources
| Resource | Link |
|---|---|
| Paper | arXiv:2010.11929 |
| Source Code | pytorch/vision |
| Torchvision Docs | VisionTransformer |
| edgeai-tidl-tools | GitHub |
| edgeai-tidlrunner | GitHub |
| EdgeAI SDK | Documentation |
Related Models
|
DINOv2 Self-supervised ViT Higher accuracy |
DINO Self-supervised ViT Linear classification head |
ResNet CNN baseline Lower compute |
MobileNetV3 Lightweight CNN Built for edge |
Maintained by: Texas Instruments EdgeAI Team
Last Updated: August 2026