pad_commands.py 2.9 KB
Newer Older
Amir MOHAMMADI's avatar
Amir MOHAMMADI committed
1
"""The main entry for bob pad commands.
2 3 4
"""
import click
from bob.measure.script import common_options
Amir MOHAMMADI's avatar
Amir MOHAMMADI committed
5
from bob.extension.scripts.click_helper import verbosity_option
6 7 8
import bob.bio.base.script.gen as bio_gen
import bob.measure.script.figure as measure_figure
from bob.bio.base.score import load
Amir MOHAMMADI's avatar
Amir MOHAMMADI committed
9
from . import pad_figure as figure
10

Amir MOHAMMADI's avatar
Amir MOHAMMADI committed
11 12 13 14
SCORE_FORMAT = (
    "Files must be 4-col format, see "
    ":py:func:`bob.bio.base.score.load.four_column`.")
CRITERIA = ('eer', 'min-hter', 'bpcer20')
15 16 17 18


@click.command()
@click.argument('outdir')
Amir MOHAMMADI's avatar
Amir MOHAMMADI committed
19 20
@click.option('-mm', '--mean-match', default=10, type=click.FLOAT,
              show_default=True)
21 22 23 24 25
@click.option('-mnm', '--mean-non-match', default=-10,
              type=click.FLOAT, show_default=True)
@click.option('-n', '--n-sys', default=1, type=click.INT, show_default=True)
@verbosity_option()
@click.pass_context
Amir MOHAMMADI's avatar
Amir MOHAMMADI committed
26
def gen(ctx, outdir, mean_match, mean_non_match, n_sys):
27 28 29 30 31 32
  """Generate random scores.
  Generates random scores in 4col or 5col format. The scores are generated
  using Gaussian distribution whose mean is an input
  parameter. The generated scores can be used as hypothetical datasets.
  Invokes :py:func:`bob.bio.base.script.commands.gen`.
  """
Amir MOHAMMADI's avatar
Amir MOHAMMADI committed
33
  ctx.meta['five_col'] = False
34 35 36
  ctx.forward(bio_gen.gen)


Amir MOHAMMADI's avatar
Amir MOHAMMADI committed
37
@common_options.metrics_command(common_options.METRICS_HELP.format(
38
    names='FtA, FAR, FRR, APCER, BPCER, ACER',
Amir MOHAMMADI's avatar
Amir MOHAMMADI committed
39
    criteria=CRITERIA, score_format=SCORE_FORMAT,
40
    hter_note='Note that ACER = (APCER + BPCER) / 2',
Amir MOHAMMADI's avatar
Amir MOHAMMADI committed
41 42 43
    command='bob pad metrics'), criteria=CRITERIA)
def metrics(ctx, scores, evaluation, **kwargs):
  process = figure.Metrics(ctx, scores, evaluation, load.split)
44 45 46
  process.run()


Amir MOHAMMADI's avatar
Amir MOHAMMADI committed
47 48 49 50 51
@common_options.roc_command(
    common_options.ROC_HELP.format(
        score_format=SCORE_FORMAT, command='bob pad roc'))
def roc(ctx, scores, evaluation, **kwargs):
  process = figure.Roc(ctx, scores, evaluation, load.split)
52 53 54
  process.run()


Amir MOHAMMADI's avatar
Amir MOHAMMADI committed
55 56 57 58 59
@common_options.det_command(
    common_options.DET_HELP.format(
        score_format=SCORE_FORMAT, command='bob pad det'))
def det(ctx, scores, evaluation, **kwargs):
  process = figure.Det(ctx, scores, evaluation, load.split)
60 61 62
  process.run()


Amir MOHAMMADI's avatar
Amir MOHAMMADI committed
63 64 65 66 67
@common_options.epc_command(
    common_options.EPC_HELP.format(
        score_format=SCORE_FORMAT, command='bob pad epc'))
def epc(ctx, scores, **kwargs):
  process = measure_figure.Epc(ctx, scores, True, load.split, hter='ACER')
68 69 70
  process.run()


Amir MOHAMMADI's avatar
Amir MOHAMMADI committed
71 72 73 74 75
@common_options.hist_command(
    common_options.HIST_HELP.format(
        score_format=SCORE_FORMAT, command='bob pad hist'))
def hist(ctx, scores, evaluation, **kwargs):
  process = figure.Hist(ctx, scores, evaluation, load.split)
76 77 78
  process.run()


Amir MOHAMMADI's avatar
Amir MOHAMMADI committed
79 80 81 82
@common_options.evaluate_command(
    common_options.EVALUATE_HELP.format(
        score_format=SCORE_FORMAT, command='bob pad evaluate'),
    criteria=CRITERIA)
83
def evaluate(ctx, scores, evaluation, **kwargs):
Amir MOHAMMADI's avatar
Amir MOHAMMADI committed
84 85
  common_options.evaluate_flow(
      ctx, scores, evaluation, metrics, roc, det, epc, hist, **kwargs)