Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
447 views
in Technique[技术] by (71.8m points)

python - 如何比较基础知识和深度学习的预测图像(How to compare ground truth and predicted images of deep learning)

I have two lists which contain ground truth and predicted images.

(我有两个列表,其中包含基本事实和预测图像。)

Both lists contains binary images.

(两个列表都包含二进制图像。)

I need to obtain accuracy,f1-score,recall and precision reports between those two lists.

(我需要获取这两个列表之间的准确性,f1-分数,召回率和准确性报告。)

sklearn.metrics.classification_report can be used to obtain the classification reports between prediction and truth values but it only accepts 1-d arrays.

(sklearn.metrics.classification_report可用于获取预测值和真值之间的分类报告,但仅接受一维数组。)

http://scikit-learn.org/stable/modules/generated/sklearn.metrics.classification_report.html

(http://scikit-learn.org/stable/modules/generation/sklearn.metrics.classification_report.html)

How to modify it to obtain the classification reports between two image lists which contain binary images?

(如何修改它以获得包含二进制图像的两个图像列表之间的分类报告?)

Or is there a better way to perform this?

(还是有更好的方法来执行此操作?)

My code :

(我的代码:)

import os
import cv2
import numpy as np 
from sklearn.metrics import confusion_matrix 
from sklearn.metrics import accuracy_score 
from sklearn.metrics import classification_report

path_pred = "absolute_path/pred"
pred_list = next(os.walk(path_pred))[2]

true_list_new=[]
pred_list_new=[]

for img in pred_list:
    pred_img=cv2.imread("absolute_path/pred/%s" % img)
    true_img=cv2.imread("absolute_path/true/%s" % img)
    true_list_new.append(true_img)
    pred_list_new.append(pred_img)

print("Confusion Matrix: ", 
      confusion_matrix(true_list_new, pred_list_new)) 

print ("Accuracy : ", 
       accuracy_score(true_list_new,pred_list_new)*100) 

print("Report : ", 
      classification_report(true_list_new, pred_list_new))
  ask by harinsamaranayake translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...