Commit 03ee04d0 authored by Amir MOHAMMADI's avatar Amir MOHAMMADI

make commands more suitable for bob.bio and bob.pad

parent a56c4d88
Pipeline #21204 passed with stage
in 15 minutes and 22 seconds
...@@ -7,7 +7,7 @@ from . import common_options ...@@ -7,7 +7,7 @@ from . import common_options
SCORE_FORMAT = ( SCORE_FORMAT = (
"The command takes as input generic 2-column data format as " "The command takes as input generic 2-column data format as "
"specified in the documentation of "":py:func:`bob.measure.load.split`") "specified in the documentation of "":py:func:`bob.measure.load.split`.")
CRITERIA = ('eer', 'min-hter', 'far') CRITERIA = ('eer', 'min-hter', 'far')
......
...@@ -182,6 +182,9 @@ class Metrics(MeasureBase): ...@@ -182,6 +182,9 @@ class Metrics(MeasureBase):
if self._log is not None: if self._log is not None:
self.log_file = open(self._log, self._open_mode) self.log_file = open(self._log, self._open_mode)
def get_thres(self, criterion, dev_neg, dev_pos, far):
return utils.get_thres(criterion, dev_neg, dev_pos, far)
def compute(self, idx, input_scores, input_names): def compute(self, idx, input_scores, input_names):
''' Compute metrics thresholds and tables (FAR, FMR, FNMR, HTER) for ''' Compute metrics thresholds and tables (FAR, FMR, FNMR, HTER) for
given system inputs''' given system inputs'''
...@@ -192,7 +195,7 @@ class Metrics(MeasureBase): ...@@ -192,7 +195,7 @@ class Metrics(MeasureBase):
eval_neg, eval_pos, eval_fta = neg_list[1], pos_list[1], fta_list[1] eval_neg, eval_pos, eval_fta = neg_list[1], pos_list[1], fta_list[1]
eval_file = input_names[1] eval_file = input_names[1]
threshold = utils.get_thres(self._criterion, dev_neg, dev_pos, self._far) \ threshold = self.get_thres(self._criterion, dev_neg, dev_pos, self._far) \
if self._thres is None else self._thres[idx] if self._thres is None else self._thres[idx]
title = self._legends[idx] if self._legends is not None else None title = self._legends[idx] if self._legends is not None else None
if self._thres is None: if self._thres is None:
...@@ -523,13 +526,13 @@ class Det(PlotBase): ...@@ -523,13 +526,13 @@ class Det(PlotBase):
class Epc(PlotBase): class Epc(PlotBase):
''' Handles the plotting of EPC ''' ''' Handles the plotting of EPC '''
def __init__(self, ctx, scores, evaluation, func_load): def __init__(self, ctx, scores, evaluation, func_load, hter='HTER'):
super(Epc, self).__init__(ctx, scores, evaluation, func_load) super(Epc, self).__init__(ctx, scores, evaluation, func_load)
if self._min_arg != 2: if self._min_arg != 2:
raise click.UsageError("EPC requires dev and eval score files") raise click.UsageError("EPC requires dev and eval score files")
self._titles = self._titles or ['EPC'] * 2 self._titles = self._titles or ['EPC'] * 2
self._x_label = self._x_label or r'$\alpha$' self._x_label = self._x_label or r'$\alpha$'
self._y_label = self._y_label or 'HTER (%)' self._y_label = self._y_label or hter + ' (%)'
self._legend_loc = self._legend_loc or 'upper center' self._legend_loc = self._legend_loc or 'upper center'
self._eval = True # always eval data with EPC self._eval = True # always eval data with EPC
self._split = False self._split = False
...@@ -597,7 +600,6 @@ class Hist(PlotBase): ...@@ -597,7 +600,6 @@ class Hist(PlotBase):
self._print_subplot(idx, eval_neg, eval_pos, threshold, self._print_subplot(idx, eval_neg, eval_pos, threshold,
not self._no_line, dflt_title="Eval scores") not self._no_line, dflt_title="Eval scores")
def _print_subplot(self, idx, neg, pos, threshold, draw_line, dflt_title): def _print_subplot(self, idx, neg, pos, threshold, draw_line, dflt_title):
n = idx % self._step_print n = idx % self._step_print
col = n % self._ncols col = n % self._ncols
...@@ -629,7 +631,7 @@ class Hist(PlotBase): ...@@ -629,7 +631,7 @@ class Hist(PlotBase):
def _get_title(self, idx, dflt=None): def _get_title(self, idx, dflt=None):
title = self._legends[idx] if self._legends is not None \ title = self._legends[idx] if self._legends is not None \
and idx < len(self._legends) else dflt and idx < len(self._legends) else dflt
title = title or self._title_base title = title or self._title_base
title = '' if title is not None and not title.replace( title = '' if title is not None and not title.replace(
' ', '') else title ' ', '') else title
......
...@@ -93,4 +93,4 @@ def gen(outdir, mean_neg, mean_pos): ...@@ -93,4 +93,4 @@ def gen(outdir, mean_neg, mean_pos):
write_scores_to_file(neg_dev, pos_dev, write_scores_to_file(neg_dev, pos_dev,
os.path.join(outdir, 'scores-dev')) os.path.join(outdir, 'scores-dev'))
write_scores_to_file(neg_eval, pos_eval, write_scores_to_file(neg_eval, pos_eval,
os.path.join(outdir, 'scores-eval')) os.path.join(outdir, 'scores-eval'))
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment