Commit ae7fb2df authored by Tiago de Freitas Pereira's avatar Tiago de Freitas Pereira
Browse files

[refactoring_2016] Migrating the database entry points to point to the High Level Interfaces

parent 51718618
Pipeline #3286 failed with stage
in 5 minutes and 43 seconds
#!/usr/bin/env python #!/usr/bin/env python
import bob.db.arface from bob.bio.db import ARFaceBioDatabase
import bob.bio.base
arface_directory = "[YOUR_ARFACE_DIRECTORY]" arface_directory = "[YOUR_ARFACE_DIRECTORY]"
database = bob.bio.base.database.DatabaseBob( database = ARFaceBioDatabase(
database = bob.db.arface.Database( original_directory=arface_directory,
original_directory = arface_directory original_extension=".png",
), protocol='all'
name = 'arface',
protocol = 'all'
) )
#!/usr/bin/env python #!/usr/bin/env python
import bob.db.atnt from bob.bio.db import AtntBioDatabase
import bob.bio.base
atnt_directory = "[YOUR_ATNT_DIRECTORY]" atnt_directory = "[YOUR_CAS-PEAL_DIRECTORY]"
database = bob.bio.base.database.DatabaseBob( database = AtntBioDatabase(
database = bob.db.atnt.Database( original_directory=atnt_directory,
original_directory = atnt_directory
),
name = 'atnt'
) )
#!/usr/bin/env python #!/usr/bin/env python
import bob.db.banca from bob.bio.db import BancaBioDatabase
import bob.bio.base
banca_directory = "[YOUR_BANCA_DIRECTORY]" banca_directory = "[YOUR_BANCA_DIRECTORY]"
database = bob.bio.base.database.DatabaseBobZT( database = BancaBioDatabase(
database = bob.db.banca.Database( original_directory=banca_directory,
original_directory = banca_directory, original_extension=".ppm",
original_extension = '.ppm' protocol='P'
),
name = "banca",
protocol = 'P'
) )
#!/usr/bin/env python #!/usr/bin/env python
import bob.db.caspeal from bob.bio.db import CaspealBioDatabase
import bob.bio.base
caspeal_directory = "[YOUR_CAS-PEAL_DIRECTORY]" caspeal_directory = "[YOUR_CAS-PEAL_DIRECTORY]"
database = bob.bio.base.database.DatabaseBob( database = CaspealBioDatabase(
database = bob.db.caspeal.Database( original_directory=caspeal_directory,
original_directory = caspeal_directory protocol='lighting'
),
name = "caspeal",
protocol = 'lighting'
) )
#!/usr/bin/env python #!/usr/bin/env python
import bob.db.gbu from bob.bio.db import GBUBioDatabase
import bob.bio.base
mbgc_v1_directory = "[YOUR_MBGC-V1_DIRECTORY]" mbgc_v1_directory = "[YOUR_MBGC-V1_DIRECTORY]"
database = bob.bio.base.database.DatabaseBob( database = GBUBioDatabase(
database = bob.db.gbu.Database( original_directory=mbgc_v1_directory,
original_directory = mbgc_v1_directory protocol='Good',
), models_depend_on_protocol=True,
name = "gbu",
protocol = 'Good',
models_depend_on_protocol = True,
all_files_options = { 'subworld': 'x2' }, all_files_options={'subworld': 'x2'},
extractor_training_options = { 'subworld': 'x2' }, extractor_training_options={'subworld': 'x2'},
projector_training_options = { 'subworld': 'x2' }, projector_training_options={'subworld': 'x2'},
enroller_training_options = { 'subworld': 'x2' } enroller_training_options={'subworld': 'x2'}
) )
#!/usr/bin/env python #!/usr/bin/env python
import bob.db.lfw from bob.bio.db import LFWBioDatabase
import bob.bio.base
lfw_directory = "[YOUR_LFW_FUNNELED_DIRECTORY]" lfw_directory = "[YOUR_LFW_FUNNELED_DIRECTORY]"
database = bob.bio.base.database.DatabaseBob( database = LFWBioDatabase(
database = bob.db.lfw.Database( original_directory=lfw_directory,
original_directory = lfw_directory, annotation_type='funneled',
annotation_type = 'funneled'
),
name = 'lfw',
protocol = 'view1',
training_depends_on_protocol = True,
models_depend_on_protocol = True,
all_files_options = { 'world_type' : 'restricted' }, protocol='view1',
extractor_training_options = { 'world_type' : 'restricted' }, # 'subworld' : 'twofolds' training_depends_on_protocol=True,
projector_training_options = { 'world_type' : 'restricted' }, # 'subworld' : 'twofolds' models_depend_on_protocol=True,
enroller_training_options = { 'world_type' : 'restricted' } # 'subworld' : 'twofolds'
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 #!/usr/bin/env python
import bob.db.lfw from bob.bio.db import LFWBioDatabase
import bob.bio.base
lfw_directory = "[YOUR_LFW_FUNNELED_DIRECTORY]" lfw_directory = "[YOUR_LFW_FUNNELED_DIRECTORY]"
database = bob.bio.base.database.DatabaseBob( database = LFWBioDatabase(
database = bob.db.lfw.Database( original_directory=lfw_directory,
original_directory = lfw_directory, annotation_type='funneled',
annotation_type = 'funneled'
), protocol='view1',
name = 'lfw', training_depends_on_protocol=True,
protocol = 'view1', models_depend_on_protocol=True,
training_depends_on_protocol = True,
models_depend_on_protocol = True,
all_files_options = { 'world_type' : 'unrestricted' }, all_files_options = { 'world_type' : 'unrestricted' },
extractor_training_options = { 'world_type' : 'unrestricted' }, # 'subworld' : 'twofolds' extractor_training_options = { 'world_type' : 'unrestricted' }, # 'subworld' : 'twofolds'
projector_training_options = { 'world_type' : 'unrestricted' }, # 'subworld' : 'twofolds' projector_training_options = { 'world_type' : 'unrestricted' }, # 'subworld' : 'twofolds'
enroller_training_options = { 'world_type' : 'unrestricted' } # 'subworld' : 'twofolds' enroller_training_options = { 'world_type' : 'unrestricted' } # 'subworld' : 'twofolds'
) )
#!/usr/bin/env python #!/usr/bin/env python
import bob.db.mobio from bob.bio.db import MobioBioDatabase
import bob.bio.base
mobio_image_directory = "[YOUR_MOBIO_IMAGE_DIRECTORY]" mobio_image_directory = "[YOUR_MOBIO_IMAGE_DIRECTORY]"
mobio_annotation_directory = "[YOUR_MOBIO_ANNOTATION_DIRECTORY]" mobio_annotation_directory = "[YOUR_MOBIO_ANNOTATION_DIRECTORY]"
database = bob.bio.base.database.DatabaseBobZT( database = MobioBioDatabase(
database = bob.db.mobio.Database( original_directory=mobio_image_directory,
original_directory = mobio_image_directory, original_extension=".png",
original_extension = ".png", annotation_directory=mobio_annotation_directory,
annotation_directory = mobio_annotation_directory,
),
name = "mobio-female",
protocol = 'female', protocol = 'female',
models_depend_on_protocol = True, models_depend_on_protocol=True,
all_files_options = { 'gender' : 'female' }, all_files_options={'gender': 'female'},
extractor_training_options = { 'gender' : 'female' }, extractor_training_options={'gender': 'female'},
projector_training_options = { 'gender' : 'female' }, projector_training_options={'gender': 'female'},
enroller_training_options = { 'gender' : 'female' }, enroller_training_options={'gender': 'female'},
z_probe_options = { 'gender' : 'female' } z_probe_options={'gender': 'female'}
) )
#!/usr/bin/env python #!/usr/bin/env python
import bob.db.mobio from bob.bio.db import MobioBioDatabase
import bob.bio.base
mobio_image_directory = "[YOUR_MOBIO_IMAGE_DIRECTORY]" mobio_image_directory = "[YOUR_MOBIO_IMAGE_DIRECTORY]"
mobio_annotation_directory = "[YOUR_MOBIO_ANNOTATION_DIRECTORY]" mobio_annotation_directory = "[YOUR_MOBIO_ANNOTATION_DIRECTORY]"
database = bob.bio.base.database.DatabaseBobZT( database = MobioBioDatabase(
database = bob.db.mobio.Database( original_directory=mobio_image_directory,
original_directory = mobio_image_directory, original_extension=".png",
original_extension = '.png', annotation_directory=mobio_annotation_directory,
annotation_directory = mobio_annotation_directory,
), protocol='male',
name = "mobio", models_depend_on_protocol = True,
protocol = 'male',
models_depend_on_protocol = True
) )
#!/usr/bin/env python #!/usr/bin/env python
import bob.db.mobio from bob.bio.db import MobioBioDatabase
import bob.bio.base
mobio_image_directory = "[YOUR_MOBIO_IMAGE_DIRECTORY]" mobio_image_directory = "[YOUR_MOBIO_IMAGE_DIRECTORY]"
mobio_annotation_directory = "[YOUR_MOBIO_ANNOTATION_DIRECTORY]" mobio_annotation_directory = "[YOUR_MOBIO_ANNOTATION_DIRECTORY]"
database = bob.bio.base.database.DatabaseBobZT( database = MobioBioDatabase(
database = bob.db.mobio.Database( original_directory=mobio_image_directory,
original_directory = mobio_image_directory, original_extension=".png",
original_extension = ".png", annotation_directory=mobio_annotation_directory,
annotation_directory = mobio_annotation_directory,
), protocol='male',
name = "mobio-male",
protocol = 'male',
models_depend_on_protocol = True, models_depend_on_protocol = True,
all_files_options = { 'gender' : 'male' }, all_files_options={'gender': 'male'},
extractor_training_options = { 'gender' : 'male' }, extractor_training_options={'gender': 'male'},
projector_training_options = { 'gender' : 'male' }, projector_training_options={'gender': 'male'},
enroller_training_options = { 'gender' : 'male' }, enroller_training_options={'gender': 'male'},
z_probe_options = { 'gender' : 'male' } z_probe_options={'gender': 'male'}
) )
#!/usr/bin/env python #!/usr/bin/env python
import bob.db.multipie from bob.bio.db import MultipieBioDatabase
import bob.bio.base
multipie_image_directory = "[YOUR_MULTI-PIE_IMAGE_DIRECTORY]" multipie_image_directory = "[YOUR_MULTI-PIE_IMAGE_DIRECTORY]"
multipie_annotation_directory = "[YOUR_MULTI-PIE_ANNOTATION_DIRECTORY]" multipie_annotation_directory = "[YOUR_MULTI-PIE_ANNOTATION_DIRECTORY]"
database = bob.bio.base.database.DatabaseBobZT( database = MultipieBioDatabase(
database = bob.db.multipie.Database( original_directory=multipie_image_directory,
original_directory = multipie_image_directory, annotation_directory=multipie_annotation_directory,
annotation_directory = multipie_annotation_directory protocol='U',
),
name = "multipie",
protocol = 'U',
training_depends_on_protocol = True training_depends_on_protocol = True
) )
#!/usr/bin/env python #!/usr/bin/env python
import bob.db.multipie
import bob.bio.base
multipie_image_directory = "[YOUR_MULTI-PIE_IMAGE_DIRECTORY]" from bob.bio.db import MultipieBioDatabase
multipie_annotation_directory = "[YOUR_MULTI-PIE_ANNOTATION_DIRECTORY]"
# here, we only want to have the cameras that are used in the P protocol # 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') 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')
database = bob.bio.base.database.DatabaseBobZT( multipie_image_directory = "[YOUR_MULTI-PIE_IMAGE_DIRECTORY]"
database = bob.db.multipie.Database( multipie_annotation_directory = "[YOUR_MULTI-PIE_ANNOTATION_DIRECTORY]"
original_directory = multipie_image_directory,
annotation_directory = multipie_annotation_directory database = MultipieBioDatabase(
), original_directory=multipie_image_directory,
name = "multipie-pose", annotation_directory=multipie_annotation_directory,
protocol = 'P', protocol = 'P',
training_depends_on_protocol = True, training_depends_on_protocol = True,
all_files_options = {'cameras' : cameras}, all_files_options={'cameras': cameras},
extractor_training_options = {'cameras' : cameras}, extractor_training_options={'cameras': cameras},
projector_training_options = {'cameras' : cameras, 'world_sampling': 3, 'world_first': True}, projector_training_options={'cameras': cameras, 'world_sampling': 3, 'world_first': True},
enroller_training_options = {'cameras' : cameras} enroller_training_options={'cameras': cameras}
) )
#!/usr/bin/env python #!/usr/bin/env python
import bob.db.scface from bob.bio.db import SCFaceBioDatabase
import bob.bio.base
scface_directory = "[YOUR_SC_FACE_DIRECTORY]" scface_directory = "[YOUR_SC_FACE_DIRECTORY]"
# setup for SCface database database = SCFaceBioDatabase(
database = bob.bio.base.database.DatabaseBobZT( original_directory=scface_directory,
database = bob.db.scface.Database( protocol='combined'
original_directory = scface_directory
),
name = 'scface',
protocol = 'combined'
) )
#!/usr/bin/env python #!/usr/bin/env python
import bob.db.xm2vts from bob.bio.db import XM2VTSBioDatabase
import bob.bio.base
xm2vts_directory = "[YOUR_XM2VTS_DIRECTORY]" xm2vts_directory = "[YOUR_XM2VTS_DIRECTORY]"
# setup for XM2VTS database = XM2VTSBioDatabase(
database = bob.bio.base.database.DatabaseBob( original_directory=xm2vts_directory,
database = bob.db.xm2vts.Database( protocol='lp1'
original_directory = xm2vts_directory
),
name = "xm2vts",
protocol = 'lp1'
) )
...@@ -24,170 +24,188 @@ from nose.plugins.skip import SkipTest ...@@ -24,170 +24,188 @@ from nose.plugins.skip import SkipTest
import bob.bio.base import bob.bio.base
from bob.bio.base.test.utils import db_available from bob.bio.base.test.utils import db_available
def _check_database(database, groups = ('dev',), protocol = None, training_depends = False, models_depend = False):
assert isinstance(database, bob.bio.base.database.DatabaseBob)
# load the directories def _check_database(database, groups=('dev',), protocol=None, training_depends=False, models_depend=False):
if 'HOME' in os.environ: assert isinstance(database, bob.bio.db.BioDatabase)
database.replace_directories(os.path.join(os.environ['HOME'], '.bob_bio_databases.txt'))
if protocol: database.protocol = protocol # load the directories
assert len(database.all_files()) > 0 if 'HOME' in os.environ:
assert len(database.training_files('train_extractor')) > 0 database.replace_directories(os.path.join(os.environ['HOME'], '.bob_bio_databases.txt'))
assert len(database.arrange_by_client(database.training_files('train_enroller'))) > 0
for group in groups: if protocol: database.protocol = protocol
model_ids = database.model_ids(group) assert len(database.all_files()) > 0
assert len(model_ids) > 0 assert len(database.training_files('train_extractor')) > 0
assert database.client_id_from_model_id(model_ids[0]) is not None assert len(database.arrange_by_client(database.training_files('train_enroller'))) > 0
assert len(database.enroll_files(model_ids[0], group)) > 0
assert len(database.probe_files(model_ids[0], group)) > 0
assert database.training_depends_on_protocol == training_depends for group in groups:
assert database.models_depend_on_protocol == models_depend model_ids = database.model_ids(group)
assert len(model_ids) > 0
assert database.client_id_from_model_id(model_ids[0]) is not None
assert len(database.enroll_files(model_ids[0], group)) > 0
assert len(database.probe_files(model_ids[0], group)) > 0
assert database.training_depends_on_protocol == training_depends
assert database.models_depend_on_protocol == models_depend
def _check_database_zt(database, groups = ('dev', 'eval'), protocol = None, training_depends = False, models_depend = False):
_check_database(database, groups, protocol, training_depends, models_depend) def _check_database_zt(database, groups=('dev', 'eval'), protocol=None, training_depends=False, models_depend=False):
assert isinstance(database, bob.bio.base.database.DatabaseBobZT) _check_database(database, groups, protocol, training_depends, models_depend)
for group in groups: assert isinstance(database, bob.bio.db.ZTBioDatabase)
t_model_ids = database.t_model_ids(group) for group in groups:
assert len(t_model_ids) > 0 t_model_ids = database.t_model_ids(group)
assert database.client_id_from_model_id(t_model_ids[0]) is not None assert len(t_model_ids) > 0
assert len(database.t_enroll_files(t_model_ids[0], group)) > 0 assert database.client_id_from_model_id(t_model_ids[0]) is not None
assert len(database.z_probe_files(group)) > 0 assert len(database.t_enroll_files(t_model_ids[0], group)) > 0
assert len(database.z_probe_files(group)) > 0
def _check_annotations(database): def _check_annotations(database):
for file in database.all_files(): for file in database.all_files():
annotations = database.annotations(file) annotations = database.annotations(file)
if annotations is not None: if annotations is not None:
assert isinstance(annotations, dict) assert isinstance(annotations, dict)
assert 'reye' in annotations assert 'reye' in annotations
assert 'leye' in annotations assert 'leye' in annotations
@db_available('arface') @db_available('arface')
def test_arface(): def test_arface():
database = bob.bio.base.load_resource('arface', 'database', preferred_package='bob.bio.face') database = bob.bio.base.load_resource('arface', 'database', preferred_package='bob.bio.face')
try: try:
_check_database(database, groups=('dev', 'eval')) _check_database(database, groups=('dev', 'eval'))
_check_annotations(database) _check_annotations(database)
except IOError as e: except IOError as e:
raise SkipTest("The database could not queried; probably the db.sql3 file is missing. Here is the error: '%s'" % e) raise SkipTest(
"The database could not queried; probably the db.sql3 file is missing. Here is the error: '%s'" % e)
def test_atnt(): def test_atnt():
_check_database(bob.bio.base.load_resource('atnt', 'database', preferred_package='bob.bio.face')) _check_database(bob.bio.base.load_resource('atnt', 'database', preferred_package='bob.bio.face'))
@db_available('banca') @db_available('banca')
def test_banca(): def test_banca():
database = bob.bio.base.load_resource('banca', 'database', preferred_package='bob.bio.face') database = bob.bio.base.load_resource('banca', 'database', preferred_package='bob.bio.face')
try: try:
_check_database_zt(database) _check_database_zt(database)
_check_annotations(database) _check_annotations(database)
except IOError as e: 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) raise SkipTest(
"The database could not be queried; probably the db.sql3 file is missing. Here is the error: '%s'" % e)
@db_available('caspeal') @db_available('caspeal')
def test_caspeal(): def test_caspeal():
database = bob.bio.base.load_resource('caspeal', 'database', preferred_package='bob.bio.face') database = bob.bio.base.load_resource('caspeal', 'database', preferred_package='bob.bio.face')
try: try:
_check_database(database)