--- id: vit-pytorch version: "1.24.2" license: MIT License Copyright (c) 2020 Phil Wang Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in… (full text in the JSON record) license_treatment: permissive maintenance: active --- # vit-pytorch — Vision Transformer (ViT) - Pytorch License: permissive · Maintenance: active · Downloads: 184.5K/mo ## What it is and what it does vit-pytorch is a collection of PyTorch implementations of Vision Transformer architectures and related vision models. It provides the core ViT model alongside numerous variants—SimpleViT, NaViT, CaiT, Token-to-Token ViT, LeViT, MobileViT, and others—each addressing different efficiency or accuracy trade-offs. The package also includes support for self-supervised learning techniques like masked autoencoders and masked image modeling, as well as knowledge distillation from convolutional networks. The library is designed for researchers and practitioners building image classification systems with transformers. It depends on torch for computation, torchvision for standard vision utilities, and einops for flexible tensor reshaping. Models are instantiated with configurable parameters (patch size, embedding dimension, depth, attention heads, dropout rates) and accept batches of images as input, returning class predictions or intermediate representations. Use it for: - Train a vision transformer from scratch on a custom image classification dataset using the base ViT or SimpleViT variant - Distill knowledge from a pretrained ResNet or other CNN teacher into a smaller, faster ViT student model - Implement masked image modeling or masked autoencoder pretraining for self-supervised representation learning - Experiment with variable-resolution image batching using NaViT for faster training on mixed-size datasets - Deploy efficient vision models on resource-constrained devices using MobileViT or LeViT variants ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Provides PyTorch implementations of Vision Transformer (ViT) and related transformer-based vision models for image classification and self-supervised learning tasks. Yes. The package is actively maintained, has low install friction, carries permissive MIT licensing, and offers a comprehensive suite of transformer vision models backed by recent research. It is well-suited for both research prototyping and production image classification systems. No known vulnerabilities. ## Install pip install vit-pytorch uv add vit-pytorch poetry add vit-pytorch ## Installing vit-pytorch Before you install: Low install friction with a pure Python wheel. Actively maintained with a recent release. Depends on torch and torchvision, which are standard deep learning libraries, plus einops for tensor operations. License in practice: MIT License permits free use, modification, and distribution with minimal restrictions—suitable for both research and commercial projects. Quickstart: pip install vit-pytorch import torch from vit_pytorch import ViT v = ViT( image_size=256, patch_size=32, num_classes=1000, dim=1024, depth=6, heads=16, mlp_dim=2048 ) img = torch.randn(1, 3, 256, 256) preds = v(img) Requires torch and torchvision to be installed; GPU recommended for practical training but not required for inference on small batches. Verify before relying: - Whether pretrained model weights are included or must be sourced separately - GPU memory requirements for different model variants and batch sizes - Training time and convergence characteristics compared to CNN baselines ## Package facts - License: MIT License Copyright (c) 2020 Phil Wang Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in… (full text in the JSON record) (permissive) - Python support: supports_current - Install friction: low - Maintenance: active - Downloads: 184.5K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags vision transformer pytorch, image classification transformer, vit implementation, transformer vision models, self-supervised vision learning, masked image modeling, attention-based image recognition, transformer-vision, self-supervised-learning, knowledge-distillation [View on SkillFed](https://skillfed.io/packages/vit-pytorch) · [View on PyPI](https://pypi.org/project/vit-pytorch/)