1010import scipy .io as sio
1111from sklearn import *
1212import matplotlib .pyplot as plt
13+ import os
1314
1415
15- def Plot_ROC_Fn (label ,distance ,phase ):
1616
17- fpr , tpr , thresholds = metrics .roc_curve (label , - distance , pos_label = 1 )
18- AUC = metrics .roc_auc_score (label , - distance , average = 'macro' , sample_weight = None )
17+ def Plot_ROC_Fn (label ,distance ,save_path ):
18+
19+ fpr , tpr , thresholds = metrics .roc_curve (label , distance , pos_label = 1 )
20+ AUC = metrics .roc_auc_score (label , distance , average = 'macro' , sample_weight = None )
1921 # AP = metrics.average_precision_score(label, -distance, average='macro', sample_weight=None)
2022
2123 # Calculating EER
@@ -37,7 +39,7 @@ def Plot_ROC_Fn(label,distance,phase):
3739 plt .setp (lines , linewidth = 2 , color = 'r' )
3840 ax .set_xticks (np .arange (0 , 1.1 , 0.1 ))
3941 ax .set_yticks (np .arange (0 , 1.1 , 0.1 ))
40- plt .title (phase + '_' + 'ROC.jpg' )
42+ plt .title ('ROC.jpg' )
4143 plt .xlabel ('False Positive Rate' )
4244 plt .ylabel ('True Positive Rate' )
4345
@@ -52,7 +54,32 @@ def Plot_ROC_Fn(label,distance,phase):
5254 # plt.text(0.5, 0.4, 'EER = ' + str(EER), fontdict=None)
5355 plt .grid ()
5456 plt .show ()
55- fig .savefig (phase + '_' + 'ROC.jpg' )
57+ fig .savefig (save_path )
58+
59+ if __name__ == '__main__' :
60+
61+ tf .app .flags .DEFINE_string (
62+ 'evaluation_dir' , '../../results/SCORES' ,
63+ 'Directory where checkpoints and event logs are written to.' )
64+
65+ tf .app .flags .DEFINE_string (
66+ 'plot_dir' , '../../results/PLOTS' ,
67+ 'Directory where plots are saved to.' )
68+
69+ # Store all elemnts in FLAG structure!
70+ FLAGS = tf .app .flags .FLAGS
71+
72+ # Loading scores and labels
73+ score = np .load (os .path .join (FLAGS .evaluation_dir ,'score_vector.npy' ))
74+ label = np .load (os .path .join (FLAGS .evaluation_dir ,'target_label_vector.npy' ))
75+ save_path = os .path .join (FLAGS .plot_dir ,'ROC.jpg' )
76+
77+ # Creating the path
78+ if not os .path .exists (FLAGS .plot_dir ):
79+ os .makedirs (FLAGS .plot_dir )
80+
81+ Plot_ROC_Fn (label ,score ,save_path )
82+
5683
5784
5885
0 commit comments