Registry / ai-ml / vit-pytorch

vit-pytorch

JSON →
library1.20.4pypypi✓ verified 85d ago

A PyTorch implementation of the Vision Transformer (ViT) and related vision transformer architectures. Current version 1.20.4, actively maintained with frequent releases.

pip install vit-pytorch
INSTALL
IMPORT
SIG · VIT-PYTORCH
V
vit-pytorch
ai-mlpythonv1.20.4
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

ViT
from vit_pytorch import ViT
from vit_pytorch.vit import ViT
Old import path no longer works; use top-level import.

Basic instantiation and forward pass of a Vision Transformer.

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, dropout=0.1, emb_dropout=0.1 ) img = torch.randn(1, 3, 256, 256) preds = v(img) # (1, 1000)
Debug
Known issues
breakingIn version 1.0.0, the package was renamed from 'vit_pytorch' to 'vit-pytorch' on PyPI, but the import remains 'vit_pytorch'. Ensure you install with 'vit-pytorch' but import with 'vit_pytorch'.
fix
Use 'pip install vit-pytorch' and 'from vit_pytorch import ViT'.
affects: >=1.0.0
gotchaCommon mistake: using the wrong import path. Many users try 'from vit_pytorch.vit import ViT' which fails. The correct import is 'from vit_pytorch import ViT'.
fix
Use 'from vit_pytorch import ViT'.
affects: all
Errors
Common errors & fixes
ImportError: cannot import name 'ViT' from 'vit_pytorch'
Using an older version where the API was different or the package was not properly installed.
fix
Upgrade to the latest version with 'pip install --upgrade vit-pytorch' and use 'from vit_pytorch import ViT'.
ModuleNotFoundError: No module named 'vit_pytorch'
Installed the wrong package name ('vit-pytorch' vs 'vit_pytorch') or not installed at all.
fix
Install with 'pip install vit-pytorch' (hyphen) and import with 'import vit_pytorch' (underscore).
Upgrade
Version history
1.20.4latest on PyPI · released May 1, 2026
Audit
Dependencies
torchrequiredRequired for tensor operations and neural network modules.
einopsrequiredRequired for rearrange and reduce operations used in the transformer.
Agent activity
47 hits · last 30 days
node
42
OpenAI (training)
1
Resources
vit-pytorch — pip install vit-pytorch · libregistry