Commit d09c7927 authored by Amir Mohammadi's avatar Amir Mohammadi

Add replay config and documentation

parent fa9a3e36
Pipeline #4266 passed with stages
in 101 minutes and 26 seconds
#!/usr/bin/env python
from bob.bio.face.database import ReplayBioDatabase
replay_attack_directory = "[YOUR_REPLAY_ATTACK_DIRECTORY]"
replay_licit = ReplayBioDatabase(
original_directory=replay_attack_directory,
original_extension=".mov",
protocol='grandtest-licit',
)
replay_spoof = ReplayBioDatabase(
original_directory=replay_attack_directory,
original_extension=".mov",
protocol='grandtest-spoof',
)
......@@ -11,12 +11,25 @@
"""
from .database import FaceBioFile
from bob.bio.base.database import BioDatabase, BioFile
from bob.bio.base.database import BioDatabase
class ReplayBioFile(FaceBioFile):
"""docstring for ReplayBioFile"""
def __init__(self, f):
super(FaceBioFile, self).__init__(client_id=f.client_id, path=f.path, file_id=f.id)
self._f = f
def load(self, directory=None, extension=None):
video = self._f.load(directory, extension)
# just return the 10th frame.
return video[10]
class ReplayBioDatabase(BioDatabase):
"""
Implements verification API for querying Replay database.
This database only loads the 10th image from the video files
"""
__doc__ = __doc__
......@@ -44,15 +57,13 @@ class ReplayBioDatabase(BioDatabase):
self.__db.groups(), self.low_level_group_names, self.high_level_group_names)
def annotations(self, file):
"""Will return the bounding box annotation of all frames of the video."""
# fn = 10 # 10th frame number
annots = file.bbx(directory=self.original_directory)
"""Will return the bounding box annotation of 10th frame of the video."""
fn = 10 # 10th frame number
annots = file._f.bbx(directory=self.original_directory)
# bob uses the (y, x) format
annotations = dict()
for i in range(annots.shape[0]):
topleft = (annots[i][2], annots[i][1])
bottomright = (annots[i][2] + annots[i][4], annots[i][1] + annots[i][3])
annotations[str(i)] = {'topleft': topleft, 'bottomright': bottomright}
topleft = (annots[fn][2], annots[fn][1])
bottomright = (annots[fn][2] + annots[fn][4], annots[fn][1] + annots[fn][3])
annotations = {'topleft': topleft, 'bottomright': bottomright}
return annotations
def model_ids_with_protocol(self, groups=None, protocol=None, **kwargs):
......@@ -106,9 +117,9 @@ class ReplayBioDatabase(BioDatabase):
retval = []
for f in objects:
if f.is_real():
retval.append(FaceBioFile(client_id=f.client_id, path=f.path, file_id=f.id))
retval.append(ReplayBioFile(f))
else:
temp = FaceBioFile(client_id=f.client_id, path=f.path, file_id=f.id)
temp = ReplayBioFile(f)
temp.client_id = 'attack'
retval.append(temp)
return retval
......@@ -8,3 +8,4 @@ bob.db.mobio
bob.db.multipie
bob.db.scface
bob.db.xm2vts
bob.db.replay
......@@ -15,6 +15,7 @@ eggs = bob.bio.face
bob.db.multipie
bob.db.scface
bob.db.xm2vts
bob.db.replay
gridtk
extensions = bob.buildout
......@@ -51,6 +52,7 @@ develop = src/bob.extension
src/bob.db.multipie
src/bob.db.scface
src/bob.db.xm2vts
src/bob.db.replay
.
; options for bob.buildout
......@@ -90,6 +92,7 @@ bob.db.mobio = git https://gitlab.idiap.ch/bob/bob.db.mobio
bob.db.multipie = git https://gitlab.idiap.ch/bob/bob.db.multipie
bob.db.scface = git https://gitlab.idiap.ch/bob/bob.db.scface
bob.db.xm2vts = git https://gitlab.idiap.ch/bob/bob.db.xm2vts
bob.db.replay = git https://gitlab.idiap.ch/bob/bob.db.replay
[scripts]
recipe = bob.buildout:scripts
......
......@@ -151,6 +151,10 @@ Here is the list of files and replacement strings for all databases that are reg
- Images: ``[YOUR_MULTI-PIE_IMAGE_DIRECTORY]``
- Annotations: ``[YOUR_MULTI-PIE_ANNOTATION_DIRECTORY]``
* Replay Attack ``'replay-img-licit'``, ``'replay-img-spoof'``
- Complete directory: ``[YOUR_REPLAY_ATTACK_DIRECTORY]``
* SC face: ``'scface'``
- Images: ``[YOUR_SC_FACE_DIRECTORY]``
......@@ -159,7 +163,6 @@ Here is the list of files and replacement strings for all databases that are reg
- Images: ``[YOUR_XM2VTS_DIRECTORY]``
You can use the ``./bin/databases.py`` script to list, which data directories are correctly set up.
In order to view the annotations inside your database on top of the images, you can use the ``./bin/display_face_annotations.py`` script that is provided.
......
......@@ -122,6 +122,8 @@ setup(
'multipie-pose = bob.bio.face.config.database.multipie_pose:database',
'scface = bob.bio.face.config.database.scface:database',
'xm2vts = bob.bio.face.config.database.xm2vts:database',
'replay-img-licit = bob.bio.face.config.database.replay:replay_licit',
'replay-img-spoof = bob.bio.face.config.database.replay:replay_spoof',
],
'bob.bio.preprocessor': [
......
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