decode_png
- torchvision.io.decode_png(input: Tensor, mode: ImageReadMode = ImageReadMode.UNCHANGED, apply_exif_orientation: bool = False) →
[DEPRECATED] Use TorchCodec instead.
Decodes a PNG image into a 3 dimensional RGB or grayscale Tensor.
The values of the output tensor are in uint8 in [0, 255] for most cases. If
the image is a 16-bit png, then the output tensor is uint16 in [0, 65535]
(supported from torchvision 0.21). Since uint16 support is limited in
pytorch, we recommend calling
torchvision.transforms.v2.functional.to_dtype() with scale=True
after this function to convert the decoded image into a uint8 or float
tensor.
input (Tensor[1]) – a one dimensional uint8 tensor containing the raw bytes of the PNG image.
mode (str or ImageReadMode) – The mode to convert the image to, e.g. “RGB”.
Default is “UNCHANGED”. See ImageReadMode
for available modes.
apply_exif_orientation (bool) – apply EXIF orientation transformation to the output tensor. Default: False.
output (Tensor[image_channels, image_height, image_width])