Table of Contents
Shortcuts

# Image

class torchvision.tv_tensors.Image(data: Any, *, dtype: Optional[dtype] = None, device: Optional[Union[device, str, int]] = None, requires_grad: Optional[bool] = None)

  [BETA] `torch.Tensor` subclass for images.

  Note

  In the transforms, `Image` instances are largely interchangeable with pure `torch.Tensor`. See this note for more details.

  Parameters:

    - data (tensor-like, PIL.Image.Image) – Any data that can be turned into a tensor with `torch.as_tensor()` as well as PIL images.

    - dtype (torch.dpython:type, optional) – Desired data type. If omitted, will be inferred from `data`.

    - device (torch.device, optional) – Desired device. If omitted and `data` is a `torch.Tensor`, the device is taken from it. Otherwise, the image is constructed on the CPU.

    - requires_grad (bool, optional) – Whether autograd should record operations. If omitted and `data` is a `torch.Tensor`, the value is taken from it. Otherwise, defaults to `False`.

## 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.