65a9577f by 乔峰昇

add draw pr_result.jpg

1 parent f43822ca
Showing 1 changed file with 27 additions and 7 deletions
...@@ -61,18 +61,38 @@ def get_evaluate_score(true_image_path, true_label_path, predict_label_path, thr ...@@ -61,18 +61,38 @@ def get_evaluate_score(true_image_path, true_label_path, predict_label_path, thr
61 p = precision_score(targets, predicts) 61 p = precision_score(targets, predicts)
62 r = recall_score(targets, predicts) 62 r = recall_score(targets, predicts)
63 conf = confusion_matrix(targets, predicts) 63 conf = confusion_matrix(targets, predicts)
64 bg_mask = np.ones((500, 500, 3)) * 255
65 cv2.putText(bg_mask, f' authentic tampered ', (20, 50), cv2.FONT_ITALIC, 0.7, (0, 0, 255), 1)
66 cv2.putText(bg_mask, f'authentic {conf[0, 0]} {conf[0, 1]}', (20, 80), cv2.FONT_ITALIC, 0.7,
67 (0, 0, 255), 1)
68 cv2.putText(bg_mask, f'tempered {conf[1, 0]} {conf[1, 1]}', (20, 110), cv2.FONT_ITALIC, 0.7,
69 (0, 0, 255), 1)
70 cv2.putText(bg_mask, f'authentic precision:{round(conf[0, 0] / (conf[0, 0] + conf[1, 0]), 3)}', (20, 170),
71 cv2.FONT_ITALIC, 0.7, (0, 0, 255), 1)
72 cv2.putText(bg_mask, f' recall:{round(conf[0, 0] / (conf[0, 0] + conf[0, 1]), 3)}', (20, 200),
73 cv2.FONT_ITALIC, 0.7, (0, 0, 255), 1)
74 cv2.putText(bg_mask, f'tampered precision:{round(conf[1, 1] / (conf[0, 1] + conf[1, 1]), 3)}', (20, 230),
75 cv2.FONT_ITALIC, 0.7, (0, 0, 255), 1)
76 cv2.putText(bg_mask, f' recall:{round(conf[1, 1] / (conf[1, 0] + conf[1, 1]), 3)}', (20, 260),
77 cv2.FONT_ITALIC, 0.7, (0, 0, 255), 1)
78 cv2.imwrite(f'pr_result.jpg', bg_mask)
64 print('precison:', p) 79 print('precison:', p)
65 print('recall:', r) 80 print('recall:', r)
66 print(conf) 81 print(conf)
67 print(f' 预 测 ') 82 print(f' 预 测 ')
68 print(f' authentic tampered ') 83 print(f' authentic tampered ')
69 print(f'真 authentic \t\t{conf[0, 0]} \t\t{conf[0,1]}') 84 print(f'真 authentic \t\t{conf[0, 0]} \t\t{conf[0, 1]}')
70 print(f'实 tempered \t\t{conf[1, 0]} \t\t\t{conf[1,1]}') 85 print(f'实 tempered \t\t{conf[1, 0]} \t\t\t{conf[1, 1]}')
71 print(f'authentic precision:{conf[0,0]/(conf[0,0]+conf[1,0])}\trecall:{conf[0, 0]/(conf[0, 0]+conf[0, 1])}') 86 print(
72 print(f'tampered precision:{conf[1, 1]/(conf[0, 1]+conf[1, 1])}\trecall:{conf[1, 1]/(conf[1, 0]+conf[1, 1])}') 87 f'authentic precision:{conf[0, 0] / (conf[0, 0] + conf[1, 0])}\trecall:{conf[0, 0] / (conf[0, 0] + conf[0, 1])}')
88 print(
89 f'tampered precision:{conf[1, 1] / (conf[0, 1] + conf[1, 1])}\trecall:{conf[1, 1] / (conf[1, 0] + conf[1, 1])}')
90
91
73 if __name__ == '__main__': 92 if __name__ == '__main__':
74 true_image_path = '/data/situ_invoice_bill_data/qfs_train_val_data/gongshang/images/val' 93 true_image_path = '/data/situ_invoice_bill_data/qfs_train_val_data/test_data/only_human_ps/all/images'
75 true_label_path = '/data/situ_invoice_bill_data/qfs_train_val_data/gongshang/labels/val' 94 true_label_path = '/data/situ_invoice_bill_data/qfs_train_val_data/test_data/only_human_ps/all/labels'
76 predict_label_path = '/home/situ/qfs/invoice_tamper/09_project/project/tamper_det/runs/detect/exp4/labels' 95 predict_label_path = '/home/situ/qfs/invoice_tamper/09_project/project/tamper_det/runs/detect/exp2/labels'
77 threshold = 0.1 96 threshold = 0.1
78 get_evaluate_score(true_image_path, true_label_path, predict_label_path, threshold) 97 get_evaluate_score(true_image_path, true_label_path, predict_label_path, threshold)
98
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!