-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathperformance_figures.py
More file actions
executable file
·51 lines (47 loc) · 2.07 KB
/
performance_figures.py
File metadata and controls
executable file
·51 lines (47 loc) · 2.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import pylab
import numpy as np
def precision_and_recall_figure(precision_curve, recall_curve, model_name):
''' Draw Precision and Recall Figures
Input : precision_curve - the precision values between 0-100% IOU thresholds
recall_curve - the recall values between 0-100% IOU thresholds
Output : precision.png - the precision figure saved in the working directory
recall.png - the recall figure saved in the working directory
f1_score.png - the f1 score figure that combines the precision and recall in one figure
and saves in the working directory
'''
# Plot the overall precision curve w.r.t iou threshold
f_1 = pylab.figure(1)
pylab.plot(precision_curve,label= model_name+' - AP '
+ str(round(precision_curve[50],2)) + ' - mAP '
+ str(round(np.mean(np.array(precision_curve[50:95])),2)))
pylab.ylabel('Precision')
pylab.xlabel('IOU Threshold')
pylab.ylim(0, 1)
pylab.xlim(0, 100)
pylab.legend(loc='lower left')
pylab.savefig('precision.png')
# Plot the overall recall curve w.r.t iou threshold
f_1 = pylab.figure(2)
pylab.plot(recall_curve,label= model_name+' - AR '
+ str(round(recall_curve[50],2)) + ' - mAR '
+ str(round(np.mean(np.array(recall_curve[50:95])),2)))
pylab.ylabel('Recall')
pylab.xlabel('IOU Threshold')
pylab.ylim(0, 1)
pylab.xlim(0, 100)
pylab.legend(loc='lower left')
pylab.savefig('recall.png')
# Plot the overall recall curve w.r.t iou threshold
f_1 = pylab.figure(3)
f1_score = precision_curve*recall_curve*2/(precision_curve+recall_curve+0.0001)
print f1_score
pylab.plot(f1_score,
label= model_name+' - AF1 '
+ str(round(f1_score[50],2)) + ' - mAF1 '
+ str(round(np.mean(np.array(f1_score[50:95])),2)))
pylab.ylabel('F1 Score')
pylab.xlabel('IOU Threshold')
pylab.ylim(0, 1)
pylab.xlim(0, 100)
pylab.legend(loc='lower left')
pylab.savefig('f1_score.png')