How to compute the mean IU (mean Intersection over Union) score as in this paper?
Long, Jonathan, Evan Shelhamer, and Trevor Darrell. "Fully Convolutional Networks for Semantic Segmentation."
How to compute the mean IU (mean Intersection over Union) score as in this paper?
Long, Jonathan, Evan Shelhamer, and Trevor Darrell. "Fully Convolutional Networks for Semantic Segmentation."
各クラスのIntersection over Union (IU) スコアは次のとおりです。
真陽性 / (真陽性 + 偽陽性 + 偽陰性)
平均 IUは、単にすべてのクラスの平均です。
論文中の表記について:
n_ij :クラスjに属すると予測されるクラスiのピクセル数。したがって、クラスiの場合:
これを直接計算するための matlab コードは、こちらの Pascak DevKitにあります。
これは役立つはずです
def computeIoU(y_pred_batch, y_true_batch):
return np.mean(np.asarray([pixelAccuracy(y_pred_batch[i], y_true_batch[i]) for i in range(len(y_true_batch))]))
def pixelAccuracy(y_pred, y_true):
y_pred = np.argmax(np.reshape(y_pred,[N_CLASSES_PASCAL,img_rows,img_cols]),axis=0)
y_true = np.argmax(np.reshape(y_true,[N_CLASSES_PASCAL,img_rows,img_cols]),axis=0)
y_pred = y_pred * (y_true>0)
return 1.0 * np.sum((y_pred==y_true)*(y_true>0)) / np.sum(y_true>0)