TorchVision
torchvision
The official PyTorch vision library: datasets, pretrained models and transforms for images, masks and boxes.
Basic information
| Name | TorchVision |
|---|---|
| Full name | torchvision |
| Category | Computer Vision & Image Processing |
| Developer | The PyTorch team |
| Release year | Not specified |
| Official website | github.com/pytorch/vision |
| GitHub repository | pytorch/vision |
| Official documentation | Not specified |
| Package on PyPI | torchvision |
| License | BSD (PyPI license) |
| Project status | Active Had a release in the last 12 months |
| Latest version | 28 October 2026 (version 0.29.2) |
| Programming language | Python, C++ |
| Operating systems | Not specified |
| Required Python version | !=3.14.1,>=3.10 |
| Difficulty level | Beginner |
Data last checked: 21 November 2026 — source: PyPI JSON API (2026-11-21)
Overview
TorchVision provides datasets such as CIFAR and ImageNet (loading interfaces), classification, detection and segmentation models with pretrained weights (ResNet, ViT, Faster R-CNN, Mask R-CNN and others), and v2 transforms that support boxes and masks.
Its version must match the installed PyTorch version; see the compatibility table in the official repository.
When to choose it? Choose it with PyTorch for transfer learning and standard models and transforms.
Uses
Main uses
- Loading standard datasets
- Loading standard datasets
- Pretrained models for transfer learning
- Pretrained models for transfer learning
- Image transforms and augmentation
- Image transforms and augmentation
Scientific fields
- Computer vision
- Computer vision
- Medical imaging
- Medical imaging
Suitable project types
- Transfer learning for image classification
- Transfer learning for image classification
Research applications
- Standard baselines with ImageNet weights
- Standard baselines with ImageNet weights
Technical features
A feature is shown as "Supported" only if it is documented in the library's official documentation; anything we have not verified is shown as "Not specified".
| CPU support | Supported |
|---|---|
| GPU support | Supported |
| CUDA compatibility | Supported |
| Distributed training or computing | Not applicable |
| Automatic differentiation (Autodiff) | SupportedThrough PyTorch. |
| Model deployment | Supported |
| Pre-trained models | Supported |
| Supported data types | PyTorch tensors and PIL images |
| Integration with other libraries | PyTorch, Pillow, timm |
| Flexibility (editorial estimate) | Medium |
| Performance (editorial estimate) | High |
| Community (editorial estimate) | Huge |
| Documentation quality (editorial estimate) | Official documentation |
Installation and running
pip install torchvisionCompatibility: Python !=3.14.1,>=3.10 — according to the package data on PyPI, checked on 21 November 2026
Compatibility: Python !=3.14.1,>=3.10 — according to the package data on PyPI, checked on 21 November 2026
Installing inside a virtual environment (venv or conda) is recommended. If you need compatibility with a specific CUDA version or operating system, refer to the official documentation, because this information changes with every release.
Code examples
Examples marked "Run and tested" were actually run, with their output, test date and library versions recorded; the others need a GPU or model downloads, so they were not run in the test environment.
BeginnerImage transforms and a ResNet model from torchvisionRun and tested
Goal: Preparing an image with the standard transforms and passing it to ResNet-18.
import numpy as np, torch
from PIL import Image
from torchvision import models
from torchvision.transforms import v2
img = Image.fromarray((np.random.default_rng(0).random((300, 400, 3)) * 255).astype("uint8"))
tf = v2.Compose([v2.ToImage(), v2.Resize(256), v2.CenterCrop(224),
v2.ToDtype(torch.float32, scale=True),
v2.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225])])
x = tf(img).unsqueeze(0)
model = models.resnet18(weights=None, num_classes=4).eval()
with torch.no_grad():
out = model(x)
print("Input shape:", tuple(x.shape))
print("Output shape:", tuple(out.shape))
print("Number of parameters (millions):", round(sum(p.numel() for p in model.parameters()) / 1e6, 2))
Code explanation
We create a synthetic PIL image and apply v2 transforms (resizing, cropping, conversion to a tensor, normalisation). We use weights=None because downloading pretrained weights needs a connection; in your project use ResNet18_Weights.DEFAULT for transfer learning.
Output recorded during testing
Input shape: (1, 3, 224, 224) Output shape: (1, 4) Number of parameters (millions): 11.18
This example was actually run and tested on 21 November 2026 on a CPU — torch 2.15.0, torchvision 0.29.2, pillow 13.0.0, python 3.13.18
Pros
- Official and integrated with PyTorch
- Ready pretrained models
Limitations
- A smaller range of models than timm
- The version must match PyTorch
References and verification
- Package page on PyPI (source of the version, licence and release date) Checked directly
https://pypi.org/project/torchvision/
Checked on: 21 November 2026 — version checked: 0.29.2 — reviewed by: the DLArabic team
- Official website A link the package officially declares on PyPI
https://github.com/pytorch/vision
Checked on: 21 November 2026 — reviewed by: the DLArabic team
- Official repository A link the package officially declares on PyPI
https://github.com/pytorch/vision
Checked on: 21 November 2026 — reviewed by: the DLArabic team
- Package page on PyPI (source of the version, licence and release date) Checked directly
https://pypi.org/project/torchvision/
Checked on: 21 November 2026 — version checked: 0.29.2 — reviewed by: the DLArabic team
- Official website A link the package officially declares on PyPI
https://github.com/pytorch/vision
Checked on: 21 November 2026 — reviewed by: the DLArabic team
- Official repository A link the package officially declares on PyPI
https://github.com/pytorch/vision
Checked on: 21 November 2026 — reviewed by: the DLArabic team
History of verified versions
| Version | Release date | Checked on |
|---|---|---|
| 0.29.2 | 28 October 2026 | 21 November 2026 |
Page information last reviewed: 21 November 2026. The description was written originally for the encyclopedia and is not copied from the official websites.
