semantic-segmentation-tensorflow icon indicating copy to clipboard operation
semantic-segmentation-tensorflow copied to clipboard

How to get the string labels for the segmentations?

Open srcolinas opened this issue 7 years ago • 4 comments

Hi, I know for some semantic segmentation datasets one has a predefined set of labels. How can I get the labels corresponding to the segments (either attached to the image or in a dictionary for later use?

srcolinas avatar Feb 25 '18 00:02 srcolinas

Sorry for the inconvenience, I found the definitions in the tools.py file: label_colours = [[128, 64, 128], [244, 35, 231], [69, 69, 69] # 0 = road, 1 = sidewalk, 2 = building ,[102, 102, 156], [190, 153, 153], [153, 153, 153] # 3 = wall, 4 = fence, 5 = pole ,[250, 170, 29], [219, 219, 0], [106, 142, 35] # 6 = traffic light, 7 = traffic sign, 8 = vegetation ,[152, 250, 152], [69, 129, 180], [219, 19, 60] # 9 = terrain, 10 = sky, 11 = person ,[255, 0, 0], [0, 0, 142], [0, 0, 69] # 12 = rider, 13 = car, 14 = truck ,[0, 60, 100], [0, 79, 100], [0, 0, 230] # 15 = bus, 16 = train, 17 = motocycle ,[119, 10, 32]] # 18 = bicycle

I am going to write something to attach the labels to the image.

srcolinas avatar Feb 26 '18 17:02 srcolinas

hi @srcolinas are you wrote something to attach the labels to the image ? , that it will helpful to me .Thanks

shadydiaa avatar Mar 17 '18 15:03 shadydiaa

I did, but to be honest I now think is an awful implementation, specially after I saw how they did it in google's deeplab implementation Anyway I share the way I did it with you: I stored the meaning of colors in a .csv file: R,G,B,label 128, 64, 128, road 244, 35, 231, sidewalk 69, 69, 69, building 102, 102, 156, wall 190, 153, 153, fence 153, 153, 153, pole 250, 170, 29, traffic light 219, 219, 0, traffic sign 106, 142, 35, vegetation 152, 250, 152, terrain 69, 129, 180, sky 219, 19, 60, person 255, 0, 0, rider 0, 0, 142, car 0, 0, 69, truck 0, 60, 100, bus 0, 79, 100, train 0, 0, 230, motocycle 119, 10, 32, bicycle Using the output image of this repo I go through all labels and colors in the .csv file and compute different masks of the output image based on the colors of the pixel and their similarity with the colors of the in the .csv file.

For some reason the output image did not contain the exact values I was using in the .csv file so I use the cv2.inRange() to create the masks. Anyway I am now trying to work with the DeepLab implementation found in here, so I did not try to polish my code.

I hope my reply helps.

srcolinas avatar Mar 17 '18 16:03 srcolinas

your reply is more helpful and i will try to implement deeplab implementation but if you can send to me your edit of code to show labels with images i will be thankful to you @srcolinas

shadydiaa avatar Mar 17 '18 16:03 shadydiaa