Torchvision bundles datasets, model architectures, image and video transforms, and utilities for computer vision work on top of PyTorch.
Overview
Torchvision is a companion package to PyTorch focused on computer vision. It ships widely used public datasets with download helpers, model architectures with optional pre-trained weights, and image and video transformation pipelines, including a newer v2 API for images, videos, boxes, and related tensor types.
Model coverage spans classification, semantic segmentation, object and instance detection, person keypoints, video classification, and optical flow, each documented with weight loading guidance. Dataset utilities download and prepare data locally; the project does not host the raw datasets itself and leaves license compliance to the user. Pre-trained weights may carry their own terms, including non-commercial licenses called out for some SWAG models.
Image loading can use PIL or torch tensors; video decoding is supported through a PyAV-backed backend. Transform layers include drawing helpers for boxes, masks, and keypoints, IO utilities, and operators aimed at detection workflows. Documentation distinguishes stable, beta, and prototype APIs so callers know what to expect long term.
The library is maintained as part of the broader PyTorch ecosystem alongside torchaudio and related projects. Install pairing follows published compatibility tables matching torchvision releases to specific torch and Python versions.
Key features
- Built-in vision dataset loaders
- Pre-trained vision model weights
- Image and video transform v2 API
- TVTensor types for boxes and masks
- Detection and segmentation operators
- Drawing and grid visualization helpers
- Configurable PIL or tensor image backends
- PyAV-based video decode backend
Use cases
- Training image classifiers with PyTorch
- Loading standard vision benchmarks
- Transfer learning from torchvision weights
- Prototyping detection or segmentation pipelines