This repository has been archived by the owner on Oct 9, 2023. It is now read-only.
SemanticSegmentationData: Paletted PIL Images Support #1397
Unanswered
Nico995
asked this question in
Data / pipelines
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello, I have been trying run a SemanticSegmentation task on a custom dataset with no luck. The problem I'm facing is that it looks like paletted png images are not supported as targets for the task.
TL;DR
ImageSegmentationData.from_files breaks when target files are paletted PNG images.
Reproducing a working example
To prove my point, I started from the segmentation example on flash website:
The mask looks completely black because PIL in RGB mode (x, 0, 0) colors with 0<x<12 are black/red-ish colors.
Testing Paletted images
The problem arises when I try to use the paletted version of the same mask, as follows:
Full stacktrace
The relevant traceback line here I believe is
Suspected problem
I believe I have seen this error many times already, and I think it is referring to a loss function call when the argument contains values larget than the number of classes declared. My first guess is that this is happening because flash default behavior is to convert the mask to RGB, and reading only the first channel. Below I try to justify my assumption.
I believe this is the line responsible for extracting the first channel:
And this is the line responsible for the RGB conversion
Which in turn is a pytorch function that simply loads a RGB image
Possible solution
I think it would be nice to have a parameter in SemanticSegmentationFilesInput.from_folders inside /flash/image/segmentation/data.py that allows the user to specify the mode of the image.
The parameter would default to 'RGB' for backward compatibility, and could be set to 'P' if one wants to work with paletted images.
Let me know if this looks like a possible enhancement, or if I just simply missed a parameter somewhere that would solve the problem :)
Beta Was this translation helpful? Give feedback.
All reactions