我实现了如下IOU:
import numpy as np
EPS = 1e-12
def get_iou( gt , pr , n_classes ):
class_wise = np.zeros(n_classes)
for cl in range(n_classes):
intersection = np.sum(( gt == cl )*( pr == cl ))
union = np.sum(np.maximum( ( gt == cl ) , ( pr == cl ) ))
iou = float(intersection)/( union + EPS )
class_wise[ cl ] = iou
return class_wise
然后像这样使用它:
for l,y in zip(gt_label_list,network_prediction):
gt=cv2.imread(l,0)
pr=y
iou.append(get_iou(gt,pr,num_classes=20))
ious = np.array(iou)
print("Class wise IoU near" , np.mean(ious , axis=0 ))
print("Total IoU near" , np.mean(ious ))
但是,即使我为相同的图像(cityscapes 500验证图像集)馈送gt和pr时,总IOU也不合理:
Class wise IoU near [0.968 0.932 0.982 0.404 0.378 0.982 0.582 0.946 0.972 0.482 0.886 0.804 0.506 0.958 0.16 0.15 0.044 0.186 0.69 1. ]
Total IoU near 0.6505999999999998
我知道有些类并没有出现在一些图片中,但这篇文章是如何报告MIoUs超过70%的呢
目前没有回答
相关问题 更多 >
编程相关推荐