akolesnikoff / SEC

Seed, Expand, Constrain: Three Principles for Weakly-Supervised Image Segmentation
MIT License
244 stars 69 forks source link

Format of localization cues #2

Closed ramprs closed 7 years ago

ramprs commented 7 years ago

Hi, This is an interesting work. I am confused as to what format the contents of the localization_cues pickle file are in. I understand that datafile['id_labels'] contains a list of present categories, but what about the datafile['id_cues']? I also understand that you compute the foreground localization cues using CAM, but I am not sure about the format it is stored. If it is easy could you please share the code you used for creating the pickle file?

kolesman commented 7 years ago

Hi,

In order to save disk space I use sparse format to store the localization cues.

Every column of "datafile['id_cues']" encodes a location (2nd and 3rd value) in an image, which was marked by a certain semantic class (1st value).

If you want to restore localization cues in a dense form you should do something like this:

sparse_mask = datafile['id_cues']
dense_mask = np.zeros((21, 41, 41))  # dense_mask[i] represents segm. mask for class i
dense_mask[sparse_mask[0], sparse_mask[1], sparse_mask[2]] = 1.0