Commit 470b12f3 authored by André Anjos's avatar André Anjos 💬

Adaptations to allow vulnerability analysis

parent a1dd2f3d
...@@ -43,4 +43,10 @@ protocol = 'Nom' ...@@ -43,4 +43,10 @@ protocol = 'Nom'
You may modify this at runtime by specifying the option ``--protocol`` on the You may modify this at runtime by specifying the option ``--protocol`` on the
command-line of ``verify.py`` or using the keyword ``protocol`` on a command-line of ``verify.py`` or using the keyword ``protocol`` on a
configuration file that is loaded **after** this configuration resource. configuration file that is loaded **after** this configuration resource.
We accept any biometric recognition protocol implemented by bob.db.verafinger.
Variants of the biometric recognition protocol ending in ``-va`` can be used to
test for vulnerability analysis. For example, use the protocol ``Nom-va`` to
test the vulnerability of a biometric recognition pipeline using the ``Nom``
protocol for enrollment and probe samples from presentation attacks.
""" """
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
# vim: set fileencoding=utf-8 : # vim: set fileencoding=utf-8 :
# Tue 27 Sep 2016 16:48:57 CEST # Tue 27 Sep 2016 16:48:57 CEST
import os
from bob.bio.base.database import BioFile, BioDatabase from bob.bio.base.database import BioFile, BioDatabase
...@@ -22,8 +23,9 @@ class File(BioFile): ...@@ -22,8 +23,9 @@ class File(BioFile):
def __init__(self, f): def __init__(self, f):
super(File, self).__init__(client_id=f.unique_finger_name, path=f.path, id_ = f.finger.unique_name
file_id=f.id) if f.source == 'pa': id_ = 'attack/%s' % id_
super(File, self).__init__(client_id=id_, path=f.path, file_id=f.id)
self.__f = f self.__f = f
...@@ -31,8 +33,14 @@ class File(BioFile): ...@@ -31,8 +33,14 @@ class File(BioFile):
"""(Overrides base method) Loads both image and mask""" """(Overrides base method) Loads both image and mask"""
image = super(File, self).load(*args, **kwargs) image = super(File, self).load(*args, **kwargs)
roi = self.__f.roi() basedir = args[0] if args else kwargs['directory']
return AnnotatedArray(image, metadata=dict(roi=roi)) annotdir = os.path.join(basedir, 'annotations', 'roi')
if os.path.exists(annotdir):
print('loading annotations')
roi = self.__f.roi(args[0])
return AnnotatedArray(image, metadata=dict(roi=roi))
print('NOT loading annotations')
return image
class Database(BioDatabase): class Database(BioDatabase):
...@@ -72,9 +80,16 @@ class Database(BioDatabase): ...@@ -72,9 +80,16 @@ class Database(BioDatabase):
groups = self.convert_names_to_lowlevel(groups, groups = self.convert_names_to_lowlevel(groups,
self.low_level_group_names, self.high_level_group_names) self.low_level_group_names, self.high_level_group_names)
retval = self._db.objects(groups=groups, protocol=protocol,
purposes=purposes, model_ids=model_ids, if (protocol.endswith('-va') or protocol.endswith('-VA')) and \
**kwargs) purposes=='probe': #the user actually means 'attack'
retval = self._db.objects(groups=groups, protocol=protocol[:-3],
purposes='attack', model_ids=model_ids,
**kwargs)
else:
retval = self._db.objects(groups=groups, protocol=protocol,
purposes=purposes, model_ids=model_ids,
**kwargs)
return [File(f) for f in retval] return [File(f) for f in retval]
......
...@@ -105,7 +105,8 @@ protocol, do the following: ...@@ -105,7 +105,8 @@ protocol, do the following:
If you have more processing cores on your local machine and don't want to If you have more processing cores on your local machine and don't want to
submit your job for SGE execution, you can run it in parallel (using 4 submit your job for SGE execution, you can run it in parallel (using 4
parallel tasks) by adding the options ``--parallel=4 --nice=10``. parallel tasks) by adding the options ``--parallel=4 --nice=10``. **Before**
doing so, make sure the package gridtk_ is properly installed.
Optionally, you may use the ``parallel`` resource configuration which Optionally, you may use the ``parallel`` resource configuration which
already sets the number of parallel jobs to the number of hardware cores you already sets the number of parallel jobs to the number of hardware cores you
......
...@@ -22,3 +22,4 @@ ...@@ -22,3 +22,4 @@
.. _bob.bio.base: https://pypi.python.org/pypi/bob.bio.base .. _bob.bio.base: https://pypi.python.org/pypi/bob.bio.base
.. _jaccard index: https://en.wikipedia.org/wiki/Jaccard_index .. _jaccard index: https://en.wikipedia.org/wiki/Jaccard_index
.. _watershed: https://en.wikipedia.org/wiki/Watershed_(image_processing) .. _watershed: https://en.wikipedia.org/wiki/Watershed_(image_processing)
.. _gridtk: https://pypi.python.org/pypi/gridtk
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