Skip to content
Snippets Groups Projects
Commit f97e3312 authored by Tiago de Freitas Pereira's avatar Tiago de Freitas Pereira
Browse files

Merge branch 'fix-119' into 'master'

Using the proper verify script depending on system

Closes #119

See merge request !156
parents b404f0d5 da3111a1
No related branches found
No related tags found
1 merge request!156Using the proper verify script depending on system
Pipeline #
...@@ -8,33 +8,40 @@ A script to run biometric recognition baselines ...@@ -8,33 +8,40 @@ A script to run biometric recognition baselines
from .. import load_resource from .. import load_resource
from .verify import main as verify import os
from ..baseline import get_available_databases, search_preprocessor from ..baseline import get_available_databases, search_preprocessor
from bob.extension.scripts.click_helper import verbosity_option from bob.extension.scripts.click_helper import (
verbosity_option, log_parameters)
import click import click
import tempfile import tempfile
import logging import logging
import os
logger = logging.getLogger("bob.bio.base") logger = logging.getLogger("bob.bio.base")
EPILOG = '''\b
Example:
$ bob bio baseline eigenface atnt -vvv
which will run the eigenface baseline (from bob.bio.face) on the atnt
database.
'''
@click.command(context_settings={'ignore_unknown_options': True, @click.command(context_settings={'ignore_unknown_options': True,
'allow_extra_args': True}) 'allow_extra_args': True}, epilog=EPILOG)
@click.argument('baseline', required=True) @click.argument('baseline', required=True)
@click.argument('database', required=True) @click.argument('database', required=True)
@click.option('--parallel-training', default='verify', show_default=True,
type=click.Choice(('verify', 'gmm', 'isv', 'ivector')),
help='Which script to use for training the algorithm. Some '
'algorithms would train more efficiently using a different '
'script.')
@verbosity_option() @verbosity_option()
@click.pass_context @click.pass_context
def baseline(ctx, baseline, database, **kwargs): def baseline(ctx, baseline, database, parallel_training, **kwargs):
"""Run a biometric recognition baseline. """Run a biometric recognition baseline.
\b
Example:
$ bob bio baseline eigenface atnt -vvv
which will run the eigenface baseline (from bob.bio.face) on the atnt
database.
\b \b
Check out all baselines available by running: Check out all baselines available by running:
`resource.py --types baseline` `resource.py --types baseline`
...@@ -51,6 +58,8 @@ def baseline(ctx, baseline, database, **kwargs): ...@@ -51,6 +58,8 @@ def baseline(ctx, baseline, database, **kwargs):
Hint: pass `--result-directory <dir>` to set the directory for resulting score files Hint: pass `--result-directory <dir>` to set the directory for resulting score files
""" """
log_parameters(logger)
# Triggering training for each baseline/database # Triggering training for each baseline/database
loaded_baseline = load_resource( loaded_baseline = load_resource(
baseline, 'baseline', package_prefix="bob.bio.") baseline, 'baseline', package_prefix="bob.bio.")
...@@ -61,7 +70,7 @@ def baseline(ctx, baseline, database, **kwargs): ...@@ -61,7 +70,7 @@ def baseline(ctx, baseline, database, **kwargs):
preprocessor = loaded_baseline.preprocessors[db] preprocessor = loaded_baseline.preprocessors[db]
# this is the default sub-directory that is used # this is the default sub-directory that is used
if "-T" in ctx.args or "--temp-directory" in ctx.args: if "-T" in ctx.args or "--temp-directory" in ctx.args:
sub_directory = os.path.join(database, baseline) sub_directory = os.path.join(database, baseline)
else: else:
sub_directory = baseline sub_directory = baseline
...@@ -89,12 +98,31 @@ verbose = {verbose} ...@@ -89,12 +98,31 @@ verbose = {verbose}
verbose=ctx.meta['verbosity'], verbose=ctx.meta['verbosity'],
) )
if parallel_training == "verify":
from .verify import main
elif parallel_training == "gmm":
from bob.bio.gmm.script.verify_gmm import main
elif parallel_training == "isv":
from bob.bio.gmm.script.verify_isv import main
elif parallel_training == "ivector":
from bob.bio.gmm.script.verify_ivector import main
algorithm = loaded_baseline.algorithm
if 'gmm' in algorithm and parallel_training != 'gmm':
logger.warning("GMM algorithms can train faster using the "
"``--parallel-training gmm`` option.")
if 'isv' in algorithm and parallel_training != 'isv':
logger.warning("ISV algorithms can train faster using the "
"``--parallel-training isv`` option.")
if 'ivector' in algorithm and parallel_training != 'ivector':
logger.warning("ivector algorithms can train faster using the "
"``--parallel-training ivector`` option.")
with tempfile.NamedTemporaryFile(mode='w+t', prefix='{}_'.format(baseline), with tempfile.NamedTemporaryFile(mode='w+t', prefix='{}_'.format(baseline),
suffix='.py', delete=False, dir='.') as f: suffix='.py', delete=False, dir='.') as f:
f.write(config) f.write(config)
f.flush() f.flush()
f.seek(0) f.seek(0)
verify([f.name] + ctx.args) main([f.name] + ctx.args)
click.echo("You may want to delete `{}' after the experiments are " click.echo("You may want to delete `{}' after the experiments are "
"finished running.".format(f.name)) "finished running.".format(f.name))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment