Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get the string labels for the segmentations? #3

Open
srcolinas opened this issue Feb 25, 2018 · 4 comments
Open

How to get the string labels for the segmentations? #3

srcolinas opened this issue Feb 25, 2018 · 4 comments

Comments

@srcolinas
Copy link

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
Copy link
Author

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.

@shadydiaa
Copy link

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

@srcolinas
Copy link
Author

srcolinas commented Mar 17, 2018

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.

@shadydiaa
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants