diff --git a/bob/bio/face/config/database/banca_english.py b/bob/bio/face/config/database/banca_english.py index 53fbc36a175ca7d816c0d5367b00462e85cf7ee8..b867e52aff0a1d0cafd09b00ab1761b2f3774508 100644 --- a/bob/bio/face/config/database/banca_english.py +++ b/bob/bio/face/config/database/banca_english.py @@ -9,4 +9,3 @@ database = BancaBioDatabase( original_extension=".ppm", protocol='P' ) - diff --git a/bob/bio/face/config/database/caspeal.py b/bob/bio/face/config/database/caspeal.py index f4fd257a6693f2b0e7afb7fca92c3351de4d3526..d6f184473aff23a208de7e2846c3f5d3f08e6809 100644 --- a/bob/bio/face/config/database/caspeal.py +++ b/bob/bio/face/config/database/caspeal.py @@ -8,4 +8,3 @@ database = CaspealBioDatabase( original_directory=caspeal_directory, protocol='lighting' ) - diff --git a/bob/bio/face/config/database/gbu.py b/bob/bio/face/config/database/gbu.py index c74b3b3ce8b048890de5ee2d4f66c3c8d7c6bb7d..67c6075669dd3bc8dce49d089cc2041081c8bac0 100644 --- a/bob/bio/face/config/database/gbu.py +++ b/bob/bio/face/config/database/gbu.py @@ -14,4 +14,3 @@ database = GBUBioDatabase( projector_training_options={'subworld': 'x2'}, enroller_training_options={'subworld': 'x2'} ) - diff --git a/bob/bio/face/config/database/lfw_unrestricted.py b/bob/bio/face/config/database/lfw_unrestricted.py index db4ecb9e1cb91242ee548c1fc21a647c6a48869a..208f9cd18a1b157358fc2cf5f2c314e99f9993d2 100644 --- a/bob/bio/face/config/database/lfw_unrestricted.py +++ b/bob/bio/face/config/database/lfw_unrestricted.py @@ -12,9 +12,8 @@ database = LFWBioDatabase( training_depends_on_protocol=True, models_depend_on_protocol=True, - all_files_options = { 'world_type' : 'unrestricted' }, - extractor_training_options = { 'world_type' : 'unrestricted' }, # 'subworld' : 'twofolds' - projector_training_options = { 'world_type' : 'unrestricted' }, # 'subworld' : 'twofolds' - enroller_training_options = { 'world_type' : 'unrestricted' } # 'subworld' : 'twofolds' + all_files_options={'world_type': 'unrestricted'}, + extractor_training_options={'world_type': 'unrestricted'}, # 'subworld' : 'twofolds' + projector_training_options={'world_type': 'unrestricted'}, # 'subworld' : 'twofolds' + enroller_training_options={'world_type': 'unrestricted'} # 'subworld' : 'twofolds' ) - diff --git a/bob/bio/face/config/database/mobio.py b/bob/bio/face/config/database/mobio.py new file mode 100644 index 0000000000000000000000000000000000000000..b3427d4026f7d5fb1267bbde859a21136e16082f --- /dev/null +++ b/bob/bio/face/config/database/mobio.py @@ -0,0 +1,49 @@ +#!/usr/bin/env python + +from bob.bio.face.database import MobioBioDatabase + +mobio_image_directory = "[YOUR_MOBIO_IMAGE_DIRECTORY]" +mobio_annotation_directory = "[YOUR_MOBIO_ANNOTATION_DIRECTORY]" + +mobio_image = MobioBioDatabase( + original_directory=mobio_image_directory, + original_extension=".png", + annotation_directory=mobio_annotation_directory, + annotation_type="eyecenter", + + protocol='male', + models_depend_on_protocol=True, +) + +mobio_male = MobioBioDatabase( + original_directory=mobio_image_directory, + original_extension=".png", + annotation_directory=mobio_annotation_directory, + annotation_type="eyecenter", + + protocol='male', + models_depend_on_protocol=True, + + all_files_options={'gender': 'male'}, + extractor_training_options={'gender': 'male'}, + projector_training_options={'gender': 'male'}, + enroller_training_options={'gender': 'male'}, + z_probe_options={'gender': 'male'} +) + + +mobio_female = MobioBioDatabase( + original_directory=mobio_image_directory, + original_extension=".png", + annotation_directory=mobio_annotation_directory, + annotation_type="eyecenter", + + protocol='female', + models_depend_on_protocol=True, + + all_files_options={'gender': 'female'}, + extractor_training_options={'gender': 'female'}, + projector_training_options={'gender': 'female'}, + enroller_training_options={'gender': 'female'}, + z_probe_options={'gender': 'female'} +) diff --git a/bob/bio/face/config/database/mobio_female.py b/bob/bio/face/config/database/mobio_female.py deleted file mode 100644 index a329d9224502429d26ae985df052f0fec95eb131..0000000000000000000000000000000000000000 --- a/bob/bio/face/config/database/mobio_female.py +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env python - -from bob.bio.face.database import MobioBioDatabase - -mobio_image_directory = "[YOUR_MOBIO_IMAGE_DIRECTORY]" -mobio_annotation_directory = "[YOUR_MOBIO_ANNOTATION_DIRECTORY]" - -database = MobioBioDatabase( - original_directory=mobio_image_directory, - original_extension=".png", - annotation_directory=mobio_annotation_directory, - annotation_type="eyecenter", - - protocol = 'female', - models_depend_on_protocol=True, - - all_files_options={'gender': 'female'}, - extractor_training_options={'gender': 'female'}, - projector_training_options={'gender': 'female'}, - enroller_training_options={'gender': 'female'}, - z_probe_options={'gender': 'female'} -) diff --git a/bob/bio/face/config/database/mobio_image.py b/bob/bio/face/config/database/mobio_image.py deleted file mode 100644 index b754e6f727190001126ecf58434ffef13bbe7c1f..0000000000000000000000000000000000000000 --- a/bob/bio/face/config/database/mobio_image.py +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env python - -from bob.bio.face.database import MobioBioDatabase - -mobio_image_directory = "[YOUR_MOBIO_IMAGE_DIRECTORY]" -mobio_annotation_directory = "[YOUR_MOBIO_ANNOTATION_DIRECTORY]" - -database = MobioBioDatabase( - original_directory=mobio_image_directory, - original_extension=".png", - annotation_directory=mobio_annotation_directory, - annotation_type="eyecenter", - - protocol='male', - models_depend_on_protocol = True, -) - - - - diff --git a/bob/bio/face/config/database/mobio_male.py b/bob/bio/face/config/database/mobio_male.py deleted file mode 100644 index 90da21e23b1580aa000870b830a61dbd5e54a3b2..0000000000000000000000000000000000000000 --- a/bob/bio/face/config/database/mobio_male.py +++ /dev/null @@ -1,23 +0,0 @@ -#!/usr/bin/env python - -from bob.bio.face.database import MobioBioDatabase - -mobio_image_directory = "[YOUR_MOBIO_IMAGE_DIRECTORY]" -mobio_annotation_directory = "[YOUR_MOBIO_ANNOTATION_DIRECTORY]" - -database = MobioBioDatabase( - original_directory=mobio_image_directory, - original_extension=".png", - annotation_directory=mobio_annotation_directory, - annotation_type="eyecenter", - - protocol='male', - models_depend_on_protocol = True, - - all_files_options={'gender': 'male'}, - extractor_training_options={'gender': 'male'}, - projector_training_options={'gender': 'male'}, - enroller_training_options={'gender': 'male'}, - z_probe_options={'gender': 'male'} -) - diff --git a/bob/bio/face/config/database/multipie.py b/bob/bio/face/config/database/multipie.py index 405c60aa9943d826f65db88c2190a7a3c8b42095..c9214eef03aa9ece3236e577586eca914d48436b 100644 --- a/bob/bio/face/config/database/multipie.py +++ b/bob/bio/face/config/database/multipie.py @@ -9,5 +9,5 @@ database = MultipieBioDatabase( original_directory=multipie_image_directory, annotation_directory=multipie_annotation_directory, protocol='U', - training_depends_on_protocol = True + training_depends_on_protocol=True ) diff --git a/bob/bio/face/config/database/replaymobile.py b/bob/bio/face/config/database/replaymobile.py new file mode 100644 index 0000000000000000000000000000000000000000..460beaf2383c81dd2563f2345930ff76a3255bc5 --- /dev/null +++ b/bob/bio/face/config/database/replaymobile.py @@ -0,0 +1,17 @@ +#!/usr/bin/env python + +from bob.bio.face.database import ReplayMobileBioDatabase + +replay_mobile_directory = "[YOUR_REPLAY_MOBILE_DIRECTORY]" + +replaymobile_licit = ReplayMobileBioDatabase( + original_directory=replay_mobile_directory, + original_extension=".mov", + protocol='grandtest-licit', +) + +replaymobile_spoof = ReplayMobileBioDatabase( + original_directory=replay_mobile_directory, + original_extension=".mov", + protocol='grandtest-spoof', +) diff --git a/bob/bio/face/database/__init__.py b/bob/bio/face/database/__init__.py index e6a26fe353122530a60f9909d47a78223299276e..ede18cda4e552c9acd2291ee6628147a5e3eb34d 100644 --- a/bob/bio/face/database/__init__.py +++ b/bob/bio/face/database/__init__.py @@ -16,6 +16,7 @@ from .xm2vts import XM2VTSBioDatabase from .frgc import FRGCBioDatabase from .cuhk_cufs import CUHK_CUFSBioDatabase from .scface import SCFaceBioDatabase +from .replaymobile import ReplayMobileBioDatabase # gets sphinx autodoc done right - don't remove it def __appropriate__(*args): @@ -47,5 +48,6 @@ __appropriate__( FRGCBioDatabase, CUHK_CUFSBioDatabase, SCFaceBioDatabase, + ReplayMobileBioDatabase, ) __all__ = [_ for _ in dir() if not _.startswith('_')] diff --git a/bob/bio/face/database/arface.py b/bob/bio/face/database/arface.py index 262dc90cfb955d6d3b12c84af08101769da3d098..2526f38bdef61bfafcf0693e006fb47a42cd8b94 100644 --- a/bob/bio/face/database/arface.py +++ b/bob/bio/face/database/arface.py @@ -10,27 +10,45 @@ """ from .database import FaceBioFile -from bob.bio.base.database import BioDatabase, BioFile +from bob.bio.base.database import BioDatabase + + +class ARFaceBioFile(FaceBioFile): + + def __init__(self, f): + super(ARFaceBioFile, self).__init__(client_id=f.client_id, path=f.path, file_id=f.id) + self._f = f class ARFaceBioDatabase(BioDatabase): """ - Implements verification API for querying ARFACE database. + ARFace database implementation of :py:class:`bob.bio.base.database.BioDatabase` interface. + It is an extension of an SQL-based database interface, which directly talks to ARFACE database, for + verification experiments (good to use in bob.bio.base framework). """ def __init__( self, + original_directory=None, + original_extension='.ppm', **kwargs ): # call base class constructors to open a session to the database - super(ARFaceBioDatabase, self).__init__(name='arface', **kwargs) + super(ARFaceBioDatabase, self).__init__( + name='arface', + original_directory=original_directory, + original_extension=original_extension, + **kwargs) from bob.db.arface.query import Database as LowLevelDatabase - self.__db = LowLevelDatabase() + self._db = LowLevelDatabase(original_directory, original_extension) def model_ids_with_protocol(self, groups=None, protocol=None, **kwargs): - return self.__db.model_ids(groups=groups, protocol=protocol) + return self._db.model_ids(groups=groups, protocol=protocol) def objects(self, groups=None, protocol=None, purposes=None, model_ids=None, **kwargs): - retval = self.__db.objects(groups=groups, protocol=protocol, purposes=purposes, model_ids=model_ids, **kwargs) - return [FaceBioFile(client_id=f.client_id, path=f.path, file_id=f.id) for f in retval] + retval = self._db.objects(groups=groups, protocol=protocol, purposes=purposes, model_ids=model_ids, **kwargs) + return [ARFaceBioFile(f) for f in retval] + + def annotations(self, myfile): + return self._db.annotations(myfile._f) diff --git a/bob/bio/face/database/atnt.py b/bob/bio/face/database/atnt.py index 6b93e0e0394162b02b8455d3273cd926ded39575..c8ac0b214e5842939997ef69e3acbaa63c23b8bf 100644 --- a/bob/bio/face/database/atnt.py +++ b/bob/bio/face/database/atnt.py @@ -10,27 +10,38 @@ """ from .database import FaceBioFile -from bob.bio.base.database import BioDatabase, BioFile +from bob.bio.base.database import BioDatabase class AtntBioDatabase(BioDatabase): """ - Implements verification API for querying Atnt database. + ATNT database implementation of :py:class:`bob.bio.base.database.BioDatabase` interface. + It is an extension of the database interface, which directly talks to ATNT database, for + verification experiments (good to use in bob.bio.base framework). """ def __init__( self, + original_directory=None, + original_extension='.pgm', **kwargs ): # call base class constructors to open a session to the database - super(AtntBioDatabase, self).__init__(name='atnt', **kwargs) + super(AtntBioDatabase, self).__init__( + name='atnt', + original_directory=original_directory, + original_extension=original_extension, + **kwargs) from bob.db.atnt.query import Database as LowLevelDatabase - self.__db = LowLevelDatabase() + self._db = LowLevelDatabase(original_directory, original_extension) def model_ids_with_protocol(self, groups=None, protocol=None, **kwargs): - return self.__db.model_ids(groups=groups, protocol=protocol) + return self._db.model_ids(groups=groups, protocol=protocol) def objects(self, groups=None, protocol=None, purposes=None, model_ids=None, **kwargs): - retval = self.__db.objects(groups=groups, protocol=protocol, purposes=purposes, model_ids=model_ids, **kwargs) + retval = self._db.objects(groups=groups, protocol=protocol, purposes=purposes, model_ids=model_ids, **kwargs) return [FaceBioFile(client_id=f.client_id, path=f.path, file_id=f.id) for f in retval] + + def annotations(self, file): + return None diff --git a/bob/bio/face/database/banca.py b/bob/bio/face/database/banca.py index 6da0b31202148674cc9eae9becd636494e7d9e9a..d1095b9929dae47e6b7b6084d9e975f9627e51eb 100644 --- a/bob/bio/face/database/banca.py +++ b/bob/bio/face/database/banca.py @@ -10,38 +10,56 @@ """ from .database import FaceBioFile -from bob.bio.base.database import ZTBioDatabase, BioFile +from bob.bio.base.database import ZTBioDatabase + + +class BancaBioFile(FaceBioFile): + + def __init__(self, f): + super(BancaBioFile, self).__init__(client_id=f.client_id, path=f.path, file_id=f.id) + self._f = f class BancaBioDatabase(ZTBioDatabase): """ - Implements verification API for querying Banca database. + BANCA database implementation of :py:class:`bob.bio.base.database.ZTBioDatabase` interface. + It is an extension of an SQL-based database interface, which directly talks to Banca database, for + verification experiments (good to use in bob.bio.base framework). """ def __init__( self, + original_directory=None, + original_extension=None, **kwargs ): # call base class constructors to open a session to the database - super(BancaBioDatabase, self).__init__(name='banca', **kwargs) + super(BancaBioDatabase, self).__init__( + name='banca', + original_directory=original_directory, + original_extension=original_extension, + **kwargs) from bob.db.banca.query import Database as LowLevelDatabase - self.__db = LowLevelDatabase() + self._db = LowLevelDatabase(original_directory, original_extension) def model_ids_with_protocol(self, groups=None, protocol=None, **kwargs): - return self.__db.model_ids(groups=groups, protocol=protocol) + return self._db.model_ids(groups=groups, protocol=protocol) def tmodel_ids_with_protocol(self, protocol=None, groups=None, **kwargs): - return self.__db.tmodel_ids(protocol=protocol, groups=groups, **kwargs) + return self._db.tmodel_ids(protocol=protocol, groups=groups, **kwargs) def objects(self, groups=None, protocol=None, purposes=None, model_ids=None, **kwargs): - retval = self.__db.objects(groups=groups, protocol=protocol, purposes=purposes, model_ids=model_ids, **kwargs) - return [FaceBioFile(client_id=f.client_id, path=f.path, file_id=f.id) for f in retval] + retval = self._db.objects(groups=groups, protocol=protocol, purposes=purposes, model_ids=model_ids, **kwargs) + return [BancaBioFile(f) for f in retval] def tobjects(self, groups=None, protocol=None, model_ids=None, **kwargs): - retval = self.__db.tobjects(groups=groups, protocol=protocol, model_ids=model_ids, **kwargs) - return [FaceBioFile(client_id=f.client_id, path=f.path, file_id=f.id) for f in retval] + retval = self._db.tobjects(groups=groups, protocol=protocol, model_ids=model_ids, **kwargs) + return [BancaBioFile(f) for f in retval] def zobjects(self, groups=None, protocol=None, **kwargs): - retval = self.__db.zobjects(groups=groups, protocol=protocol, **kwargs) - return [FaceBioFile(client_id=f.client_id, path=f.path, file_id=f.id) for f in retval] + retval = self._db.zobjects(groups=groups, protocol=protocol, **kwargs) + return [BancaBioFile(f) for f in retval] + + def annotations(self, myfile): + return self._db.annotations(myfile._f) diff --git a/bob/bio/face/database/caspeal.py b/bob/bio/face/database/caspeal.py index 620c02ef96851cf3b498734ba51708c20384c85e..9c1bfc5f674a7e929dc650f36f91faabff4a51f0 100644 --- a/bob/bio/face/database/caspeal.py +++ b/bob/bio/face/database/caspeal.py @@ -10,27 +10,45 @@ """ from .database import FaceBioFile -from bob.bio.base.database import BioDatabase, BioFile +from bob.bio.base.database import BioDatabase + + +class CaspealBioFile(FaceBioFile): + + def __init__(self, f): + super(CaspealBioFile, self).__init__(client_id=f.client_id, path=f.path, file_id=f.id) + self._f = f class CaspealBioDatabase(BioDatabase): """ - Implements verification API for querying Caspeal database. + Caspeal database implementation of :py:class:`bob.bio.base.database.BioDatabase` interface. + It is an extension of an SQL-based database interface, which directly talks to Caspeal database, for + verification experiments (good to use in bob.bio.base framework). """ def __init__( self, + original_directory=None, + original_extension='.tif', **kwargs ): # call base class constructors to open a session to the database - super(CaspealBioDatabase, self).__init__(name='caspeal', **kwargs) + super(CaspealBioDatabase, self).__init__( + name='caspeal', + original_directory=original_directory, + original_extension=original_extension, + **kwargs) from bob.db.caspeal.query import Database as LowLevelDatabase - self.__db = LowLevelDatabase() + self._db = LowLevelDatabase(original_directory, original_extension) def model_ids_with_protocol(self, groups=None, protocol=None, **kwargs): - return self.__db.model_ids(groups=groups, protocol=protocol) + return self._db.model_ids(groups=groups, protocol=protocol) def objects(self, groups=None, protocol=None, purposes=None, model_ids=None, **kwargs): - retval = self.__db.objects(groups=groups, protocol=protocol, purposes=purposes, model_ids=model_ids, **kwargs) - return [FaceBioFile(client_id=f.client_id, path=f.path, file_id=f.id) for f in retval] + retval = self._db.objects(groups=groups, protocol=protocol, purposes=purposes, model_ids=model_ids, **kwargs) + return [CaspealBioFile(f) for f in retval] + + def annotations(self, myfile): + return self._db.annotations(myfile._f) diff --git a/bob/bio/face/database/cuhk_cufs.py b/bob/bio/face/database/cuhk_cufs.py index 62ed153dd4c234455c1ddd8f3980fc1cc6849611..adf5aefe6a7fd0b961dd00f91bae437a0a9883ce 100644 --- a/bob/bio/face/database/cuhk_cufs.py +++ b/bob/bio/face/database/cuhk_cufs.py @@ -10,38 +10,60 @@ """ from .database import FaceBioFile -from bob.bio.base.database import ZTBioDatabase, BioFile +from bob.bio.base.database import ZTBioDatabase + + +class CUHK_CUFSBioFile(FaceBioFile): + + def __init__(self, f): + super(CUHK_CUFSBioFile, self).__init__(client_id=f.client_id, path=f.path, file_id=f.id) + self._f = f class CUHK_CUFSBioDatabase(ZTBioDatabase): """ - Implements verification API for querying CUHK_CUFS database. + CUHK_CUFS database implementation of :py:class:`bob.bio.base.database.BioDatabase` interface. + It is an extension of an SQL-based database interface, which directly talks to CUHK_CUFS database, for + verification experiments (good to use in bob.bio.base framework). """ def __init__( self, + original_directory=None, + original_extension=None, + arface_directory="", + xm2vts_directory="", **kwargs ): # call base class constructors to open a session to the database - super(CUHK_CUFSBioDatabase, self).__init__(name='cuhk_cufs', **kwargs) + super(CUHK_CUFSBioDatabase, self).__init__( + name='cuhk_cufs', + original_directory=original_directory, + original_extension=original_extension, + arface_directory=arface_directory, + xm2vts_directory=xm2vts_directory, + **kwargs) from bob.db.cuhk_cufs.query import Database as LowLevelDatabase - self.__db = LowLevelDatabase() + self._db = LowLevelDatabase(original_directory, original_extension, arface_directory, xm2vts_directory) def model_ids_with_protocol(self, groups=None, protocol="search_split1_p2s", **kwargs): - return self.__db.model_ids(groups=groups, protocol=protocol) + return self._db.model_ids(groups=groups, protocol=protocol) def tmodel_ids_with_protocol(self, protocol="search_split1_p2s", groups=None, **kwargs): - return self.__db.tmodel_ids(protocol=protocol, groups=groups, **kwargs) + return self._db.tmodel_ids(protocol=protocol, groups=groups, **kwargs) def objects(self, groups=None, protocol="search_split1_p2s", purposes=None, model_ids=None, **kwargs): - retval = self.__db.objects(groups=groups, protocol=protocol, purposes=purposes, model_ids=model_ids, **kwargs) - return [FaceBioFile(client_id=f.client_id, path=f.path, file_id=f.id) for f in retval] + retval = self._db.objects(groups=groups, protocol=protocol, purposes=purposes, model_ids=model_ids, **kwargs) + return [CUHK_CUFSBioFile(f) for f in retval] def tobjects(self, groups=None, protocol="search_split1_p2s", model_ids=None, **kwargs): - retval = self.__db.tobjects(groups=groups, protocol=protocol, model_ids=model_ids, **kwargs) - return [FaceBioFile(client_id=f.client_id, path=f.path, file_id=f.id) for f in retval] + retval = self._db.tobjects(groups=groups, protocol=protocol, model_ids=model_ids, **kwargs) + return [CUHK_CUFSBioFile(f) for f in retval] def zobjects(self, groups=None, protocol="search_split1_p2s", **kwargs): - retval = self.__db.zobjects(groups=groups, protocol=protocol, **kwargs) - return [FaceBioFile(client_id=f.client_id, path=f.path, file_id=f.id) for f in retval] + retval = self._db.zobjects(groups=groups, protocol=protocol, **kwargs) + return [CUHK_CUFSBioFile(f) for f in retval] + + def annotations(self, myfile): + return self._db.annotations(myfile._f) diff --git a/bob/bio/face/database/frgc.py b/bob/bio/face/database/frgc.py index b6d8ac7a0ab2fcaf0afc97db07627f624754356b..fb345a36e69ecddd1668d0aa4ff2279f5ff776b7 100644 --- a/bob/bio/face/database/frgc.py +++ b/bob/bio/face/database/frgc.py @@ -11,27 +11,45 @@ from .database import FaceBioFile -from bob.bio.base.database import BioDatabase, BioFile +from bob.bio.base.database import BioDatabase + + +class FRGCBioFile(FaceBioFile): + + def __init__(self, f): + super(FRGCBioFile, self).__init__(client_id=f.client_id, path=f.path, file_id=f.id) + self._f = f class FRGCBioDatabase(BioDatabase): """ - Implements verification API for querying FRGC database. + FRGC database implementation of :py:class:`bob.bio.base.database.BioDatabase` interface. + It is an extension of the low-level database interface, which directly talks to FRGC database, for + verification experiments (good to use in bob.bio.base framework). """ def __init__( self, + original_directory=None, + original_extension='.jpg', **kwargs ): # call base class constructors to open a session to the database - super(FRGCBioDatabase, self).__init__(name='frgc', **kwargs) + super(FRGCBioDatabase, self).__init__( + name='frgc', + original_directory=original_directory, + original_extension=original_extension, + **kwargs) from bob.db.frgc.query import Database as LowLevelDatabase - self.__db = LowLevelDatabase() + self._db = LowLevelDatabase(original_directory, original_extension) def model_ids_with_protocol(self, groups=None, protocol=None, **kwargs): - return self.__db.model_ids(groups=groups, protocol=protocol) + return self._db.model_ids(groups=groups, protocol=protocol) def objects(self, groups=None, protocol=None, purposes=None, model_ids=None, **kwargs): - retval = self.__db.objects(groups=groups, protocol=protocol, purposes=purposes, model_ids=model_ids, **kwargs) - return [FaceBioFile(client_id=f.client_id, path=f.path, file_id=f.id) for f in retval] + retval = self._db.objects(groups=groups, protocol=protocol, purposes=purposes, model_ids=model_ids, **kwargs) + return [FRGCBioFile(f) for f in retval] + + def annotations(self, myfile): + return self._db.annotations(myfile._f) diff --git a/bob/bio/face/database/gbu.py b/bob/bio/face/database/gbu.py index a402ba6c0034e78f62263f2bb9217e2fce6f018c..42b9857407178602f49339ede276471c3b5baca7 100644 --- a/bob/bio/face/database/gbu.py +++ b/bob/bio/face/database/gbu.py @@ -10,27 +10,45 @@ """ from .database import FaceBioFile -from bob.bio.base.database import BioDatabase, BioFile +from bob.bio.base.database import BioDatabase + + +class GBUBioFile(FaceBioFile): + + def __init__(self, f): + super(GBUBioFile, self).__init__(client_id=f.client_id, path=f.path, file_id=f.id) + self._f = f class GBUBioDatabase(BioDatabase): """ - Implements verification API for querying gbu database. + GBU database implementation of :py:class:`bob.bio.base.database.BioDatabase` interface. + It is an extension of an SQL-based database interface, which directly talks to GBU database, for + verification experiments (good to use in bob.bio.base framework). """ def __init__( self, + original_directory=None, + original_extension='.jpg', **kwargs ): # call base class constructors to open a session to the database - super(GBUBioDatabase, self).__init__(name='GBU', **kwargs) + super(GBUBioDatabase, self).__init__( + name='GBU', + original_directory=original_directory, + original_extension=original_extension, + **kwargs) from bob.db.gbu.query import Database as LowLevelDatabase - self.__db = LowLevelDatabase() + self._db = LowLevelDatabase(original_directory, original_extension) def model_ids_with_protocol(self, groups=None, protocol=None, **kwargs): - return self.__db.model_ids(groups=groups, protocol=protocol) + return self._db.model_ids(groups=groups, protocol=protocol) def objects(self, groups=None, protocol=None, purposes=None, model_ids=None, **kwargs): - retval = self.__db.objects(groups=groups, protocol=protocol, purposes=purposes, model_ids=model_ids, **kwargs) - return [FaceBioFile(client_id=f.client_id, path=f.path, file_id=f.id) for f in retval] + retval = self._db.objects(groups=groups, protocol=protocol, purposes=purposes, model_ids=model_ids, **kwargs) + return [GBUBioFile(f) for f in retval] + + def annotations(self, myfile): + return self._db.annotations(myfile._f) diff --git a/bob/bio/face/database/ijba.py b/bob/bio/face/database/ijba.py index 711b11f339b1a0bf21647bea0a751730a7b19cb1..01caa00cb7c23cbe9b8ac905c1b168ab5ee9ada7 100644 --- a/bob/bio/face/database/ijba.py +++ b/bob/bio/face/database/ijba.py @@ -10,27 +10,48 @@ """ from .database import FaceBioFile -from bob.bio.base.database import BioDatabase, BioFile +from bob.bio.base.database import BioDatabase + + +class IJBABioFile(FaceBioFile): + + def __init__(self, f): + super(IJBABioFile, self).__init__(client_id=f.client_id, path=f.path, file_id=f.id) + self._f = f class IJBABioDatabase(BioDatabase): """ - Implements verification API for querying IJBA database. + IJBA database implementation of :py:class:`bob.bio.base.database.BioDatabase` interface. + It is an extension of an SQL-based database interface, which directly talks to IJBA database, for + verification experiments (good to use in bob.bio.base framework). """ def __init__( self, + original_directory=None, + annotations_directory=None, + original_extension=None, **kwargs ): # call base class constructors to open a session to the database - super(IJBABioDatabase, self).__init__(name='ijba', **kwargs) + super(IJBABioDatabase, self).__init__( + name='ijba', + original_directory=original_directory, + annotations_directory=annotations_directory, + original_extension=original_extension, + **kwargs) from bob.db.ijba.query import Database as LowLevelDatabase - self.__db = LowLevelDatabase() + self._db = LowLevelDatabase(original_directory, annotations_directory, + original_extension) def model_ids_with_protocol(self, groups=None, protocol="search_split1", **kwargs): - return self.__db.model_ids(groups=groups, protocol=protocol) + return self._db.model_ids(groups=groups, protocol=protocol) def objects(self, groups=None, protocol="search_split1", purposes=None, model_ids=None, **kwargs): - retval = self.__db.objects(groups=groups, protocol=protocol, purposes=purposes, model_ids=model_ids, **kwargs) - return [FaceBioFile(client_id=f.client_id, path=f.path, file_id=f.id) for f in retval] + retval = self._db.objects(groups=groups, protocol=protocol, purposes=purposes, model_ids=model_ids, **kwargs) + return [IJBABioFile(f) for f in retval] + + def annotations(self, myfile): + return self._db.annotations(myfile._f) diff --git a/bob/bio/face/database/lfw.py b/bob/bio/face/database/lfw.py index 0a22d09c15b81c9dc68046a1e96f0428e657e6ae..cdf3468a0f750b06e796d36b1dbc1c3bece8e14f 100644 --- a/bob/bio/face/database/lfw.py +++ b/bob/bio/face/database/lfw.py @@ -11,27 +11,47 @@ from .database import FaceBioFile -from bob.bio.base.database import BioDatabase, BioFile +from bob.bio.base.database import BioDatabase + + +class LFWBioFile(FaceBioFile): + + def __init__(self, f): + super(LFWBioFile, self).__init__(client_id=f.client_id, path=f.path, file_id=f.id) + self._f = f class LFWBioDatabase(BioDatabase): """ - Implements verification API for querying LFW database. + LFW database implementation of bob.bio.base.database.Database interface. + It is an extension of an SQL-based database interface, which directly talks to LFW database, for + verification experiments (good to use in bob.bio.base framework). """ def __init__( self, + original_directory=None, + original_extension='.jpg', + annotation_type=None, **kwargs ): # call base class constructors to open a session to the database - super(LFWBioDatabase, self).__init__(name='lfw', **kwargs) + super(LFWBioDatabase, self).__init__( + name='lfw', + original_directory=original_directory, + original_extension=original_extension, + annotation_type=annotation_type, + **kwargs) from bob.db.lfw.query import Database as LowLevelDatabase - self.__db = LowLevelDatabase() + self._db = LowLevelDatabase(original_directory, original_extension, annotation_type) def model_ids_with_protocol(self, groups=None, protocol=None, **kwargs): - return self.__db.model_ids(groups=groups, protocol=protocol) + return self._db.model_ids(groups=groups, protocol=protocol) def objects(self, groups=None, protocol=None, purposes=None, model_ids=None, **kwargs): - retval = self.__db.objects(groups=groups, protocol=protocol, purposes=purposes, model_ids=model_ids, **kwargs) - return [FaceBioFile(client_id=f.client_id, path=f.path, file_id=f.id) for f in retval] + retval = self._db.objects(groups=groups, protocol=protocol, purposes=purposes, model_ids=model_ids, **kwargs) + return [LFWBioFile(f) for f in retval] + + def annotations(self, myfile): + return self._db.annotations(myfile._f) diff --git a/bob/bio/face/database/mobio.py b/bob/bio/face/database/mobio.py index 94c797475f4b815f96e3ef9b61359e488d53064d..900f493608df3bcb30fb9ae54c7540e5718f60d5 100644 --- a/bob/bio/face/database/mobio.py +++ b/bob/bio/face/database/mobio.py @@ -11,7 +11,15 @@ from .database import FaceBioFile -from bob.bio.base.database import ZTBioDatabase, BioFile +from bob.bio.base.database import ZTBioDatabase + + +class MobioBioFile(FaceBioFile): + """FaceBioFile implementation of the Replay Mobile Database""" + + def __init__(self, f): + super(MobioBioFile, self).__init__(client_id=f.client_id, path=f.path, file_id=f.id) + self._f = f class MobioBioDatabase(ZTBioDatabase): @@ -21,29 +29,42 @@ class MobioBioDatabase(ZTBioDatabase): def __init__( self, + original_directory=None, + original_extension=None, + annotation_directory=None, + annotation_extension='.pos', **kwargs ): # call base class constructors to open a session to the database - super(MobioBioDatabase, self).__init__(name='mobio', - **kwargs) + super(MobioBioDatabase, self).__init__( + name='mobio', + original_directory=original_directory, + original_extension=original_extension, + annotation_directory=annotation_directory, + annotation_extension=annotation_extension, + **kwargs) from bob.db.mobio.query import Database as LowLevelDatabase - self.__db = LowLevelDatabase() + self._db = LowLevelDatabase(original_directory, original_extension, + annotation_directory, annotation_extension) def model_ids_with_protocol(self, groups=None, protocol=None, gender=None): - return self.__db.model_ids(groups=groups, protocol=protocol, gender=gender) + return self._db.model_ids(groups=groups, protocol=protocol, gender=gender) def tmodel_ids_with_protocol(self, protocol=None, groups=None, **kwargs): - return self.__db.tmodel_ids(protocol=protocol, groups=groups, **kwargs) + return self._db.tmodel_ids(protocol=protocol, groups=groups, **kwargs) def objects(self, groups=None, protocol=None, purposes=None, model_ids=None, **kwargs): - retval = self.__db.objects(groups=groups, protocol=protocol, purposes=purposes, model_ids=model_ids, **kwargs) - return [FaceBioFile(client_id=f.client_id, path=f.path, file_id=f.id) for f in retval] + retval = self._db.objects(groups=groups, protocol=protocol, purposes=purposes, model_ids=model_ids, **kwargs) + return [MobioBioFile(f) for f in retval] def tobjects(self, groups=None, protocol=None, model_ids=None, **kwargs): - retval = self.__db.tobjects(groups=groups, protocol=protocol, model_ids=model_ids, **kwargs) - return [FaceBioFile(client_id=f.client_id, path=f.path, file_id=f.id) for f in retval] + retval = self._db.tobjects(groups=groups, protocol=protocol, model_ids=model_ids, **kwargs) + return [MobioBioFile(f) for f in retval] def zobjects(self, groups=None, protocol=None, **kwargs): - retval = self.__db.zobjects(groups=groups, protocol=protocol, **kwargs) - return [FaceBioFile(client_id=f.client_id, path=f.path, file_id=f.id) for f in retval] + retval = self._db.zobjects(groups=groups, protocol=protocol, **kwargs) + return [MobioBioFile(f) for f in retval] + + def annotations(self, myfile): + return self._db.annotations(myfile._f) diff --git a/bob/bio/face/database/multipie.py b/bob/bio/face/database/multipie.py index f6bc0b1018dca177164de5655f519d07e6fcb9b0..bde369044f07cbd780171d06ab771a965749caba 100644 --- a/bob/bio/face/database/multipie.py +++ b/bob/bio/face/database/multipie.py @@ -10,39 +10,63 @@ """ from .database import FaceBioFile -from bob.bio.base.database import ZTBioDatabase, BioFile +from bob.bio.base.database import ZTBioDatabase + + +class MultipieBioFile(FaceBioFile): + + def __init__(self, f): + super(MultipieBioFile, self).__init__(client_id=f.client_id, path=f.path, file_id=f.id) + self._f = f class MultipieBioDatabase(ZTBioDatabase): """ - Implements verification API for querying MULTIPIE database. + Multipie database implementation of bob.bio.base.database.Database interface. + It is an extension of an SQL-based database interface, which directly talks to Multipie database, for + verification experiments (good to use in bob.bio.base framework). """ def __init__( self, + original_directory=None, + original_extension='.png', + annotation_directory=None, + annotation_extension='.pos', **kwargs ): # call base class constructors to open a session to the database - super(MultipieBioDatabase, self).__init__(name='multipie', **kwargs) + super(MultipieBioDatabase, self).__init__( + name='multipie', + original_directory=original_directory, + original_extension=original_extension, + annotation_directory=annotation_directory, + annotation_extension=annotation_extension, + **kwargs) from bob.db.multipie.query import Database as LowLevelDatabase - self.__db = LowLevelDatabase() + self._db = LowLevelDatabase(original_directory, + original_extension, + annotation_directory, + annotation_extension) def model_ids_with_protocol(self, groups=None, protocol=None, **kwargs): - return self.__db.model_ids(groups=groups, protocol=protocol) + return self._db.model_ids(groups=groups, protocol=protocol) def objects(self, groups=None, protocol=None, purposes=None, model_ids=None, **kwargs): - retval = self.__db.objects(groups=groups, protocol=protocol, purposes=purposes, model_ids=model_ids, **kwargs) - return [BioFile(client_id=f.client_id, path=f.path, file_id=f.id) for f in retval] + retval = self._db.objects(groups=groups, protocol=protocol, purposes=purposes, model_ids=model_ids, **kwargs) + return [MultipieBioFile(f) for f in retval] def tmodel_ids_with_protocol(self, protocol=None, groups=None, **kwargs): - return self.__db.tmodel_ids(protocol=protocol, groups=groups, **kwargs) + return self._db.tmodel_ids(protocol=protocol, groups=groups, **kwargs) def tobjects(self, groups=None, protocol=None, model_ids=None, **kwargs): - retval = self.__db.tobjects(groups=groups, protocol=protocol, model_ids=model_ids, **kwargs) - return [FaceBioFile(client_id=f.client_id, path=f.path, file_id=f.id) for f in retval] + retval = self._db.tobjects(groups=groups, protocol=protocol, model_ids=model_ids, **kwargs) + return [MultipieBioFile(f) for f in retval] def zobjects(self, groups=None, protocol=None, **kwargs): - retval = self.__db.zobjects(groups=groups, protocol=protocol, **kwargs) - return [FaceBioFile(client_id=f.client_id, path=f.path, file_id=f.id) for f in retval] + retval = self._db.zobjects(groups=groups, protocol=protocol, **kwargs) + return [MultipieBioFile(f) for f in retval] + def annotations(self, myfile): + return self._db.annotations(myfile._f) diff --git a/bob/bio/face/database/replay.py b/bob/bio/face/database/replay.py index 2fe1815dc2feb817a24da2f93853e8d5c6ff43a3..c3a35b40d412c8baa5feb923c75ea4ebfaed2679 100644 --- a/bob/bio/face/database/replay.py +++ b/bob/bio/face/database/replay.py @@ -15,9 +15,10 @@ from bob.bio.base.database import BioDatabase class ReplayBioFile(FaceBioFile): - """docstring for ReplayBioFile""" + """BioFile implementation for the bob.db.replay database""" + def __init__(self, f): - super(FaceBioFile, self).__init__(client_id=f.client_id, path=f.path, file_id=f.id) + super(ReplayBioFile, self).__init__(client_id=f.client_id, path=f.path, file_id=f.id) self._f = f def load(self, directory=None, extension=None): @@ -28,8 +29,10 @@ class ReplayBioFile(FaceBioFile): class ReplayBioDatabase(BioDatabase): """ - Implements verification API for querying Replay database. - This database only loads the 10th image from the video files + Replay attack database implementation of bob.bio.base.database.BioDatabase interface. + It is an extension of an SQL-based database interface, which directly talks to Replay database, for + verification experiments (good to use in bob.bio.base framework). + It also implements a kind of hack so that you can run vulnerability analysis with it. """ __doc__ = __doc__ @@ -38,7 +41,7 @@ class ReplayBioDatabase(BioDatabase): super(ReplayBioDatabase, self).__init__(name='replay', **kwargs) from bob.db.replay import Database as LowLevelDatabase - self.__db = LowLevelDatabase() + self._db = LowLevelDatabase() self.low_level_group_names = ('train', 'devel', 'test') self.high_level_group_names = ('world', 'dev', 'eval') @@ -48,13 +51,13 @@ class ReplayBioDatabase(BioDatabase): Here I am going to hack and double the number of protocols with -licit and -spoof. This is done for running vulnerability analysis""" - names = [p.name + '-licit' for p in self.__db.protocols()] - names += [p.name + '-spoof' for p in self.__db.protocols()] + names = [p.name + '-licit' for p in self._db.protocols()] + names += [p.name + '-spoof' for p in self._db.protocols()] return names def groups(self): return self.convert_names_to_highlevel( - self.__db.groups(), self.low_level_group_names, self.high_level_group_names) + self._db.groups(), self.low_level_group_names, self.high_level_group_names) def annotations(self, file): """Will return the bounding box annotation of 10th frame of the video.""" @@ -111,7 +114,7 @@ class ReplayBioDatabase(BioDatabase): purposes.append('attack') # now, query the actual Replay database - objects = self.__db.objects(groups=groups, protocol=protocol, cls=purposes, clients=model_ids, **kwargs) + objects = self._db.objects(groups=groups, protocol=protocol, cls=purposes, clients=model_ids, **kwargs) # make sure to return BioFile representation of a file, not the database one # also make sure you replace client ids with spoof/metatdata1/metadata2/... @@ -124,3 +127,15 @@ class ReplayBioDatabase(BioDatabase): temp.client_id = 'attack' retval.append(temp) return retval + + def arrange_by_client(self, files): + client_files = {} + for file in files: + if str(file.client_id) not in client_files: + client_files[str(file.client_id)] = [] + client_files[str(file.client_id)].append(file) + + files_by_clients = [] + for client in sorted(client_files.keys()): + files_by_clients.append(client_files[client]) + return files_by_clients diff --git a/bob/bio/face/database/replaymobile.py b/bob/bio/face/database/replaymobile.py new file mode 100644 index 0000000000000000000000000000000000000000..e16d61dedc6da3414f5e735dfc69b9d59345ad35 --- /dev/null +++ b/bob/bio/face/database/replaymobile.py @@ -0,0 +1,74 @@ +#!/usr/bin/env python +# vim: set fileencoding=utf-8 : + +""" The Replay-Mobile Database for face spoofing implementation of +bob.bio.base.database.BioDatabase interface.""" + +from .database import FaceBioFile +from bob.bio.base.database import BioDatabase + + +class ReplayMobileBioFile(FaceBioFile): + """FaceBioFile implementation of the Replay Mobile Database""" + + def __init__(self, f): + super(ReplayMobileBioFile, self).__init__(client_id=f.client_id, path=f.path, file_id=f.id) + self._f = f + + def load(self, directory=None, extension=None): + if extension in (None, '.mov'): + return self._f.load(directory, extension) + else: + return super(ReplayMobileBioFile, self).load(directory, extension) + + +class ReplayMobileBioDatabase(BioDatabase): + """ + ReplayMobile database implementation of :py:class:`bob.bio.base.database.BioDatabase` interface. + It is an extension of an SQL-based database interface, which directly talks to ReplayMobile database, for + verification experiments (good to use in bob.bio.base framework). + """ + + def __init__(self, max_number_of_frames=None, **kwargs): + # call base class constructors to open a session to the database + super(ReplayMobileBioDatabase, self).__init__( + name='replay-mobile', + max_number_of_frames=max_number_of_frames, **kwargs) + + from bob.db.replaymobile.verificationprotocol import Database as LowLevelDatabase + self._db = LowLevelDatabase(max_number_of_frames) + + def protocol_names(self): + return self._db.protocols() + + def groups(self): + return self._db.groups() + + def annotations(self, myfile): + """Will return the bounding box annotation of nth frame of the video.""" + fn = myfile._f.framen + annots = myfile._f._f.bbx(directory=self.original_directory) + # convert width and height to bottomright coordinates + # bob uses the (y, x) format + topleft = (annots[fn][1], annots[fn][0]) + bottomright = (annots[fn][1] + annots[fn][3], annots[fn][0] + annots[fn][2]) + annotations = {'topleft': topleft, 'bottomright': bottomright} + return annotations + + def model_ids_with_protocol(self, groups=None, protocol=None, **kwargs): + return self._db.model_ids_with_protocol(groups, protocol, **kwargs) + + def objects(self, groups=None, protocol=None, purposes=None, model_ids=None, **kwargs): + return [ReplayMobileBioFile(f) for f in self._db.objects(groups, protocol, purposes, model_ids, **kwargs)] + + def arrange_by_client(self, files): + client_files = {} + for file in files: + if str(file.client_id) not in client_files: + client_files[str(file.client_id)] = [] + client_files[str(file.client_id)].append(file) + + files_by_clients = [] + for client in sorted(client_files.keys()): + files_by_clients.append(client_files[client]) + return files_by_clients diff --git a/bob/bio/face/database/scface.py b/bob/bio/face/database/scface.py index a13d092b41239bbf337ab15f7da1ed13ba2ba8bb..cde69349aa0507bcfe53691b800a51f53f811a40 100644 --- a/bob/bio/face/database/scface.py +++ b/bob/bio/face/database/scface.py @@ -10,38 +10,56 @@ """ from .database import FaceBioFile -from bob.bio.base.database import ZTBioDatabase, BioFile +from bob.bio.base.database import ZTBioDatabase + + +class SCFaceBioFile(FaceBioFile): + + def __init__(self, f): + super(SCFaceBioFile, self).__init__(client_id=f.client_id, path=f.path, file_id=f.id) + self._f = f class SCFaceBioDatabase(ZTBioDatabase): """ - Implements verification API for querying SCFace database. + SCFace database implementation of bob.bio.base.database.ZTDatabase interface. + It is an extension of an SQL-based database interface, which directly talks to SCFace database, for + verification experiments (good to use in bob.bio.base framework). """ def __init__( self, + original_directory=None, + original_extension='.jpg', **kwargs ): # call base class constructors to open a session to the database - super(SCFaceBioDatabase, self).__init__(name='scface', **kwargs) + super(SCFaceBioDatabase, self).__init__( + name='scface', + original_directory=original_directory, + original_extension=original_extension, + **kwargs) from bob.db.scface.query import Database as LowLevelDatabase - self.__db = LowLevelDatabase() + self._db = LowLevelDatabase(original_directory, original_extension) def model_ids_with_protocol(self, groups=None, protocol=None, **kwargs): - return self.__db.model_ids(groups=groups, protocol=protocol) + return self._db.model_ids(groups=groups, protocol=protocol) def tmodel_ids_with_protocol(self, protocol=None, groups=None, **kwargs): - return self.__db.tmodel_ids(protocol=protocol, groups=groups, **kwargs) + return self._db.tmodel_ids(protocol=protocol, groups=groups, **kwargs) def objects(self, groups=None, protocol=None, purposes=None, model_ids=None, **kwargs): - retval = self.__db.objects(groups=groups, protocol=protocol, purposes=purposes, model_ids=model_ids, **kwargs) - return [FaceBioFile(client_id=f.client_id, path=f.path, file_id=f.id) for f in retval] + retval = self._db.objects(groups=groups, protocol=protocol, purposes=purposes, model_ids=model_ids, **kwargs) + return [SCFaceBioFile(f) for f in retval] def tobjects(self, groups=None, protocol=None, model_ids=None, **kwargs): - retval = self.__db.tobjects(groups=groups, protocol=protocol, model_ids=model_ids, **kwargs) - return [FaceBioFile(client_id=f.client_id, path=f.path, file_id=f.id) for f in retval] + retval = self._db.tobjects(groups=groups, protocol=protocol, model_ids=model_ids, **kwargs) + return [SCFaceBioFile(f) for f in retval] def zobjects(self, groups=None, protocol=None, **kwargs): - retval = self.__db.zobjects(groups=groups, protocol=protocol, **kwargs) - return [FaceBioFile(client_id=f.client_id, path=f.path, file_id=f.id) for f in retval] + retval = self._db.zobjects(groups=groups, protocol=protocol, **kwargs) + return [SCFaceBioFile(f) for f in retval] + + def annotations(self, myfile): + return self._db.annotations(myfile._f) diff --git a/bob/bio/face/database/xm2vts.py b/bob/bio/face/database/xm2vts.py index a6f94ceaeaf914373a5358f1491d494292194ba1..6059ce3835633bca0a552619704d7e039d7c97cc 100644 --- a/bob/bio/face/database/xm2vts.py +++ b/bob/bio/face/database/xm2vts.py @@ -10,27 +10,45 @@ """ from .database import FaceBioFile -from bob.bio.base.database import BioDatabase, BioFile +from bob.bio.base.database import BioDatabase + + +class XM2VTSBioFile(FaceBioFile): + + def __init__(self, f): + super(XM2VTSBioFile, self).__init__(client_id=f.client_id, path=f.path, file_id=f.id) + self._f = f class XM2VTSBioDatabase(BioDatabase): """ - Implements verification API for querying XM2VTS database. + XM2VTS database implementation of bob.bio.base.database.Database interface. + It is an extension of an SQL-based database interface, which directly talks to XM2VTS database, for + verification experiments (good to use in bob.bio.base framework). """ def __init__( self, + original_directory=None, + original_extension='.ppm', **kwargs ): # call base class constructors to open a session to the database - super(XM2VTSBioDatabase, self).__init__(name='xm2vts', **kwargs) + super(XM2VTSBioDatabase, self).__init__( + name='xm2vts', + original_directory=original_directory, + original_extension=original_extension, + **kwargs) from bob.db.xm2vts.query import Database as LowLevelDatabase - self.__db = LowLevelDatabase() + self._db = LowLevelDatabase(original_directory, original_extension) def model_ids_with_protocol(self, groups=None, protocol=None, **kwargs): - return self.__db.model_ids(groups=groups, protocol=protocol) + return self._db.model_ids(groups=groups, protocol=protocol) def objects(self, groups=None, protocol=None, purposes=None, model_ids=None, **kwargs): - retval = self.__db.objects(groups=groups, protocol=protocol, purposes=purposes, model_ids=model_ids, **kwargs) - return [FaceBioFile(client_id=f.client_id, path=f.path, file_id=f.id) for f in retval] + retval = self._db.objects(groups=groups, protocol=protocol, purposes=purposes, model_ids=model_ids, **kwargs) + return [XM2VTSBioFile(f) for f in retval] + + def annotations(self, myfile): + return self._db.annotations(myfile._f) diff --git a/bob/bio/face/test/test_databases.py b/bob/bio/face/test/test_databases.py index f1928301a001fd755a4e2e044b957db9f1212c02..220235296711e510862f6105941aaaac5d03a88d 100644 --- a/bob/bio/face/test/test_databases.py +++ b/bob/bio/face/test/test_databases.py @@ -25,13 +25,23 @@ from bob.bio.base.test.utils import db_available from bob.bio.base.test.test_database_implementations import check_database, check_database_zt -def _check_annotations(database): - for file in database.all_files(): +def _check_annotations(database, topleft=False, required=True, limit_files=None): + files = database.all_files() + if limit_files is not None: + import random + files = random.sample(files, limit_files) + for file in files: annotations = database.annotations(file) + if required: + assert annotations is not None if annotations is not None: assert isinstance(annotations, dict) - assert 'reye' in annotations - assert 'leye' in annotations + if topleft: + assert 'topleft' in annotations + assert 'bottomright' in annotations + else: + assert 'reye' in annotations + assert 'leye' in annotations @db_available('arface') @@ -50,7 +60,6 @@ def test_atnt(): database = bob.bio.base.load_resource('atnt', 'database', preferred_package='bob.bio.face') try: check_database(database) - _check_annotations(database) except IOError as e: raise SkipTest( "The database could not queried; probably the db.sql3 file is missing. Here is the error: '%s'" % e) @@ -80,7 +89,7 @@ def test_caspeal(): #@db_available('frgc') -#def test_frgc(): +# def test_frgc(): # import xml.sax # database = bob.bio.base.load_resource('frgc', 'database', preferred_package='bob.bio.face') # try: @@ -108,8 +117,8 @@ def test_gbu(): try: check_database(database, models_depend=True) check_database(database, protocol='Bad', models_depend=True) - check_database(database, protocol = 'Ugly', models_depend=True) - _check_annotations(database) + check_database(database, protocol='Ugly', models_depend=True) + _check_annotations(database, limit_files=1000) except IOError as e: raise SkipTest( "The database could not queried; probably the db.sql3 file is missing. Here is the error: '%s'" % e) @@ -120,7 +129,7 @@ def test_ijba(): database = bob.bio.base.load_resource('ijba', 'database', preferred_package='bob.bio.face') try: check_database(database) - _check_annotations(database) + _check_annotations(database, limit_files=1000) except IOError as e: raise SkipTest( "The database could not queried; probably the db.sql3 file is missing. Here is the error: '%s'" % e) @@ -134,7 +143,7 @@ def test_lfw(): check_database(database, groups=('dev', 'eval'), protocol='fold1', training_depends=True, models_depend=True) check_database(bob.bio.base.load_resource('lfw-unrestricted', 'database', preferred_package='bob.bio.face'), training_depends=True, models_depend=True) - _check_annotations(database) + _check_annotations(database, limit_files=1000) except IOError as e: raise SkipTest( "The database could not queried; probably the db.sql3 file is missing. Here is the error: '%s'" % e) @@ -155,7 +164,7 @@ def test_mobio(): "The database could not be queried; probably the db.sql3 file is missing. Here is the error: '%s'" % e) try: - _check_annotations(database) + _check_annotations(database, limit_files=1000) except Exception as e: raise SkipTest( "The annotations could not be queried; probably the annotation files are missing. Here is the error: '%s'" % e) @@ -187,10 +196,14 @@ def test_scface(): database = bob.bio.base.load_resource('scface', 'database', preferred_package='bob.bio.face') try: check_database_zt(database) - _check_annotations(database) except IOError as e: raise SkipTest( "The database could not be queried; probably the db.sql3 file is missing. Here is the error: '%s'" % e) + try: + _check_annotations(database) + except Exception as e: + raise SkipTest( + "The annotations could not be queried; probably the annotation files are missing. Here is the error: '%s'" % e) @db_available('xm2vts') @@ -199,18 +212,71 @@ def test_xm2vts(): try: check_database(database, groups=('dev', 'eval')) check_database(database, groups=('dev', 'eval'), protocol='darkened-lp1') + except IOError as e: + raise SkipTest( + "The database could not be queried; probably the db.sql3 file is missing. Here is the error: '%s'" % e) + try: _check_annotations(database) + except Exception as e: + raise SkipTest( + "The annotations could not be queried; probably the annotation files are missing. Here is the error: '%s'" % e) + + +@db_available('replay') +def test_replay_licit(): + database = bob.bio.base.load_resource('replay-img-licit', 'database', preferred_package='bob.bio.face') + try: + check_database(database, groups=('dev', 'eval')) except IOError as e: raise SkipTest( "The database could not be queried; probably the db.sql3 file is missing. Here is the error: '%s'" % e) + try: + _check_annotations(database) + except Exception as e: + raise SkipTest( + "The annotations could not be queried; probably the annotation files are missing. Here is the error: '%s'" % e) @db_available('replay') -def test_replay(): - database = bob.bio.base.load_resource('replay', 'database', preferred_package='bob.bio.face') +def test_replay_spoof(): + database = bob.bio.base.load_resource('replay-img-spoof', 'database', preferred_package='bob.bio.face') try: check_database(database, groups=('dev', 'eval')) + except IOError as e: + raise SkipTest( + "The database could not be queried; probably the db.sql3 file is missing. Here is the error: '%s'" % e) + try: + _check_annotations(database) + except Exception as e: + raise SkipTest( + "The annotations could not be queried; probably the annotation files are missing. Here is the error: '%s'" % e) + + +@db_available('replaymobile') +def test_replaymobile_licit(): + database = bob.bio.base.load_resource('replaymobile-img-licit', 'database', preferred_package='bob.bio.face') + try: + check_database(database, groups=('dev', 'eval')) + except IOError as e: + raise SkipTest( + "The database could not be queried; probably the db.sql3 file is missing. Here is the error: '%s'" % e) + try: _check_annotations(database) + except Exception as e: + raise SkipTest( + "The annotations could not be queried; probably the annotation files are missing. Here is the error: '%s'" % e) + + +@db_available('replaymobile') +def test_replaymobile_spoof(): + database = bob.bio.base.load_resource('replaymobile-img-spoof', 'database', preferred_package='bob.bio.face') + try: + check_database(database, groups=('dev', 'eval')) except IOError as e: raise SkipTest( "The database could not be queried; probably the db.sql3 file is missing. Here is the error: '%s'" % e) + try: + _check_annotations(database) + except Exception as e: + raise SkipTest( + "The annotations could not be queried; probably the annotation files are missing. Here is the error: '%s'" % e) diff --git a/develop.cfg b/develop.cfg index d70bdd47b3155f232912b0f1dcbced4269391624..faa22780b1319566ee0f5b8077f4cb44ddfc66dd 100644 --- a/develop.cfg +++ b/develop.cfg @@ -4,20 +4,44 @@ [buildout] parts = scripts -eggs = bob.bio.face +eggs = bob.extension + bob.blitz + bob.core + bob.io.base + bob.io.image + bob.learn.activation + bob.math + bob.learn.linear + bob.sp + bob.ip.base + bob.ip.color + bob.ip.draw + bob.ip.gabor + bob.learn.em + bob.measure + bob.learn.boosting + bob.ip.facedetect + bob.ip.flandmark + bob.db.base + bob.db.atnt bob.db.arface bob.db.banca bob.db.caspeal + bob.db.cuhk_cufs bob.db.frgc bob.db.gbu bob.db.lfw bob.db.mobio bob.db.multipie + bob.db.replay + bob.db.replaymobile bob.db.scface bob.db.xm2vts - bob.db.replay gridtk - + bob.bio.base + bob.bio.gmm + bob.bio.face + extensions = bob.buildout mr.developer auto-checkout = * @@ -36,23 +60,28 @@ develop = src/bob.extension src/bob.ip.gabor src/bob.learn.em src/bob.measure - src/bob.db.base - src/bob.db.atnt - src/bob.bio.base src/bob.learn.boosting src/bob.ip.facedetect src/bob.ip.flandmark + src/bob.db.base + src/bob.db.atnt src/bob.db.arface src/bob.db.banca src/bob.db.caspeal + src/bob.db.cuhk_cufs src/bob.db.frgc src/bob.db.gbu src/bob.db.lfw src/bob.db.mobio src/bob.db.multipie + src/bob.db.replay + src/bob.db.replaymobile src/bob.db.scface src/bob.db.xm2vts - src/bob.db.replay + src/gridtk + src/bob.bio.base + src/bob.bio.gmm + src/bob.bio.face . ; options for bob.buildout @@ -68,31 +97,36 @@ bob.io.base = git https://gitlab.idiap.ch/bob/bob.io.base bob.io.image = git https://gitlab.idiap.ch/bob/bob.io.image bob.learn.activation = git https://gitlab.idiap.ch/bob/bob.learn.activation bob.math = git https://gitlab.idiap.ch/bob/bob.math +bob.learn.linear = git https://gitlab.idiap.ch/bob/bob.learn.linear bob.sp = git https://gitlab.idiap.ch/bob/bob.sp bob.ip.base = git https://gitlab.idiap.ch/bob/bob.ip.base bob.ip.color = git https://gitlab.idiap.ch/bob/bob.ip.color bob.ip.draw = git https://gitlab.idiap.ch/bob/bob.ip.draw bob.ip.gabor = git https://gitlab.idiap.ch/bob/bob.ip.gabor -bob.learn.linear = git https://gitlab.idiap.ch/bob/bob.learn.linear bob.learn.em = git https://gitlab.idiap.ch/bob/bob.learn.em bob.measure = git https://gitlab.idiap.ch/bob/bob.measure -bob.db.base = git https://gitlab.idiap.ch/bob/bob.db.base -bob.db.atnt = git https://gitlab.idiap.ch/bob/bob.db.atnt -bob.bio.base = git https://gitlab.idiap.ch/bob/bob.bio.base bob.learn.boosting = git https://gitlab.idiap.ch/bob/bob.learn.boosting bob.ip.facedetect = git https://gitlab.idiap.ch/bob/bob.ip.facedetect bob.ip.flandmark = git https://gitlab.idiap.ch/bob/bob.ip.flandmark +bob.db.base = git https://gitlab.idiap.ch/bob/bob.db.base +bob.db.atnt = git https://gitlab.idiap.ch/bob/bob.db.atnt bob.db.arface = git https://gitlab.idiap.ch/bob/bob.db.arface bob.db.banca = git https://gitlab.idiap.ch/bob/bob.db.banca bob.db.caspeal = git https://gitlab.idiap.ch/bob/bob.db.caspeal -bob.db.frgc = git https://gitlab.idiap.ch/bob/bob.db.frgc +bob.db.cuhk_cufs = git https://gitlab.idiap.ch/bob/bob.db.cuhk_cufs +bob.db.frgc = git https://gitlab.idiap.ch/bob/bob.db.frgc bob.db.gbu = git https://gitlab.idiap.ch/bob/bob.db.gbu -bob.db.lfw = git https://gitlab.idiap.ch/bob/bob.db.lfw +bob.db.lfw = git https://gitlab.idiap.ch/bob/bob.db.lfw 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.replay = git https://gitlab.idiap.ch/bob/bob.db.replay +bob.db.replaymobile = git https://gitlab.idiap.ch/bob/bob.db.replaymobile 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 +gridtk = git https://gitlab.idiap.ch/bob/gridtk +bob.bio.base = git https://gitlab.idiap.ch/bob/bob.bio.base +bob.bio.gmm = git https://gitlab.idiap.ch/bob/bob.bio.gmm +bob.bio.face = git https://gitlab.idiap.ch/bob/bob.bio.face [scripts] recipe = bob.buildout:scripts diff --git a/doc/implemented.rst b/doc/implemented.rst index b56a7c48f8a16b227eda6b89f61afe9764f867f4..23ec72a5f316bb03d2ceaa911c8d7dfbb2d846d6 100644 --- a/doc/implemented.rst +++ b/doc/implemented.rst @@ -7,6 +7,26 @@ Tools implemented in bob.bio.face Summary ------- +Databases +~~~~~~~~~ + +.. autosummary:: + bob.bio.face.database.ARFaceBioDatabase + bob.bio.face.database.AtntBioDatabase + bob.bio.face.database.BancaBioDatabase + bob.bio.face.database.MobioBioDatabase + bob.bio.face.database.CaspealBioDatabase + bob.bio.face.database.ReplayBioDatabase + bob.bio.face.database.ReplayMobileBioDatabase + bob.bio.face.database.GBUBioDatabase + bob.bio.face.database.LFWBioDatabase + bob.bio.face.database.MultipieBioDatabase + bob.bio.face.database.IJBABioDatabase + bob.bio.face.database.XM2VTSBioDatabase + bob.bio.face.database.FRGCBioDatabase + bob.bio.face.database.SCFaceBioDatabase + bob.bio.face.database.CUHK_CUFSBioDatabase + Image Preprocessors ~~~~~~~~~~~~~~~~~~~ @@ -39,6 +59,9 @@ Face Recognition Algorithms bob.bio.face.algorithm.GaborJet bob.bio.face.algorithm.Histogram +Databases +--------- +.. automodule:: bob.bio.face.database Preprocessors ------------- diff --git a/setup.py b/setup.py index ea630ad3f0a77f6c5b227a1c2829d389fab571c3..9f800b5664f848b1f608293fb175bf0d9dcf1035 100644 --- a/setup.py +++ b/setup.py @@ -109,21 +109,24 @@ setup( 'bob.bio.database': [ 'arface = bob.bio.face.config.database.arface:database', - 'atnt = bob.bio.face.config.database.atnt:database', + 'atnt = bob.bio.face.config.database.atnt:database', 'banca = bob.bio.face.config.database.banca_english:database', 'caspeal = bob.bio.face.config.database.caspeal:database', 'frgc = bob.bio.face.config.database.frgc:database', 'gbu = bob.bio.face.config.database.gbu:database', 'lfw-restricted = bob.bio.face.config.database.lfw_restricted:database', 'lfw-unrestricted = bob.bio.face.config.database.lfw_unrestricted:database', - 'mobio-male = bob.bio.face.config.database.mobio_male:database', # MOBIO gender-dependent training - 'mobio-female = bob.bio.face.config.database.mobio_female:database', # MOBIO gender-dependent training + 'mobio-image = bob.bio.face.config.database.mobio:mobio_image', + 'mobio-male = bob.bio.face.config.database.mobio:mobio_male', # MOBIO gender-dependent training + 'mobio-female = bob.bio.face.config.database.mobio:mobio_female', # MOBIO gender-dependent training 'multipie = bob.bio.face.config.database.multipie:database', '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', + 'replaymobile-img-licit = bob.bio.face.config.database.replaymobile:replaymobile_licit', + 'replaymobile-img-spoof = bob.bio.face.config.database.replaymobile:replaymobile_spoof', ], 'bob.bio.preprocessor': [ diff --git a/test-requirements.txt b/test-requirements.txt index fe0824d6a993cd30ad724c239b2602846a4b7958..1786ccb28016b1c92e9a3b108b992eab72f067ec 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -11,5 +11,7 @@ bob.db.lfw bob.db.mobio bob.db.multipie bob.db.replay +bob.db.replaymobile bob.db.scface -bob.db.xm2vts \ No newline at end of file +bob.db.xm2vts +bob.bio.gmm