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
p = precision_score(targets, predicts)
r = recall_score(targets, predicts)
conf = confusion_matrix(targets, predicts)
bg_mask = np.ones((500, 500, 3)) * 255
cv2.putText(bg_mask, f' authentic tampered ', (20, 50), cv2.FONT_ITALIC, 0.7, (0, 0, 255), 1)
cv2.putText(bg_mask, f'authentic {conf[0, 0]} {conf[0, 1]}', (20, 80), cv2.FONT_ITALIC, 0.7,
(0, 0, 255), 1)
cv2.putText(bg_mask, f'tempered {conf[1, 0]} {conf[1, 1]}', (20, 110), cv2.FONT_ITALIC, 0.7,
(0, 0, 255), 1)
cv2.putText(bg_mask, f'authentic precision:{round(conf[0, 0] / (conf[0, 0] + conf[1, 0]), 3)}', (20, 170),
cv2.FONT_ITALIC, 0.7, (0, 0, 255), 1)
cv2.putText(bg_mask, f' recall:{round(conf[0, 0] / (conf[0, 0] + conf[0, 1]), 3)}', (20, 200),
cv2.FONT_ITALIC, 0.7, (0, 0, 255), 1)
cv2.putText(bg_mask, f'tampered precision:{round(conf[1, 1] / (conf[0, 1] + conf[1, 1]), 3)}', (20, 230),
cv2.FONT_ITALIC, 0.7, (0, 0, 255), 1)
cv2.putText(bg_mask, f' recall:{round(conf[1, 1] / (conf[1, 0] + conf[1, 1]), 3)}', (20, 260),
cv2.FONT_ITALIC, 0.7, (0, 0, 255), 1)
cv2.imwrite(f'pr_result.jpg', bg_mask)
print('precison:', p)
print('recall:', r)
print(conf)
print(f' 预 测 ')
print(f' authentic tampered ')
print(f'真 authentic \t\t{conf[0, 0]} \t\t{conf[0,1]}')
print(f'实 tempered \t\t{conf[1, 0]} \t\t\t{conf[1,1]}')
print(f'authentic precision:{conf[0,0]/(conf[0,0]+conf[1,0])}\trecall:{conf[0, 0]/(conf[0, 0]+conf[0, 1])}')
print(f'tampered precision:{conf[1, 1]/(conf[0, 1]+conf[1, 1])}\trecall:{conf[1, 1]/(conf[1, 0]+conf[1, 1])}')
print(f'真 authentic \t\t{conf[0, 0]} \t\t{conf[0, 1]}')
print(f'实 tempered \t\t{conf[1, 0]} \t\t\t{conf[1, 1]}')
print(
f'authentic precision:{conf[0, 0] / (conf[0, 0] + conf[1, 0])}\trecall:{conf[0, 0] / (conf[0, 0] + conf[0, 1])}')
print(
f'tampered precision:{conf[1, 1] / (conf[0, 1] + conf[1, 1])}\trecall:{conf[1, 1] / (conf[1, 0] + conf[1, 1])}')
if __name__ == '__main__':
true_image_path = '/data/situ_invoice_bill_data/qfs_train_val_data/gongshang/images/val'
true_label_path = '/data/situ_invoice_bill_data/qfs_train_val_data/gongshang/labels/val'
predict_label_path = '/home/situ/qfs/invoice_tamper/09_project/project/tamper_det/runs/detect/exp4/labels'
true_image_path = '/data/situ_invoice_bill_data/qfs_train_val_data/test_data/only_human_ps/all/images'
true_label_path = '/data/situ_invoice_bill_data/qfs_train_val_data/test_data/only_human_ps/all/labels'
predict_label_path = '/home/situ/qfs/invoice_tamper/09_project/project/tamper_det/runs/detect/exp2/labels'
threshold = 0.1
get_evaluate_score(true_image_path, true_label_path, predict_label_path, threshold)
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!