Is there a TensorFlow function which takes multicategorical ground truth for semantic image segmentations in the form of RGB images and outputs a tensor with a one-hot vector encoding of the corresponding class per pixel? In other words, I'm starting with RGB images for the ground truth, so each class has a distinct color, like this:

RGB ground truth annotations for semantic segmentation, taken from the SYNTHIA dataset

This image was taken from the SYNTHIA dataset.Many semantic segmentation datasets supply their ground truth this way. Every pixel has just one class. What I am looking for is a function that first enumerates the number of different colours in an annotation, and then considers each colour to be a different class automatically. I thought that usually when performing semantic segmentation, each ground truth class is encoded using a one hot vector, to which predicted class probabilities can easily be compared.

I'm basically asking the exact same as this question, and am merely wondering whether such a function has been added since that question was posed, or if someone has a more efficient solution. The answer to it seems convoluted, and I can't imagine such functionality does not exist, as it would seem like a common task. Also, while for many datasets the ground truth is additionally given as some sort of text file (like JSON), writing parser for each different dataset you use seems needlessly cumbersome.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.