- torchvision.io.decode_jpeg(input: Tensor, mode: ImageReadMode = ImageReadMode.UNCHANGED, device: str = 'cpu') Tensor [source]¶
Decodes a JPEG 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 between 0 and 255.
input (Tensor) – a one dimensional uint8 tensor containing the raw bytes of the JPEG image. This tensor must be on CPU, regardless of the
mode (ImageReadMode) – the read mode used for optionally converting the image. The supported modes are:
ImageReadModeclass for more information on various available modes.
device (str or torch.device) –
The device on which the decoded image will be stored. If a cuda device is specified, the image will be decoded with nvjpeg. This is only supported for CUDA version >= 10.1
The device parameter is in Beta stage, and backward compatibility is not guaranteed.
There is a memory leak in the nvjpeg library for CUDA versions < 11.6. Make sure to rely on CUDA 11.6 or above before using
output (Tensor[image_channels, image_height, image_width])