Skip to content
Advertisement

How to get iou of single class in keras semantic segmentation?

I am using the Image segmentation guide by fchollet to perform semantic segmentation. I have attempted modifying the guide to suit my dataset by labelling the 8-bit img mask values into 1 and 2 like in the Oxford Pets dataset. (which will be subtracted to 0 and 1 in class OxfordPets(keras.utils.Sequence):)

Question is how do I get the IoU metric of a single class (e.g 1)?

I have tried different metrics suggested by Stack Overflow but most of suggest using MeanIoU which I tried but I have gotten nan loss as a result. Here is an example of a mask after using autocontrast. PIL.ImageOps.autocontrast(load_img(val_target_img_paths[i])) enter image description here

The model seems to train well but the accuracy was decreasing over time.

Also, can someone help explain how the metric score can be calculated from y_true and y_pred? I don’t quite fully understand when the label value is used in the IoU metric calculation.

Advertisement

Answer

I had a similar problem back then. I used jaccard_distance_loss and dice_metric. They are based on IoU. My task was a binary segmentation, so I guess you might have to modify the code in case you want to use it for a multi-label classification problem.

JavaScript
JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement