xiaoyufenfei / Efficient-Segmentation-Networks

Lightweight models for real-time semantic segmentationon PyTorch (include SQNet, LinkNet, SegNet, UNet, ENet, ERFNet, EDANet, ESPNet, ESPNetv2, LEDNet, ESNet, FSSNet, CGNet, DABNet, Fast-SCNN, ContextNet, FPENet, etc.)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

About metric mistake, recall and precison

DCC-lzhy opened this issue · comments

# Pii为预测正确的数量,Pij和Pji分别被解释为假正和假负,尽管两者都是假正与假负之和
def recall(self): # 预测为正确的像素中确认为正确像素的个数
recall = 0.0
for i in range(self.nclass):
recall += self.M[i, i] / np.sum(self.M[:, i])
return recall / self.nclass
def accuracy(self): # 分割正确的像素除以总像素
accuracy = 0.0
for i in range(self.nclass):
accuracy += self.M[i, i] / np.sum(self.M[i, :])
return accuracy / self.nclass

it's reverse.
` # 理解混淆矩阵生成的代码的关键,行为真实值,列为预测值
# Pii为预测正确的数量,Pij=FN, Pji=FP
# 每一列之和表示被预测为该类别的样本数量 = TP+FP, precision = TP/(TP+FP), 所有被预测为正类中真正正类的比例
# 每一行之和表示该类别的真实样本数量 = TP+FN, recall = TP/TP+FN , 所有正类中,被找出的正类的比例

def recall(self):
    recall = 0.0
    class_recall = []
    for i in range(self.nclass):
        recall_i = self.M[i, i] / np.sum(self.M[i, :])
        recall += recall_i
        class_recall.append(recall_i)
    return recall / self.nclass, class_recall

def accuracy(self):
    accuracy = 0.0
    class_accuracy = []
    for i in range(self.nclass):
        accuracy_i = self.M[i, i] / np.sum(self.M[:, i])
        accuracy += accuracy_i
        class_accuracy.append(accuracy_i)
    return accuracy / self.nclass, class_accuracy`

So, change

recall += self.M[i, i] / np.sum(self.M[:, i])
and
accuracy += self.M[i, i] / np.sum(self.M[i, :])

@DCC-lzhy Yes, I think your analysis makes sense. But this project may still use mIoU, so this may be less noticed. And it should be called "precision" here.