How to find IoU from segmentation masks?

别说谁变了你拦得住时间么 提交于 2019-12-24 00:38:02

问题


I am doing an image segmentation task and I am using a dataset that only has ground truths but no bounding boxes or polygons.

I have 2 classes( ignoring 0 for background) and the outputs and ground truth labels are in an array like

Predicted--/---Labels

0|0|0|1|2 0|0|0|1|2 0|2|1|0|0 0|2|1|0|0 0|0|1|1|1 0|0|1|1|1 0|0|0|0|1 0|0|0|0|1

How do I calculate IoU from these ?

PS: I am using python3 with pytorch api


回答1:


So I just found out that jaccard_similarity_score is regarded as IoU.

So the solution is very simple,

from sklearn.metrics import jaccard_similarity_score jac = jaccard_similarity_score(predictions, label, Normalize = True/False)

Source link: https://scikit-learn.org/stable/modules/generated/sklearn.metrics.jaccard_score.html#sklearn.metrics.jaccard_score



来源:https://stackoverflow.com/questions/51115630/how-to-find-iou-from-segmentation-masks

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!