You can construct a greyscale image by combining the masks, then use that image as a new feature called “label” using the datasets.Image
feature type . If you save this new mask as a file and use Imagefolder metadata, referring to the mask path, it should cast to
datasets.Image
for ya out of the box.
Now to do that…here’s a vvv quick explanation
Let’s say you have an image that’s shape is (1080, 720, 3). You could construct a mask of shape (1080, 720) where each value therein is [0, num_classes)
denoting which object is in that pixel location.
So if you had two masks:
Cat
0 1 0
0 0 0
0 1 1
and Dog
1 0 1
0 0 1
1 0 0
Let’s also assume you want a background class to make it clearer…you’d construct labels = ['background', 'cat', 'dog']
and make following array you could save as greyscale image
2 1 2
0 0 2
2 1 1
You can see a dataset like that in the segments AI dataset Nima mentioned above.