mapillary / seamseg

Seamless Scene Segmentation
BSD 3-Clause "New" or "Revised" License
289 stars 53 forks source link

Where can I find the index -> class mappings produced by train_detection? #13

Closed gcheng21 closed 4 years ago

gcheng21 commented 4 years ago

How do I interpret the values in cls_pred and obj_pred? is there a json or some file with the class idx -> class name mappings?

ducksoup commented 4 years ago

In case you are referring to the Mapillary Vistas model we shared, you can interpret the class indices as follows. First, load the metadata.bin file we share with the network model and extract some relevant information:

import umsgpack
with open("metadata.bin", "rb") as f:
    metadata = umsgpack.load(f, encoding="utf-8")
    num_stuff = metadata["meta"]["num_stuff"]
    categories = metadata["meta"]["categories"]

Then, you can map from class indices to class names as follows:

# Class name of the i-th detected instance
class_name = categories[num_stuff + cls_pred[i] - 1]

# Name of the class predicted at pixel (i, j) of the segmentation mask
class_name = categories[sem_pred[i, j]]