本文主要是介绍mmdetection如何计算准确率、召回率、F1值,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
1、训练
python tools/train.py configs/fcos/fcosrdweed3.py
2、测试
这一步要加–out=result.pkl,才能计算准确率和召回率
python tools/test.py configs/fcos/fcosrddweed3.py work_dirs/fcosrddweed3/epoch_300.pth --out=resultfcos.pkl
3、计算准确率和召回率
在tools/analysis_tools/confusion_matrix.py代码下面加上:
TP = np.diag(confusion_matrix)FP = np.sum(confusion_matrix, axis=0) - TPFN = np.sum(confusion_matrix, axis=1) - TPprecision = TP / (TP + FP)recall = TP / (TP + FN)average_precision = np.mean(precision)average_recall = np.mean(recall)f1 = 2 * (average_precision * average_recall) / (average_precision + average_recall)#print("AP ", average_precision)#print("AR", average_recall)#print("F1", f1)print("P",precision)print("R",recall)
运行:
python tools/analysis_tools/confusion_matrix.py configs/fcos/fcosrddweed3.py resultfcos.pkl ./
拿下:
这篇关于mmdetection如何计算准确率、召回率、F1值的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!