Skip to content

Support paletted images for io.image.read_image #2823

@vfdev-5

Description

@vfdev-5

🚀 Feature

The following code raises an error for mask images

from torchvision.io.image import read_image

read_image("/data/VOCdevkit/VOC2012/SegmentationClass/2007_000032.png")
> 
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
<ipython-input-13-5d26944acaeb> in <module>
----> 1 read_image("/data/VOCdevkit/VOC2012/SegmentationClass/2007_000032.png")

.../lib/python3.7/site-packages/torchvision/io/image.py in read_image(path)
    228     """
    229     data = read_file(path)
--> 230     return decode_image(data)

.../lib/python3.7/site-packages/torchvision/io/image.py in decode_image(input)
    209     output: Tensor[3, image_height, image_width]
    210     """
--> 211     output = torch.ops.image.decode_image(input)
    212     return output
    213 

RuntimeError: Non RGB images are not supported.

The problem is related to paletted type images.

It would be nice to support those images and return a single channel tensor.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions