Skip to content

Support for non-rgb images in io.read_image & io.decode_image #3194

Closed
@AnirudhDagar

Description

@AnirudhDagar

🚀 Feature

The current torchvision.io.read_image function reads a JPEG or PNG image into a 3 dimensional RGB Tensor. When the image has a single channel, this function throws a runtime error saying "RuntimeError: Non-RGB images are not supported.".
It would be nice to add support for non-RGB images.

Motivation

This can be extremely helpful for example when reading in the segmentation maps in the VOC dataset which are originally single-channel png images.

Pitch

This can probably be resolved in the method decode_image by converting the image to RGB with a boolean flag to_rgb=True similar to MXNet's image read method here as an argument.

Alternatives

For now to get around these, one needs to use the PIL Image module or OpenCV. torchvision native io doesn't support these.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions