Object class to color mapping for semantic segmentation #528
-
I am trying to do semantic segmentation over data collected from AI2THOR scenes. The |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 8 replies
-
Hey @sashi2295! I'll give a contrived example with smaller dimensions, since it's easier to visualize. Consider that the (semantic) segmentation masks will appear in the following form, where 0, 1, and 2 are each correspond to separate object type segmentation: import numpy as np
segmentation = np.random.randint(low=0, high=3, size=(3, 3))
array([[2, 2, 0],
[1, 2, 1],
[0, 0, 1]]) If the condition = (segmentation == 2)
array([[False, True, False],
[ True, False, False],
[ True, True, True]]) Now, the RGB rgb_frame = np.random.randint(low=0, high=256, size=(3, 3))
array([[231, 31, 222],
[101, 245, 223],
[ 15, 101, 106]]) where multiplying it by the condition matrix gives us the masks mask = rgb_frame * condition
array([[ 0, 31, 0],
[101, 0, 0],
[ 15, 101, 106]]) If we then want to consistently store the image mask for each object, in something like a NumPy array with masks_array = np.zeros((125, 3, 3))
array([[[0., 0., 0.],
[0., 0., 0.],
[0., 0., 0.]],
[[0., 0., 0.],
[0., 0., 0.],
[0., 0., 0.]],
[[0., 0., 0.],
[0., 0., 0.],
[0., 0., 0.]],
.....
[[0., 0., 0.],
[0., 0., 0.],
[0., 0., 0.]]]) where each of the 125 masks_array[0] = mask
# masks_array now looks like:
array([[[ 0., 31., 0.],
[101., 0., 0.],
[ 15., 101., 106.]],
[[ 0., 0., 0.],
[ 0., 0., 0.],
[ 0., 0., 0.]],
[[ 0., 0., 0.],
[ 0., 0., 0.],
[ 0., 0., 0.]],
.....
[[ 0., 0., 0.],
[ 0., 0., 0.],
[ 0., 0., 0.]]]) Here, |
Beta Was this translation helpful? Give feedback.
Hey @sashi2295!
I'll give a contrived example with smaller dimensions, since it's easier to visualize.
Consider that the (semantic) segmentation masks will appear in the following form, where 0, 1, and 2 are each correspond to separate object type segmentation:
If the
object_id_to_color
does something like assign2
to theCup
object type, we can then condition the segmentation where each entry is equal to2
, as in:Now, the RGB
frame
…