decode_image Tensor, mode: ImageReadMode = ImageReadMode.UNCHANGED, apply_exif_orientation: bool = False) Tensor[source]

Detect whether an image is a JPEG, PNG or GIF and performs the appropriate operation to decode the image into a 3 dimensional RGB or grayscale Tensor.

Optionally converts the image to the desired format. The values of the output tensor are uint8 in [0, 255].

  • input (Tensor) – a one dimensional uint8 tensor containing the raw bytes of the PNG or JPEG image.

  • mode (ImageReadMode) – the read mode used for optionally converting the image. Default: ImageReadMode.UNCHANGED. See ImageReadMode class for more information on various available modes. Ignored for GIFs.

  • apply_exif_orientation (bool) – apply EXIF orientation transformation to the output tensor. Ignored for GIFs. Default: False.


output (Tensor[image_channels, image_height, image_width])


Access comprehensive developer documentation for PyTorch

View Docs


Get in-depth tutorials for beginners and advanced developers

View Tutorials


Find development resources and get your questions answered

View Resources