Commit b63237ce authored by Amir MOHAMMADI's avatar Amir MOHAMMADI

nit

parent 2ddbe247
Pipeline #19959 canceled with stage
in 6 minutes and 28 seconds
...@@ -6,6 +6,7 @@ from bob.extension.scripts.click_helper import verbosity_option ...@@ -6,6 +6,7 @@ from bob.extension.scripts.click_helper import verbosity_option
from bob.bio.base.score import load from bob.bio.base.score import load
from . import figure from . import figure
@click.command() @click.command()
@common_options.scores_argument(min_arg=2, force_eval=True, nargs=-1) @common_options.scores_argument(min_arg=2, force_eval=True, nargs=-1)
@common_options.output_plot_file_option(default_out='det.pdf') @common_options.output_plot_file_option(default_out='det.pdf')
...@@ -31,23 +32,23 @@ from . import figure ...@@ -31,23 +32,23 @@ from . import figure
help='If False, will annotate the plots hypothetically, instead ' help='If False, will annotate the plots hypothetically, instead '
'of with real data values of the calculated error rates.') 'of with real data values of the calculated error rates.')
@click.pass_context @click.pass_context
def det(ctx, scores, criteria, real_data, **kwargs): def det(ctx, scores, criteria, real_data, **kwargs):
"""Plot DET """Plot DET
You need to provide 2 or 4 scores You need to provide 2 or 4 scores
files for each PAD system in this order: files for each PAD system in this order:
\b \b
* licit development scores * licit development scores
* licit evaluation scores * licit evaluation scores
* spoof development scores (when ``--no-spoof`` is False (default)) * spoof development scores (when ``--no-spoof`` is False (default))
* spoof evaluation scores (when ``--no-spoof`` is False (default)) * spoof evaluation scores (when ``--no-spoof`` is False (default))
Examples: Examples:
$ bob pad det --no-spoof dev-scores eval-scores $ bob pad det --no-spoof dev-scores eval-scores
$ bob pad det {licit,spoof}/scores-{dev,eval} $ bob pad det {licit,spoof}/scores-{dev,eval}
""" """
process = figure.Det(ctx, scores, True, load.split, criteria, real_data) process = figure.Det(ctx, scores, True, load.split, criteria, real_data)
process.run() process.run()
...@@ -6,6 +6,7 @@ from bob.extension.scripts.click_helper import verbosity_option ...@@ -6,6 +6,7 @@ from bob.extension.scripts.click_helper import verbosity_option
from bob.bio.base.score import load from bob.bio.base.score import load
from . import figure from . import figure
@click.command() @click.command()
@common_options.scores_argument(min_arg=2, force_eval=True, nargs=-1) @common_options.scores_argument(min_arg=2, force_eval=True, nargs=-1)
@common_options.output_plot_file_option(default_out='epc.pdf') @common_options.output_plot_file_option(default_out='epc.pdf')
...@@ -49,6 +50,7 @@ def epc(ctx, scores, **kwargs): ...@@ -49,6 +50,7 @@ def epc(ctx, scores, **kwargs):
process = figure.Epc(ctx, scores, True, load.split) process = figure.Epc(ctx, scores, True, load.split)
process.run() process.run()
@click.command() @click.command()
@common_options.scores_argument(min_arg=2, force_eval=True, nargs=-1) @common_options.scores_argument(min_arg=2, force_eval=True, nargs=-1)
@common_options.output_plot_file_option(default_out='epsc.pdf') @common_options.output_plot_file_option(default_out='epsc.pdf')
......
#!/usr/bin/env python #!/usr/bin/env python
#Ivana Chingovska <ivana.chingovska@idiap.ch> # Ivana Chingovska <ivana.chingovska@idiap.ch>
#Fri Dec 7 12:33:37 CET 2012 # Fri Dec 7 12:33:37 CET 2012
"""Utility functions for computation of EPSC curve and related measurement""" """Utility functions for computation of EPSC curve and related measurement"""
import os
import sys
import bob.measure import bob.measure
import numpy import numpy
import argparse
def calc_pass_rate(threshold, attacks): def calc_pass_rate(threshold, attacks):
...@@ -69,7 +66,7 @@ def weighted_neg_error_rate_criteria(data, ...@@ -69,7 +66,7 @@ def weighted_neg_error_rate_criteria(data,
if beta == 0.5: if beta == 0.5:
return abs(far_w - frr) return abs(far_w - frr)
else: else:
#return abs(far_w - frr) # return abs(far_w - frr)
return abs((1 - beta) * frr - beta * far_w) return abs((1 - beta) * frr - beta * far_w)
elif criteria == 'min-hter': elif criteria == 'min-hter':
...@@ -137,7 +134,7 @@ def weighted_negatives_threshold(licit_neg, ...@@ -137,7 +134,7 @@ def weighted_negatives_threshold(licit_neg,
beta=0.5, beta=0.5,
criteria='eer'): criteria='eer'):
"""Calculates the threshold for achieving the given criteria between the """Calculates the threshold for achieving the given criteria between the
FAR_w and the FRR, given the single value for the weight parameter FAR_w and the FRR, given the single value for the weight parameter
balancing between impostors and spoofing attacks and a single value for the balancing between impostors and spoofing attacks and a single value for the
parameter beta balancing between the real accesses and the negatives parameter beta balancing between the real accesses and the negatives
(impostors and spoofing attacks) (impostors and spoofing attacks)
...@@ -205,14 +202,14 @@ def epsc_thresholds(licit_neg, ...@@ -205,14 +202,14 @@ def epsc_thresholds(licit_neg,
spoofing attacks. If None, it is going to span the full range [0,1]. spoofing attacks. If None, it is going to span the full range [0,1].
Otherwise, can be set to a fixed value or a list of values. Otherwise, can be set to a fixed value or a list of values.
- beta - the value of the parameter beta, balancing between real accesses - beta - the value of the parameter beta, balancing between real accesses
and all the negatives (zero-effort impostors and spoofing attacks). If and all the negatives (zero-effort impostors and spoofing attacks). If
None, it is going to span the full range [0,1]. Otherwise, can be set to a None, it is going to span the full range [0,1]. Otherwise, can be set to a
fixed value or a list of values. fixed value or a list of values.
""" """
step_size = 1 / float(points) step_size = 1 / float(points)
if omega == None: if omega is None:
omega = numpy.array([(i * step_size) for i in range(points + 1)]) omega = numpy.array([(i * step_size) for i in range(points + 1)])
elif not isinstance(omega, list) and not isinstance( elif not isinstance(omega, list) and not isinstance(
omega, tuple) and not isinstance(omega, numpy.ndarray): omega, tuple) and not isinstance(omega, numpy.ndarray):
...@@ -220,7 +217,7 @@ def epsc_thresholds(licit_neg, ...@@ -220,7 +217,7 @@ def epsc_thresholds(licit_neg,
else: else:
omega = numpy.array(omega) omega = numpy.array(omega)
if beta == None: if beta is None:
beta = numpy.array([(i * step_size) for i in range(points + 1)]) beta = numpy.array([(i * step_size) for i in range(points + 1)])
elif not isinstance(beta, list) and not isinstance( elif not isinstance(beta, list) and not isinstance(
beta, tuple) and not isinstance(beta, numpy.ndarray): beta, tuple) and not isinstance(beta, numpy.ndarray):
...@@ -288,8 +285,8 @@ negative samples (impostors and spoofing attacks). ...@@ -288,8 +285,8 @@ negative samples (impostors and spoofing attacks).
spoof_neg, spoof_pos, spoof_neg, spoof_pos,
threshold) # calculate test frr @ threshold (spoof scenario) threshold) # calculate test frr @ threshold (spoof scenario)
frr = farfrr_licit[ # we can take this value from farfrr_spoof as well, it doesn't matter
1] # we can take this value from farfrr_spoof as well, it doesn't matter frr = farfrr_licit[1]
far = farfrr_licit[0] far = farfrr_licit[0]
sfar = farfrr_spoof[0] sfar = farfrr_spoof[0]
...@@ -302,8 +299,8 @@ negative samples (impostors and spoofing attacks). ...@@ -302,8 +299,8 @@ negative samples (impostors and spoofing attacks).
def epsc_error_rates(licit_neg, licit_pos, spoof_neg, spoof_pos, thresholds, def epsc_error_rates(licit_neg, licit_pos, spoof_neg, spoof_pos, thresholds,
omega, beta): omega, beta):
"""Calculates several error rates: FAR_w and WER_wb for the given weights """Calculates several error rates: FAR_w and WER_wb for the given weights
(omega and beta) and thresholds (the thresholds need to be computed first (omega and beta) and thresholds (the thresholds need to be computed first
using the method: epsc_thresholds() before passing to this method) using the method: epsc_thresholds() before passing to this method)
Parameters Parameters
...@@ -350,8 +347,8 @@ def epsc_error_rates(licit_neg, licit_pos, spoof_neg, spoof_pos, thresholds, ...@@ -350,8 +347,8 @@ def epsc_error_rates(licit_neg, licit_pos, spoof_neg, spoof_pos, thresholds,
def all_error_rates(licit_neg, licit_pos, spoof_neg, spoof_pos, thresholds, def all_error_rates(licit_neg, licit_pos, spoof_neg, spoof_pos, thresholds,
omega, beta): omega, beta):
"""Calculates several error rates: FAR_w and WER_wb for the given weights """Calculates several error rates: FAR_w and WER_wb for the given weights
(omega and beta) and thresholds (the thresholds need to be computed first (omega and beta) and thresholds (the thresholds need to be computed first
using the method: epsc_thresholds() before passing to this method) using the method: epsc_thresholds() before passing to this method)
Parameters Parameters
...@@ -427,7 +424,7 @@ def calc_aue(licit_neg, ...@@ -427,7 +424,7 @@ def calc_aue(licit_neg,
- h_bound - higher bound of integration - h_bound - higher bound of integration
- points - number of points to calculate EPSC - points - number of points to calculate EPSC
- criteria - the decision threshold criteria ('eer', 'wer' or 'min-hter') - criteria - the decision threshold criteria ('eer', 'wer' or 'min-hter')
- var_param - name of the parameter which is varied on the abscissa - var_param - name of the parameter which is varied on the abscissa
('omega' or 'beta') ('omega' or 'beta')
""" """
......
...@@ -3,10 +3,10 @@ experiements ...@@ -3,10 +3,10 @@ experiements
""" """
import click import click
from bob.measure.script import common_options from bob.measure.script import common_options
from bob.extension.scripts.click_helper import (verbosity_option, bool_option) from bob.extension.scripts.click_helper import verbosity_option
from bob.bio.base.score import load
import bob.bio.base.script.commands as bio_commands import bob.bio.base.script.commands as bio_commands
from . import (figure, histograms, metrics, det, fmr_iapmr, epc) from . import (histograms, metrics, det, fmr_iapmr, epc)
@click.command() @click.command()
@common_options.scores_argument(nargs=-1) @common_options.scores_argument(nargs=-1)
...@@ -99,8 +99,8 @@ def vuln(ctx, scores, **kwargs): ...@@ -99,8 +99,8 @@ def vuln(ctx, scores, **kwargs):
\b \b
1. Computes bob pad vuln_metrics 1. Computes bob pad vuln_metrics
2. Plots EPC, EPSC, vulnerability histograms, fmr vs IAPMR to a multi-page PDF 2. Plots EPC, EPSC, vulnerability histograms, fmr vs IAPMR to a multi-page
file PDF file
You need to provide 4 score files for each biometric system in this order: You need to provide 4 score files for each biometric system in this order:
......
This diff is collapsed.
...@@ -6,6 +6,7 @@ from bob.extension.scripts.click_helper import verbosity_option ...@@ -6,6 +6,7 @@ from bob.extension.scripts.click_helper import verbosity_option
from bob.bio.base.score import load from bob.bio.base.score import load
from . import figure from . import figure
@click.command() @click.command()
@common_options.scores_argument(min_arg=2, force_eval=True, nargs=-1) @common_options.scores_argument(min_arg=2, force_eval=True, nargs=-1)
@common_options.output_plot_file_option(default_out='fmr_iapmr.pdf') @common_options.output_plot_file_option(default_out='fmr_iapmr.pdf')
......
...@@ -6,6 +6,7 @@ from bob.extension.scripts.click_helper import (verbosity_option, bool_option) ...@@ -6,6 +6,7 @@ from bob.extension.scripts.click_helper import (verbosity_option, bool_option)
from bob.bio.base.score import load from bob.bio.base.score import load
from . import figure from . import figure
@click.command() @click.command()
@common_options.scores_argument(nargs=-1) @common_options.scores_argument(nargs=-1)
@common_options.title_option() @common_options.title_option()
...@@ -27,13 +28,13 @@ def hist(ctx, scores, evaluation, **kwargs): ...@@ -27,13 +28,13 @@ def hist(ctx, scores, evaluation, **kwargs):
""" Plots histograms of Bona fida and PA along with threshold """ Plots histograms of Bona fida and PA along with threshold
criterion. criterion.
You need to provide one or more development score file(s) for each experiment. You need to provide one or more development score file(s) for each
You can also provide eval files along with dev files. If only dev scores experiment. You can also provide eval files along with dev files. If only
are provided, you must use flag `--no-evaluation`. dev scores are provided, you must use flag `--no-evaluation`.
By default, when eval-scores are given, only eval-scores histograms are By default, when eval-scores are given, only eval-scores histograms are
displayed with threshold line displayed with threshold line
computed from dev-scores. If you want to display dev-scores distributions computed from dev-scores. If you want to display dev-scores distributions
as well, use ``--show-dev`` option. as well, use ``--show-dev`` option.
Examples: Examples:
...@@ -47,6 +48,7 @@ def hist(ctx, scores, evaluation, **kwargs): ...@@ -47,6 +48,7 @@ def hist(ctx, scores, evaluation, **kwargs):
process = figure.HistPad(ctx, scores, evaluation, load.split) process = figure.HistPad(ctx, scores, evaluation, load.split)
process.run() process.run()
@click.command() @click.command()
@common_options.scores_argument(nargs=-1, min_arg=2) @common_options.scores_argument(nargs=-1, min_arg=2)
@common_options.title_option() @common_options.title_option()
...@@ -87,10 +89,10 @@ def vuln_hist(ctx, scores, evaluation, **kwargs): ...@@ -87,10 +89,10 @@ def vuln_hist(ctx, scores, evaluation, **kwargs):
See :ref:`bob.pad.base.vulnerability` in the documentation for a guide on See :ref:`bob.pad.base.vulnerability` in the documentation for a guide on
vulnerability analysis. vulnerability analysis.
You need to provide one or more development score file(s) for each experiment. You need to provide one or more development score file(s) for each
You can also provide eval files along with dev files. If only dev-scores experiment. You can also provide eval files along with dev files. If only
are used set the flag `--no-evaluation` dev-scores are used set the flag `--no-evaluation` is required in that
is required in that case. case.
By default, when eval-scores are given, only eval-scores histograms are By default, when eval-scores are given, only eval-scores histograms are
displayed with threshold line displayed with threshold line
......
...@@ -7,6 +7,7 @@ from bob.extension.scripts.click_helper import (verbosity_option, ...@@ -7,6 +7,7 @@ from bob.extension.scripts.click_helper import (verbosity_option,
from bob.bio.base.score import load from bob.bio.base.score import load
from . import figure from . import figure
@click.command(context_settings=dict(token_normalize_func=lambda x: x.lower())) @click.command(context_settings=dict(token_normalize_func=lambda x: x.lower()))
@common_options.scores_argument(nargs=-1) @common_options.scores_argument(nargs=-1)
@common_options.eval_option() @common_options.eval_option()
...@@ -20,7 +21,8 @@ def metrics(ctx, scores, evaluation, **kwargs): ...@@ -20,7 +21,8 @@ def metrics(ctx, scores, evaluation, **kwargs):
"""PAD ISO compliant metrics. """PAD ISO compliant metrics.
Reports several metrics based on a selected thresholds on the development Reports several metrics based on a selected thresholds on the development
set and apply them on evaluation sets (if provided). The used thresholds are: set and apply them on evaluation sets (if provided). The used thresholds
are:
bpcer20 When APCER is set to 5%. bpcer20 When APCER is set to 5%.
...@@ -52,6 +54,7 @@ def metrics(ctx, scores, evaluation, **kwargs): ...@@ -52,6 +54,7 @@ def metrics(ctx, scores, evaluation, **kwargs):
process = figure.Metrics(ctx, scores, evaluation, load.split) process = figure.Metrics(ctx, scores, evaluation, load.split)
process.run() process.run()
@click.command(context_settings=dict(token_normalize_func=lambda x: x.lower())) @click.command(context_settings=dict(token_normalize_func=lambda x: x.lower()))
@common_options.scores_argument(min_arg=2, force_eval=True, nargs=-1) @common_options.scores_argument(min_arg=2, force_eval=True, nargs=-1)
@common_options.eval_option() @common_options.eval_option()
......
...@@ -8,5 +8,5 @@ from click_plugins import with_plugins ...@@ -8,5 +8,5 @@ from click_plugins import with_plugins
@with_plugins(pkg_resources.iter_entry_points('bob.pad.cli')) @with_plugins(pkg_resources.iter_entry_points('bob.pad.cli'))
@click.group() @click.group()
def pad(): def pad():
"""Entry for bob.pad commands.""" """Presentation Attack Detection related commands."""
pass pass
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