Table of Contents
Shortcuts

# torchvision

This library is part of the PyTorch project. PyTorch is an open source machine learning framework.

Features described in this documentation are classified by release status:

> Stable: These features will be maintained long-term and there should generally be no major performance limitations or gaps in documentation. We also expect to maintain backwards compatibility (although breaking changes can happen and notice will be given one release ahead of time).

> Beta: Features are tagged as Beta because the API may change based on user feedback, because the performance needs to improve, or because coverage across operators is not yet complete. For Beta features, we are committing to seeing the feature through to the Stable classification. We are not, however, committing to backwards compatibility.

> Prototype: These features are typically not available as part of binary distributions like PyPI or Conda, except sometimes behind run-time flags, and are at an early stage for feedback and testing.

The `torchvision` package consists of popular datasets, model architectures, and common image transformations for computer vision.

Package Reference

- Transforming and augmenting images
  - Start here
  - Supported input types and conventions
  - V1 or V2? Which one should I use?
  - Performance considerations
  - Transform classes, functionals, and kernels
  - Torchscript support
  - V2 API reference - Recommended
  - V1 API Reference
- TVTensors
  - Image
  - Video
  - BoundingBoxFormat
  - BoundingBoxes
  - Mask
  - TVTensor
  - set_return_type
  - wrap
- Models and pre-trained weights
  - General information on pre-trained weights
  - Classification
  - Semantic Segmentation
  - Object Detection, Instance Segmentation and Person Keypoint Detection
  - Video Classification
  - Optical Flow
- Datasets
  - Built-in datasets
  - Base classes for custom datasets
  - Transforms v2
- Utils
  - draw_bounding_boxes
  - draw_segmentation_masks
  - draw_keypoints
  - flow_to_image
  - make_grid
  - save_image
- Operators
  - Detection and Segmentation Operators
  - Box Operators
  - Losses
  - Layers
- Decoding / Encoding images and videos
  - Images
  - Video
- Feature extraction for model inspection
  - API Reference

Examples and training references

- Examples and tutorials
- Training references

torchvision.get_image_backend()

  Gets the name of the package used to load images

torchvision.get_video_backend()

  Returns the currently active video backend used to decode videos.

  Returns:

    Name of the video backend. one of {‘pyav’, ‘video_reader’}.

  Return type:

    str

torchvision.set_image_backend(backend)

  Specifies the package used to load images.

  Parameters:

    backend (string) – Name of the image backend. one of {‘PIL’, ‘accimage’}. The `accimage` package uses the Intel IPP library. It is generally faster than PIL, but does not support as many operations.

torchvision.set_video_backend(backend)

  Specifies the package used to decode videos.

  Parameters:

    backend (string) – Name of the video backend. one of {‘pyav’, ‘video_reader’}. The `pyav` package uses the 3rd party PyAv library. It is a Pythonic binding for the FFmpeg libraries. The `video_reader` package includes a native C++ implementation on top of FFMPEG libraries, and a python API of TorchScript custom operator. It generally decodes faster than `pyav`, but is perhaps less robust.

  Note

  Building with FFMPEG is disabled by default in the latest main. If you want to use the ‘video_reader’ backend, please compile torchvision from source.

PyTorch Libraries

- PyTorch
- torchaudio
- torchtext
- torchvision
- TorchElastic
- TorchServe
- PyTorch on XLA Devices

## Indices

- Index

## Docs

Access comprehensive developer documentation for PyTorch

View Docs

## Tutorials

Get in-depth tutorials for beginners and advanced developers

View Tutorials

## Resources

Find development resources and get your questions answered

View Resources

To analyze traffic and optimize your experience, we serve cookies on this site. By clicking or navigating, you agree to allow our usage of cookies. As the current maintainers of this site, Facebook’s Cookies Policy applies. Learn more, including about available controls: Cookies Policy.