Commit 022bde8d authored by Manuel Günther's avatar Manuel Günther
Browse files

Implemented IJBA database interface correctly

parent b96e367c
Pipeline #5168 passed with stages
in 45 minutes and 29 seconds
#!/usr/bin/env python
from import IJBABioDatabase
ijba_directory = "[YOUR_IJBA_DIRECTORY]"
database = IJBABioDatabase(
......@@ -4,13 +4,29 @@
# Sat 20 Aug 15:43:10 CEST 2016
IJBA database implementation of interface.
It is an extension of an SQL-based database interface, which directly talks to IJBA database, for
IJBA database implementation of interface.
It is an extension of the database interface, which directly talks to IJBA database, for
verification experiments (good to use in framework).
from .database import FaceBioFile
from import BioDatabase, BioFile
from import BioDatabase, BioFileSet
import os
class IJBABioFile(FaceBioFile):
def __init__(self, f):
super(IJBABioFile, self).__init__(client_id=f.client_id, path=f.path,
self.f = f
def make_path(self, directory, extension):
# add file ID to the path, so that a unique path is generated (there might be several identities in each physical file)
return str(os.path.join(directory or '', self.path + "-" + str( + (extension or '')))
class IJBABioFileSet(BioFileSet):
def __init__(self, template):
super(IJBABioFileSet, self).__init__(file_set_id =, files = [IJBABioFile(f) for f in template.files], path = template.path)
class IJBABioDatabase(BioDatabase):
......@@ -23,14 +39,25 @@ class IJBABioDatabase(BioDatabase):
# call base class constructors to open a session to the database
super(IJBABioDatabase, self).__init__(name='ijba', **kwargs)
super(IJBABioDatabase, self).__init__(name='ijba', models_depend_on_protocol=True, training_depends_on_protocol=True, **kwargs)
from bob.db.ijba.query import Database as LowLevelDatabase
self.__db = LowLevelDatabase()
import bob.db.ijba
self._db = bob.db.ijba.Database()
def uses_probe_file_sets(self):
return True
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, for f in retval]
return [IJBABioFile(f) for f in self._db.objects(groups=groups, protocol=protocol, purposes=purposes, model_ids=model_ids, **kwargs)]
def object_sets(self, groups=None, protocol="search_split1", purposes=None, model_ids=None):
return [IJBABioFileSet(t) for t in self._db.object_sets(groups=groups, protocol=protocol, purposes=purposes, model_ids=model_ids)]
def annotations(self, biofile):
return self._db.annotations(biofile.f)
def client_id_from_model_id(self, model_id, group='dev'):
return self._db.get_client_id_from_model_id(model_id)
......@@ -25,11 +25,12 @@ from import db_available
from import check_database, check_database_zt
def _check_annotations(database):
def _check_annotations(database, require_eyes=True):
for file in database.all_files():
annotations = database.annotations(file)
if annotations is not None:
assert isinstance(annotations, dict)
if require_eyes:
assert 'reye' in annotations
assert 'leye' in annotations
......@@ -119,8 +120,8 @@ def test_gbu():
def test_ijba():
database ='ijba', 'database', preferred_package='')
check_database(database,models_depend=True, training_depends=True)
_check_annotations(database, require_eyes=False)
except IOError as e:
raise SkipTest(
"The database could not queried; probably the db.sql3 file is missing. Here is the error: '%s'" % e)
......@@ -114,6 +114,7 @@ setup(
'caspeal =',
'frgc =',
'gbu =',
'ijba =',
'lfw-restricted =',
'lfw-unrestricted =',
'mobio-male =', # MOBIO gender-dependent training
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment