read_image¶
- torchvision.io.read_image(path: str, mode: ImageReadMode = ImageReadMode.UNCHANGED, apply_exif_orientation: bool = False) Tensor [source]¶
Reads a JPEG or PNG 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].
- Parameters:
path (str or
pathlib.Path
) – path of the JPEG or PNG image.mode (ImageReadMode) – the read mode used for optionally converting the image. Default:
ImageReadMode.UNCHANGED
. SeeImageReadMode
class for more information on various available modes.apply_exif_orientation (bool) – apply EXIF orientation transformation to the output tensor. Default: False.
- Returns:
output (Tensor[image_channels, image_height, image_width])
Examples using
read_image
:Getting started with transforms v2
Getting started with transforms v2Repurposing masks into bounding boxes
Repurposing masks into bounding boxesTorchscript supportVisualization utilities