lucidrains/vit-pytorch

Implementation of Vision Transformer, a simple way to achieve SOTA in vision classification with only a single transformer encoder, in Pytorch

Open original source ↗

From the publisher

README & documentation

Source preview

Read the project’s overview, installation instructions and usage examples. The original README is the source of truth.

Implementation of Vision Transformer, a simple way to achieve SOTA in vision classification with only a single transformer encoder, in Pytorch. Significance is further explained in Yannic Kilcher's video. There's really not much to code here, but may as well lay it out for everyone so we expedite the attention revolution. For a Pytorch implementation with pretrained models, please see Ross Wightman's repository here. The official Jax repository is here. A tensorflow2 translation also exists here, created by research scientist Junho Kim! 🙏 Flax translation by Enrico Shippole! Image size. If you have rectangular images, make sure your image size is the maximum of the width and height Size of patches. imagesize must be divisible by patchsize. The number of patches is: n = (imagesize // patchsize) 2 and n must be greater than 16. Number of classes to classify. Last dimension of output tensor after linear transformation nn.Linear(..., dim).…

lucidrains/vit-pytorch on GitHub A short preview, not the full document.

Read the full README ↗ · Preview checked 2026-11-01T17:05:10.639Z

Inside the original README — Document outline
  1. Table of Contents
  2. Vision Transformer - Pytorch
  3. Install
  4. Usage
  5. Parameters
  6. Simple ViT
  7. NaViT
  8. Distillation
  9. Deep ViT
  10. CaiT
  11. Token-to-Token ViT
  12. CCT

Headings are captured from the source. Links open the publisher’s document, not a locally hosted copy.

Links from the README

References supplied by the publisher, not independently verified endorsements. Check the destination before downloading files or entering credentials.

Documentation belongs to its respective authors. Reported project/model license: MIT. A listing is not a grant of reuse or training rights. Confirm the document’s own terms at the source.

What this repository does

Implementation of Vision Transformer, a simple way to achieve SOTA in vision classification with only a single transformer encoder, in Pytorch

Repository facts

Owner
lucidrains
Primary language
Python
Stars
25,554
Forks
3,496
Open issues + pull requests
151
License
MIT
Archived
No
Default branch
main
Created
2020-10-03T22:47:24.000Z
Last push
2026-11-01T03:52:46.000Z

Topics and intended use

Owner-supplied topics: artificial-intelligence, attention-mechanism, computer-vision, image-classification, transformers

Review the README for scope, installation, examples and limitations. We do not run repository code or certify it.

Evaluate before installing

Review licensing and dependencies, inspect recent commits and unresolved issues, and test in an isolated environment before production use. Stars and forks alone cannot answer these questions.

README and project files

Issues and maintenance discussion

Releases and changelog

Source and freshness

Source: GitHub. Metadata observed 2026-11-01T13:20:54.848Z. Daily imports are snapshots, not real-time monitoring.

Popularity and source listings do not establish security, suitability, licensing rights or benchmark performance.

Open original source

Related repositories

public-apis/public-apis

EbookFoundation/free-programming-books

donnemartin/system-design-primer

vinta/awesome-python

practical-tutorials/project-based-learning

NousResearch/hermes-agent