Cleaning up the database interfaces

parent 1d2676e2
#!/usr/bin/env python
from bob.bio.base.pipelines.vanilla_biometrics import DatabaseConnector
from bob.extension import rc
from bob.bio.face.database import ARFaceBioDatabase
arface_directory = "[YOUR_ARFACE_DIRECTORY]"
arface_directory = rc["bob.db.arface.directory"]
database = ARFaceBioDatabase(
original_directory=arface_directory,
original_extension=".png",
protocol='all'
database = DatabaseConnector(
ARFaceBioDatabase(
original_directory=arface_directory, original_extension=".png", protocol="all"
)
)
#!/usr/bin/env python
from bob.bio.base.pipelines.vanilla_biometrics import DatabaseConnector
from bob.extension import rc
from bob.bio.face.database import AtntBioDatabase
atnt_directory = "[YOUR_ATNT_DIRECTORY]"
atnt_directory = rc["bob.db.atnt.directory"]
database = AtntBioDatabase(
original_directory=atnt_directory,
original_extension=".pgm",
database = DatabaseConnector(
AtntBioDatabase(original_directory=atnt_directory, original_extension=".pgm",)
)
#!/usr/bin/env python
from bob.bio.face.database import BancaBioDatabase
banca_directory = "[YOUR_BANCA_DIRECTORY]"
database = BancaBioDatabase(
original_directory=banca_directory,
original_extension=".ppm",
protocol='P'
)
#!/usr/bin/env python
from bob.bio.face.database import CaspealBioDatabase
caspeal_directory = "[YOUR_CAS-PEAL_DIRECTORY]"
database = CaspealBioDatabase(
original_directory=caspeal_directory,
protocol='lighting'
)
#!/usr/bin/env python
from bob.bio.base.pipelines.vanilla_biometrics import DatabaseConnector
from bob.extension import rc
from bob.bio.face.database import FargoBioDatabase
fargo_directory = "[YOUR_FARGO_DIRECTORY]"
fargo_directory = rc["bob.db.fargo.directory"]
database = FargoBioDatabase(
original_directory=fargo_directory,
original_extension=".png",
protocol='mc-rgb'
database = DatabaseConnector(
FargoBioDatabase(
original_directory=fargo_directory, original_extension=".png", protocol="mc-rgb"
)
)
#!/usr/bin/env python
from bob.bio.face.database import FRGCBioDatabase
frgc_directory = "[YOUR_FRGC_DIRECTORY]"
database = FRGCBioDatabase(
original_directory=frgc_directory,
protocol='2.0.1',
models_depend_on_protocol=True
)
#!/usr/bin/env python
from bob.bio.base.pipelines.vanilla_biometrics import DatabaseConnector
from bob.extension import rc
from bob.bio.face.database import GBUBioDatabase
mbgc_v1_directory = "[YOUR_MBGC-V1_DIRECTORY]"
database = GBUBioDatabase(
original_directory=mbgc_v1_directory,
protocol='Good',
models_depend_on_protocol=True,
mbgc_v1_directory = rc["bob.db.gbu.directory"]
all_files_options={'subworld': 'x2'},
extractor_training_options={'subworld': 'x2'},
projector_training_options={'subworld': 'x2'},
enroller_training_options={'subworld': 'x2'}
database = DatabaseConnector(
GBUBioDatabase(
original_directory=mbgc_v1_directory,
protocol="Good",
models_depend_on_protocol=True,
all_files_options={"subworld": "x2"},
extractor_training_options={"subworld": "x2"},
projector_training_options={"subworld": "x2"},
enroller_training_options={"subworld": "x2"},
)
)
#!/usr/bin/env python
from bob.bio.face.database import IJBCBioDatabase
from bob.bio.base.pipelines.vanilla_biometrics import DatabaseConnector
from bob.extension import rc
ijbc_directory = "[YOUR_IJBC_DIRECTORY]"
ijbc_11 = IJBCBioDatabase(
original_directory=ijbc_directory,
protocol='1:1'
ijbc_directory = rc["bob.db.ijbc.directory"]
ijbc_11 = DatabaseConnector(
IJBCBioDatabase(original_directory=ijbc_directory, protocol="1:1")
)
ijbc_covariates = IJBCBioDatabase(
original_directory=ijbc_directory,
protocol='Covariates'
ijbc_covariates = DatabaseConnector(
IJBCBioDatabase(
original_directory=ijbc_directory, protocol="Covariates"
)
)
#!/usr/bin/env python
from bob.bio.face.database import LFWBioDatabase
from bob.bio.base.pipelines.vanilla_biometrics import DatabaseConnector
from bob.extension import rc
lfw_directory = "[YOUR_LFW_FUNNELED_DIRECTORY]"
database = LFWBioDatabase(
original_directory=lfw_directory,
annotation_type='funneled',
lfw_directory = rc["bob.db.lfw.directory"]
protocol='view1',
training_depends_on_protocol=True,
models_depend_on_protocol=True,
all_files_options={'world_type': 'restricted'},
extractor_training_options={'world_type': 'restricted'}, # 'subworld' : 'twofolds'
projector_training_options={'world_type': 'restricted'}, # 'subworld' : 'twofolds'
enroller_training_options={'world_type': 'restricted'} # 'subworld' : 'twofolds'
database = DatabaseConnector(
LFWBioDatabase(
original_directory=lfw_directory,
annotation_type="funneled",
protocol="view1",
training_depends_on_protocol=True,
models_depend_on_protocol=True,
all_files_options={"world_type": "restricted"},
extractor_training_options={
"world_type": "restricted"
}, # 'subworld' : 'twofolds'
projector_training_options={
"world_type": "restricted"
}, # 'subworld' : 'twofolds'
enroller_training_options={
"world_type": "restricted"
}, # 'subworld' : 'twofolds'
)
)
#!/usr/bin/env python
from bob.bio.face.database import LFWBioDatabase
from bob.bio.base.pipelines.vanilla_biometrics import DatabaseConnector
from bob.extension import rc
lfw_directory = "[YOUR_LFW_FUNNELED_DIRECTORY]"
database = LFWBioDatabase(
original_directory=lfw_directory,
annotation_type='funneled',
lfw_directory = rc["bob.db.lfw.directory"]
protocol='view1',
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'
database = DatabaseConnector(
LFWBioDatabase(
original_directory=lfw_directory,
annotation_type="funneled",
protocol="view1",
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'
)
)
#!/usr/bin/env python
from bob.bio.face.database import MsuMfsdModBioDatabase
from bob.bio.base.pipelines.vanilla_biometrics import DatabaseConnector
from bob.extension import rc
msu_mfsd_mod_directory = "[YOUR_MSU_MFSD_MOD_DIRECTORY]"
msu_mfsd_mod_directory = rc["bob.db.msu_mfsd.directory"]
msu_mfsd_mod_licit = MsuMfsdModBioDatabase(
original_directory=msu_mfsd_mod_directory,
original_extension=".mov",
protocol='grandtest-licit',
msu_mfsd_mod_licit = DatabaseConnector(
MsuMfsdModBioDatabase(
original_directory=msu_mfsd_mod_directory,
original_extension=".mov",
protocol="grandtest-licit",
)
)
msu_mfsd_mod_spoof = MsuMfsdModBioDatabase(
original_directory=msu_mfsd_mod_directory,
original_extension=".mov",
protocol='grandtest-spoof',
msu_mfsd_mod_spoof = DatabaseConnector(
MsuMfsdModBioDatabase(
original_directory=msu_mfsd_mod_directory,
original_extension=".mov",
protocol="grandtest-spoof",
)
)
#!/usr/bin/env python
from bob.bio.face.database import MultipieBioDatabase
from bob.bio.base.pipelines.vanilla_biometrics import DatabaseConnector
from bob.extension import rc
multipie_image_directory = "[YOUR_MULTI-PIE_IMAGE_DIRECTORY]"
multipie_annotation_directory = "[YOUR_MULTI-PIE_ANNOTATION_DIRECTORY]"
database = MultipieBioDatabase(
original_directory=multipie_image_directory,
annotation_directory=multipie_annotation_directory,
protocol='U',
training_depends_on_protocol=True
multipie_image_directory = rc["bob.db.multipie.directory"]
multipie_annotation_directory = rc["bob.db.multipie.annotations"]
database = DatabaseConnector(
MultipieBioDatabase(
original_directory=multipie_image_directory,
annotation_directory=multipie_annotation_directory,
protocol="U",
training_depends_on_protocol=True,
)
)
......@@ -2,23 +2,43 @@
from bob.bio.face.database import MultipieBioDatabase
from bob.bio.base.pipelines.vanilla_biometrics import DatabaseConnector
from bob.extension import rc
# here, we only want to have the cameras that are used in the P protocol
cameras = ('24_0', '01_0', '20_0', '19_0', '04_1', '05_0', '05_1', '14_0', '13_0', '08_0', '09_0', '12_0', '11_0')
multipie_image_directory = "[YOUR_MULTI-PIE_IMAGE_DIRECTORY]"
multipie_annotation_directory = "[YOUR_MULTI-PIE_ANNOTATION_DIRECTORY]"
database = MultipieBioDatabase(
original_directory=multipie_image_directory,
annotation_directory=multipie_annotation_directory,
protocol = 'P',
training_depends_on_protocol = True,
all_files_options={'cameras': cameras},
extractor_training_options={'cameras': cameras},
projector_training_options={'cameras': cameras, 'world_sampling': 3, 'world_first': True},
enroller_training_options={'cameras': cameras}
# here, we only want to have the cameras that are used in the P protocol
cameras = (
"24_0",
"01_0",
"20_0",
"19_0",
"04_1",
"05_0",
"05_1",
"14_0",
"13_0",
"08_0",
"09_0",
"12_0",
"11_0",
)
multipie_image_directory = rc["bob.db.multipie.directory"]
multipie_annotation_directory = rc["bob.db.multipie.annotations"]
database = DatabaseConnector(
MultipieBioDatabase(
original_directory=multipie_image_directory,
annotation_directory=multipie_annotation_directory,
protocol="P",
training_depends_on_protocol=True,
all_files_options={"cameras": cameras},
extractor_training_options={"cameras": cameras},
projector_training_options={
"cameras": cameras,
"world_sampling": 3,
"world_first": True,
},
enroller_training_options={"cameras": cameras},
)
)
#!/usr/bin/env python
from bob.bio.face.database import ReplayBioDatabase
from bob.bio.base.pipelines.vanilla_biometrics import DatabaseConnector
from bob.extension import rc
replay_attack_directory = "[YOUR_REPLAY_ATTACK_DIRECTORY]"
replay_licit = ReplayBioDatabase(
original_directory=replay_attack_directory,
original_extension=".mov",
protocol='grandtest-licit',
replay_attack_directory = rc["bob.db.replay.directory"]
replay_licit = DatabaseConnector(
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',
replay_spoof = DatabaseConnector(
ReplayBioDatabase(
original_directory=replay_attack_directory,
original_extension=".mov",
protocol="grandtest-spoof",
)
)
#!/usr/bin/env python
from bob.bio.face.database import ReplayMobileBioDatabase
from bob.bio.base.pipelines.vanilla_biometrics import DatabaseConnector
from bob.extension import rc
replay_mobile_directory = "[YOUR_REPLAY_MOBILE_DIRECTORY]"
replaymobile_licit = ReplayMobileBioDatabase(
original_directory=replay_mobile_directory,
original_extension=".mov",
protocol='grandtest-licit',
replay_mobile_directory = rc["bob.db.replay_mobile.directory"]
replaymobile_licit = DatabaseConnector(
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',
replaymobile_spoof = DatabaseConnector(
ReplayMobileBioDatabase(
original_directory=replay_mobile_directory,
original_extension=".mov",
protocol="grandtest-spoof",
)
)
#!/usr/bin/env python
from bob.bio.face.database import SCFaceBioDatabase
scface_directory = "[YOUR_SC_FACE_DIRECTORY]"
database = SCFaceBioDatabase(
original_directory=scface_directory,
protocol='combined'
)
#!/usr/bin/env python
from bob.bio.face.database import XM2VTSBioDatabase
xm2vts_directory = "[YOUR_XM2VTS_DIRECTORY]"
database = XM2VTSBioDatabase(
original_directory=xm2vts_directory,
protocol='lp1'
)
......@@ -7,13 +7,9 @@ from .replay import ReplayBioDatabase
from .atnt import AtntBioDatabase
from .gbu import GBUBioDatabase
from .arface import ARFaceBioDatabase
from .caspeal import CaspealBioDatabase
from .lfw import LFWBioDatabase
from .multipie import MultipieBioDatabase
from .ijbc import IJBCBioDatabase
from .xm2vts import XM2VTSBioDatabase
from .frgc import FRGCBioDatabase
from .scface import SCFaceBioDatabase
from .replaymobile import ReplayMobileBioDatabase
from .msu_mfsd_mod import MsuMfsdModBioDatabase
from .fargo import FargoBioDatabase
......@@ -43,13 +39,9 @@ __appropriate__(
AtntBioDatabase,
GBUBioDatabase,
ARFaceBioDatabase,
CaspealBioDatabase,
LFWBioDatabase,
MultipieBioDatabase,
IJBCBioDatabase,
XM2VTSBioDatabase,
FRGCBioDatabase,
SCFaceBioDatabase,
IJBCBioDatabase,
ReplayMobileBioDatabase,
MsuMfsdModBioDatabase,
FargoBioDatabase
......
#!/usr/bin/env python
# vim: set fileencoding=utf-8 :
# Tiago de Freitas Pereira <tiago.pereira@idiap.ch>
# Sat 20 Aug 15:43:10 CEST 2016
"""
FRGC database implementation of bob.bio.base.database.Database interface.
It is an extension of an SQL-based database interface, which directly talks to FRGC database, for
verification experiments (good to use in bob.bio.base framework).
"""
from .database import FaceBioFile
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):
"""
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
):
from bob.db.frgc.query import Database as LowLevelDatabase
self._db = LowLevelDatabase(original_directory, original_extension)
# call base class constructors to open a session to the database
super(FRGCBioDatabase, self).__init__(
name='frgc',
original_directory=original_directory,
original_extension=original_extension,
**kwargs)
@property
def original_directory(self):
return self._db.original_directory
@original_directory.setter
def original_directory(self, value):
self._db.original_directory = value
def model_ids_with_protocol(self, groups=None, protocol=None, **kwargs):
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 [FRGCBioFile(f) for f in retval]
def annotations(self, myfile):
return self._db.annotations(myfile._f)
#!/usr/bin/env python
# vim: set fileencoding=utf-8 :
# Tiago de Freitas Pereira <tiago.pereira@idiap.ch>
# Sat 20 Aug 15:43:10 CEST 2016
"""
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).
"""
from .database import FaceBioFile
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):
"""
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
):
from bob.db.scface.query import Database as LowLevelDatabase
self._db = LowLevelDatabase(original_directory, original_extension)
# call base class constructors to open a session to the database
super(SCFaceBioDatabase, self).__init__(
name='scface',
original_directory=original_directory,
original_extension=original_extension,
**kwargs)
@property
def original_directory(self):
return self._db.original_directory
@original_directory.setter
def original_directory(self, value):
self._db.original_directory = value
def model_ids_with_protocol(self, groups=None, protocol=None, **kwargs):
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)
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 [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 [SCFaceBioFile(f) for f in retval]
def zobjects(self, groups=None, protocol=None, **kwargs):
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)
#!/usr/bin/env python
# vim: set fileencoding=utf-8 :
# Tiago de Freitas Pereira <tiago.pereira@idiap.ch>
# Sat 20 Aug 15:43:10 CEST 2016
"""
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).
"""
from .database import FaceBioFile
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):
"""
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
):
from bob.db.xm2vts.query import Database as LowLevelDatabase
self._db = LowLevelDatabase(original_directory, original_extension)
# call base class constructors to open a session to the database
super(XM2VTSBioDatabase, self).__init__(
name='xm2vts',
original_directory=original_directory,
original_extension=original_extension,
**kwargs)
@property
def original_directory(self):
return self._db.original_directory
@original_directory.setter
def original_directory(self, value):
self._db.original_directory = value
def model_ids_with_protocol(self, groups=None, protocol=None, **kwargs):
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 [XM2VTSBioFile(f) for f in retval]
def annotations(self, myfile):
return self._db.annotations(myfile._f)
......@@ -28,13 +28,15 @@ logger = bob.core.log.setup("bob.bio.face")
def _check_annotations(database, topleft=False, required=True, limit_files=None, framed=False):
files = database.all_files()
database_legacy = database.database
files = database_legacy.all_files()
if limit_files is not None:
import random
files = random.sample(files, limit_files)
found_none = False
for file in files:
annotations = database.annotations(file)
annotations = database_legacy.annotations(file)
if required:
assert annotations is not None
if annotations is not None:
......@@ -51,7 +53,7 @@ def _check_annotations(database, topleft=False, required=True, limit_files=None,
else:
found_none = True
if found_none:
logger.warn("Some annotations were None for {}".format(database.name))
logger.warn("Some annotations were None for {}".format(database_legacy.name))
@db_available('arface')
......@@ -81,36 +83,6 @@ def test_atnt():
"The database could not queried; probably the db.sql3 file is missing. Here is the error: '%s'" % e)
@db_available('caspeal')
def test_caspeal():
database = bob.bio.base.load_resource(