AI/TLDR

torchvision

PyTorch's computer-vision library: datasets, model architectures and transforms

Vision & UnderstandingOpen source
Language
Python
License
BSD-3-Clause

Overview

torchvision is the computer-vision companion package to PyTorch, maintained in the PyTorch organisation itself. It consists of three things developers reach for constantly: popular vision datasets with loaders, model architectures with pre-trained weights, and the common image transformations used to prepare data for them.

Its role in the ecosystem is to be the layer you do not have to write. Instead of hand-rolling a dataset downloader, re-implementing a classification or detection backbone, or reimplementing resize/crop/normalize pipelines, you import them — and because everything speaks native torch tensors, the pieces compose with the rest of a PyTorch training loop without conversion glue. Transforms operate on torch tensors and on PIL images, with Pillow or the faster drop-in Pillow-SIMD as the image backend.

Versions are pinned to PyTorch releases: torchvision 0.28 pairs with torch 2.13, 0.27 with 2.12, 0.26 with 2.11 and 0.25 with 2.10, all supporting Python 3.10 through 3.14. Two licensing caveats are worth knowing: torchvision downloads public datasets but does not host or license them, and some pre-trained weights carry their own terms — the SWAG models, for instance, are released under CC-BY-NC 4.0 rather than the package's BSD-3-Clause licence.

What it does

  • Loaders for popular public vision datasets, with download and preparation handled for you
  • Reference implementations of widely used model architectures, many with pre-trained weights
  • Common image transformations (resize, crop, normalize, augmentation) that run on torch tensors and PIL images
  • Multiple image backends: torch tensors, Pillow, and the SIMD-accelerated Pillow-SIMD drop-in replacement
  • Version matrix pinned to PyTorch releases so torch/torchvision/Python combinations are unambiguous
  • Full API documentation published alongside the PyTorch docs

Getting started

torchvision is installed together with PyTorch. The project points to the official PyTorch install selector rather than a single pip line, because the right wheel depends on your OS, package manager and CUDA version.

Install torch and torchvision together

Follow the official instructions at pytorch.org/get-started/locally to pick the wheel matching your platform and accelerator. Check the README's compatibility table to confirm which torchvision version pairs with your torch version — for example torchvision 0.28 with torch 2.13.

Verify the install

Import the package and print its version to confirm the pairing is what you expect.

pythonpython
import torch, torchvision
print(torch.__version__, torchvision.__version__)

Read the API docs

The full reference — datasets, models, transforms and ops — lives at pytorch.org/vision/stable/index.html, with a dedicated transforms guide at pytorch.org/vision/stable/transforms.html.

Build from source (contributors)

To develop against torchvision, follow the development-installation section of the repository's CONTRIBUTING guide rather than installing the published wheel.

bashbash
git clone https://github.com/pytorch/vision.git
cd vision

Commands and code are distilled from the project's own documentation — always check the official repo for the latest.

When to use it

  • Fine-tune a pre-trained classification or detection backbone instead of training a vision model from scratch
  • Load a standard benchmark dataset with one line while prototyping or reproducing a paper
  • Assemble a reproducible image augmentation and preprocessing pipeline that runs directly on torch tensors
  • Provide the vision layer under a multimodal PyTorch model, alongside text or audio encoders

How torchvision compares

torchvision alongside other open-source vision & understanding tools AI/TLDR tracks, ranked by GitHub stars.

ToolStarsWhat it does
OpenCV★ 90.9kThe long-standing open-source computer-vision library for C++, Python and Java; version 5 rewrote the DNN engine and added ONNX-based LLM and VLM inference in-library.
PaddleOCR★ 90.1kA toolkit for detecting and recognizing text in images across many languages, plus document parsing.
Ultralytics YOLO★ 61.9kA framework for training and running YOLO models for real-time object detection, segmentation, and tracking.
Supervision★ 51kA Python toolkit for processing, annotating, and visualizing detections and segmentations from many vision models.
MediaPipe★ 37kGoogle's on-device ML framework: ready-to-run vision, text and audio tasks with one cross-platform API for Android, iOS, web, desktop and edge.
MMDetection★ 33kAn OpenMMLab toolbox with many object detection and instance segmentation algorithms for research and production.
vit-pytorch★ 25.5kA single pip package with readable PyTorch implementations of the Vision Transformer and dozens of its research variants, for training image models from scratch.
torchvision★ 17.9kPyTorch's computer-vision library: datasets, model architectures and transforms