Ported MOBIO as CSVDatabase

parent 10ca24c0
Pipeline #46692 passed with stage
in 43 minutes and 3 seconds
#!/usr/bin/env python
from bob.bio.face.database import MobioBioDatabase
from bob.bio.base.pipelines.vanilla_biometrics import DatabaseConnector
from bob.extension import rc
database = DatabaseConnector(
MobioBioDatabase(
original_directory=rc["bob.db.mobio.directory"],
annotation_directory=rc["bob.db.mobio.annotation_directory"],
original_extension=".png",
protocol="mobile0-male",
)
)
database.allow_scoring_with_all_biometric_references = True
mobio_image_directory = rc["bob.db.mobio.directory"]
mobio_annotation_directory = rc["bob.db.mobio.annotation_directory"]
allow_scoring_with_all_biometric_references = True
annotation_type = "eyes-center"
fixed_positions = None
mobio_image = DatabaseConnector(
MobioBioDatabase(
original_directory=mobio_image_directory,
original_extension=".png",
annotation_directory=mobio_annotation_directory,
annotation_type="eyecenter",
protocol="male",
models_depend_on_protocol=True,
),
allow_scoring_with_all_biometric_references=allow_scoring_with_all_biometric_references,
annotation_type=annotation_type,
fixed_positions=fixed_positions,
)
mobio_male = DatabaseConnector(
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"},
),
allow_scoring_with_all_biometric_references=allow_scoring_with_all_biometric_references,
annotation_type=annotation_type,
fixed_positions=fixed_positions,
)
mobio_female = DatabaseConnector(
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"},
),
allow_scoring_with_all_biometric_references=allow_scoring_with_all_biometric_references,
annotation_type=annotation_type,
fixed_positions=fixed_positions,
)
#!/usr/bin/env python
from bob.bio.face.database import MobioBioDatabase
from bob.bio.base.pipelines.vanilla_biometrics import DatabaseConnector
from bob.extension import rc
database = DatabaseConnector(
MobioBioDatabase(
original_directory=rc["bob.db.mobio.directory"],
annotation_directory=rc["bob.db.mobio.annotation_directory"],
original_extension=".png",
protocol="mobile0-male-female",
),
annotation_type = "eyes-center",
fixed_positions = None
)
from bob.bio.face.database import MobioDatabase
database = MobioDatabase(protocol="mobile0-male-female")
#!/usr/bin/env python
from bob.bio.face.database import MobioBioDatabase
from bob.bio.base.pipelines.vanilla_biometrics import DatabaseConnector
from bob.extension import rc
database = DatabaseConnector(
MobioBioDatabase(
original_directory=rc["bob.db.mobio.directory"],
annotation_directory=rc["bob.db.mobio.annotation_directory"],
original_extension=".png",
protocol="mobile0-male",
),
annotation_type = "eyes-center",
fixed_positions = None
)
from bob.bio.face.database import MobioDatabase
database = MobioDatabase(protocol="mobile0-male")
......@@ -2,7 +2,7 @@
# vim: set fileencoding=utf-8 :
from .database import FaceBioFile
from .mobio import MobioBioDatabase
from .mobio import MobioDatabase
from .replay import ReplayBioDatabase
from .atnt import AtntBioDatabase
from .gbu import GBUBioDatabase
......@@ -35,7 +35,7 @@ def __appropriate__(*args):
__appropriate__(
FaceBioFile,
MobioBioDatabase,
MobioDatabase,
ReplayBioDatabase,
AtntBioDatabase,
GBUBioDatabase,
......
#!/usr/bin/env python
# vim: set fileencoding=utf-8 :
# Amir Mohammadi <amir.mohammadi@idiap.ch>
# Wed 13 Jul 16:43:22 CEST 2016
# Tiago de Freitas Pereira <tiago.pereira@idiap.ch>
"""
MOBIO database implementation of bob.bio.base.database.ZTBioDatabase interface.
It is an extension of an SQL-based database interface, which directly talks to Mobio database, for
verification experiments (good to use in bob.bio.base framework).
MOBIO database implementation
"""
from bob.bio.base.database import (
CSVDataset,
CSVDatasetZTNorm,
)
from bob.pipelines.datasets import CSVToSampleLoader
from bob.bio.face.database.sample_loaders import EyesAnnotations
from bob.extension import rc
from bob.extension.download import get_file
import bob.io.base
from sklearn.pipeline import make_pipeline
from .database import FaceBioFile
from bob.bio.base.database import ZTBioDatabase
class MobioBioFile(FaceBioFile):
"""FaceBioFile implementation of the Mobio 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):
"""
MOBIO database implementation of bob.bio.base.database.ZTBioDatabase interface.
It is an extension of an SQL-based database interface, which directly talks to Mobio database, for
verification experiments (good to use in bob.bio.base framework).
class MobioDatabase(CSVDatasetZTNorm):
"""
The MOBIO dataset is a video database containing bimodal data (face/speaker).
It is composed by 152 people (split in the two genders male and female), mostly Europeans, split in 5 sessions (few weeks time lapse between sessions).
The database was recorded using two types of mobile devices: mobile phones (NOKIA N93i) and laptop
computers(standard 2008 MacBook).
For face recognition images are used instead of videos.
One image was extracted from each video by choosing the video frame after 10 seconds.
The eye positions were manually labelled and distributed with the database.
For more information check:
.. code-block:: latex
@article{McCool_IET_BMT_2013,
title = {Session variability modelling for face authentication},
author = {McCool, Chris and Wallace, Roy and McLaren, Mitchell and El Shafey, Laurent and Marcel, S{\'{e}}bastien},
month = sep,
journal = {IET Biometrics},
volume = {2},
number = {3},
year = {2013},
pages = {117-129},
issn = {2047-4938},
doi = {10.1049/iet-bmt.2012.0059},
}
def __init__(
self,
original_directory=None,
original_extension=None,
annotation_directory=None,
annotation_extension='.pos',
**kwargs
):
from bob.db.mobio.query import Database as LowLevelDatabase
self._db = LowLevelDatabase(original_directory, original_extension,
annotation_directory, annotation_extension)
# call base class constructors to open a session to the database
super(MobioBioDatabase, self).__init__(
name='mobio',
original_directory=original_directory,
original_extension=original_extension,
annotation_directory=annotation_directory,
annotation_extension=annotation_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
@property
def annotation_directory(self):
return self._db.annotation_directory
@annotation_directory.setter
def annotation_directory(self, value):
self._db.annotation_directory = value
def model_ids_with_protocol(self, groups=None, protocol=None, gender=None):
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)
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 [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 [MobioBioFile(f) for f in retval]
def zobjects(self, groups=None, protocol=None, **kwargs):
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)
def groups(self, protocol=None, **kwargs):
return self._db.groups(protocol=protocol)
"""
def __init__(self, protocol):
# Downloading model if not exists
urls = [
"https://www.idiap.ch/software/bob/databases/latest/mobio.tar.gz",
"http://www.idiap.ch/software/bob/databases/latest/mobio.tar.gz",
]
filename = get_file("mobio.tar.gz", urls)
self.annotation_type = "eyes-center"
self.fixed_positions = None
database = CSVDataset(
filename,
protocol,
csv_to_sample_loader=make_pipeline(
CSVToSampleLoader(
data_loader=bob.io.base.load,
dataset_original_directory=rc["bob.db.mobio.directory"]
if rc["bob.db.mobio.directory"]
else "",
extension=".png",
),
EyesAnnotations(),
),
)
super().__init__(database)
# def zprobes(self, proportion=0.20):
# return super().zprobes(proportion=proportion)
@staticmethod
def protocols():
# TODO: Until we have (if we have) a function that dumps the protocols, let's use this one.
return [
"laptop1-female",
"laptop_mobile1-female",
"mobile0-female",
"mobile0-male-female",
"mobile1-male",
"laptop1-male",
"laptop_mobile1-male",
"mobile0-male",
"mobile1-female",
]
......@@ -156,39 +156,34 @@ def test_lfw():
)
@db_available("mobio")
def test_mobio():
database = bob.bio.base.load_resource(
"mobio-image", "database", preferred_package="bob.bio.face"
)
try:
check_database_zt(database, models_depend=True)
check_database_zt(database, protocol="female", models_depend=True)
check_database_zt(
bob.bio.base.load_resource(
"mobio-male", "database", preferred_package="bob.bio.face"
),
models_depend=True,
)
check_database_zt(
bob.bio.base.load_resource(
"mobio-female", "database", preferred_package="bob.bio.face"
),
models_depend=True,
)
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
)
from bob.bio.face.database import MobioDatabase
try:
_check_annotations(database, limit_files=1000)
except IOError as e:
raise SkipTest(
"The annotations could not be queried; probably the annotation files are missing. Here is the error: '%s'"
% e
)
protocols = MobioDatabase.protocols()
for p in protocols:
database = MobioDatabase(protocol=p)
assert len(database.background_model_samples()) > 0
assert len(database.treferences()) > 0
assert len(database.zprobes()) > 0
assert len(database.references(group="dev")) > 0
assert len(database.probes(group="dev")) > 0
assert len(database.references(group="eval")) > 0
assert len(database.probes(group="eval")) > 0
# Sanity check on mobio-male
database = MobioDatabase(protocol="mobile0-male")
assert len(database.treferences()) == 16
assert len(database.zprobes()) == 1920
assert len(database.background_model_samples()) == 9600
assert len(database.references()) == 24
assert len(database.probes()) == 2520
assert len(database.references(group="eval")) == 38
assert len(database.probes(group="eval")) == 3990
@db_available("multipie")
......
......@@ -75,7 +75,6 @@ test:
- bob.db.gbu
- bob.db.ijbc
- bob.db.lfw
- bob.db.mobio
- bob.db.multipie
- bob.db.replay
- bob.db.replaymobile
......
......@@ -13,7 +13,7 @@ Databases
.. autosummary::
bob.bio.face.database.ARFaceBioDatabase
bob.bio.face.database.AtntBioDatabase
bob.bio.face.database.MobioBioDatabase
bob.bio.face.database.MobioDatabase
bob.bio.face.database.ReplayBioDatabase
bob.bio.face.database.ReplayMobileBioDatabase
bob.bio.face.database.GBUBioDatabase
......
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