Python API¶
This is the Bob database entry for the Multi-PIE database.
-
class
bob.db.multipie.Camera(name)[source]¶ Bases:
sqlalchemy.ext.declarative.api.BaseMulti-PIE cameras
-
files_multiview¶
-
id¶
-
metadata= MetaData(bind=None)¶
-
name¶
-
-
class
bob.db.multipie.Client(id, group, birthyear, gender, first_session, second_session, third_session, fourth_session)[source]¶ Bases:
sqlalchemy.ext.declarative.api.BaseDatabase clients, marked by an integer identifier and the group they belong to
-
birthyear¶
-
first_session¶
-
fourth_session¶
-
gender¶
-
gender_choices= ('male', 'female')¶
-
group_choices= ('dev', 'eval', 'world')¶
-
id¶
-
metadata= MetaData(bind=None)¶
-
second_session¶
-
sgroup¶
-
third_session¶
-
-
class
bob.db.multipie.Database(original_directory=None, original_extension='.png', annotation_directory=None, annotation_extension='.pos')[source]¶ Bases:
bob.db.verification.utils.database.SQLiteDatabase,bob.db.verification.utils.database.ZTDatabaseThe dataset class opens and maintains a connection opened to the Database.
It provides many different ways to probe for the characteristics of the data and for the data itself inside the database.
-
all_files(**kwargs)[source]¶ Returns the list of all File objects that satisfy your query. For possible keyword arguments, please check the
objects()function.
-
annotations(file)[source]¶ Reads the annotations for the given file id from file and returns them in a dictionary. Depending on the view type of the file (i.e., the camera), different annotations might be returned.
If you have no copy of the annotations yet, you can download them under http://www.idiap.ch/resource/biometric, where you also can find more information about the annotations.
Keyword parameters:
- file
- The ID of the file for which the annotations should be read.
- Return value
- The annotations as a dictionary, e.g., {‘reye’:(re_y,re_x), ‘leye’:(le_y,le_x), ...}
-
assert_validity()¶ Raise a RuntimeError if the database back-end is not available.
-
check_parameter_for_validity(parameter, parameter_description, valid_parameters, default_parameter=None)[source]¶ Checks the given parameter for validity, i.e., if it is contained in the set of valid parameters. If the parameter is ‘None’ or empty, the default_parameter will be returned, in case it is specified, otherwise a ValueError will be raised.
This function will return the parameter after the check tuple or list of parameters, or raise a ValueError.
Keyword parameters:
- parameter : str
- The single parameter to be checked. Might be a string or None.
- parameter_description : str
- A short description of the parameter. This will be used to raise an exception in case the parameter is not valid.
- valid_parameters : [str]
- A list/tuple of valid values for the parameters.
- default_parameters : [str] or None
- The default parameter that will be returned in case parameter is None or empty. If omitted and parameter is empty, a ValueError is raised.
-
check_parameters_for_validity(parameters, parameter_description, valid_parameters, default_parameters=None)[source]¶ Checks the given parameters for validity, i.e., if they are contained in the set of valid parameters. It also assures that the parameters form a tuple or a list. If parameters is ‘None’ or empty, the default_parameters will be returned (if default_parameters is omitted, all valid_parameters are returned).
This function will return a tuple or list of parameters, or raise a ValueError.
Keyword parameters:
- parameters : str, [str] or None
- The parameters to be checked. Might be a string, a list/tuple of strings, or None.
- parameter_description : str
- A short description of the parameter. This will be used to raise an exception in case the parameter is not valid.
- valid_parameters : [str]
- A list/tuple of valid values for the parameters.
- default_parameters : [str] or None
- The list/tuple of default parameters that will be returned in case parameters is None or empty. If omitted, all valid_parameters are used.
-
client(id)[source]¶ Returns the Client object in the database given a certain id. Raises an error if that does not exist.
-
clients(protocol=None, groups=None, subworld=None, genders=None, birthyears=None)[source]¶ Returns a set of Clients for the specific query by the user.
Keyword Parameters:
- protocol
- One of the Multi-PIE protocols (use protocol_names() to get the list of available ones)
- groups
- The groups to which the clients belong (‘dev’, ‘eval’, ‘world’)
- subworld
- Specify a split of the world data (‘sub41’, ‘sub81’, ‘sub121’, ‘sub161’) In order to be considered, “world” should be in groups.
- genders
- The genders to which the clients belong (‘female’, ‘male’)
- birthyears
- The birth year of the clients (in the range [1900,2050])
Returns: A list containing all the Clients which have the given properties.
-
enroll_files(protocol=None, model_id=None, groups='dev', **kwargs)[source]¶ Returns the list of enrollment File objects from the given model id of the given protocol for the given groups that satisfy your query. If the model_id is None (the default), enrollment files for all models are returned. For possible keyword arguments, please check the
objects()function.
-
file_names(files, directory, extension)[source]¶ This function returns the list of original file names for the given list of File objects.
Keyword parameters:
- files : [
File] - The list of File objects for which the file names should be retrieved
- directory : str
- The base directory where the files are stored
- extension : str
- The file name extension of the files
- Return value : [str]
- The file names for the given File objects, in the same order.
- files : [
-
files(ids, preserve_order=True)¶ Returns a list of
Fileobjects with the given file idsKeyword Parameters:
- ids : [various type]
- The ids of the object in the database table “file”. This object should be a python iterable (such as a tuple or list).
- preserve_order : bool
- If True (the default) the order of elements is preserved, but the execution time increases.
Returns a list (that may be empty) of
Fileobjects.
-
get_client_id_from_model_id(model_id, **kwargs)[source]¶ Returns the client_id attached to the given model_id
Keyword Parameters:
- model_id
- The model_id to consider
Returns: The client_id attached to the given model_id
-
is_valid()¶ Returns if a valid session has been opened for reading the database.
-
model_ids(protocol=None, groups=None)[source]¶ Returns a set of model ids for the specific query by the user.
Keyword Parameters:
- protocol
- One of the Multi-PIE protocols (use protocol_names() to get the list of available ones)
- groups
- The groups to which the subjects attached to the models belong (‘dev’, ‘eval’, ‘world’)
Returns: A list containing the ids all the models belonging to the given group.
-
models(protocol=None, groups=None)[source]¶ Returns a set of models for the specific query by the user.
Keyword Parameters:
- protocol
- One of the Multi-PIE protocols (use protocol_names() to get the list of available ones)
- groups
- The groups to which the subjects attached to the models belong (‘dev’, ‘eval’, ‘world’)
Returns: A list containing all the models belonging to the given group.
-
objects(protocol=None, purposes=None, model_ids=None, groups=None, classes=None, subworld=None, expressions=None, cameras=None, world_sampling=1, world_noflash=False, world_first=False, world_second=False, world_third=False, world_fourth=False, world_nshots=None, world_shots=None)[source]¶ Returns a set of Files for the specific query by the user.
Keyword Parameters:
- protocol
- One of the Multi-PIE protocols (use protocol_names() to get the list of available ones)
- purposes
- The purposes required to be retrieved (‘enroll’, ‘probe’, ‘train’) or a tuple with several of them. If ‘None’ is given (this is the default), it is considered the same as a tuple with all possible values. This field is ignored for the data from the “world” group.
- model_ids
- Only retrieves the files for the provided list of model ids (claimed client id). If ‘None’ is given (this is the default), no filter over the model_ids is performed.
- groups
- One of the groups (‘dev’, ‘eval’, ‘world’) or a tuple with several of them. If ‘None’ is given (this is the default), it is considered the same as a tuple with all possible values.
- classes
- The classes (types of accesses) to be retrieved (‘client’, ‘impostor’) or a tuple with several of them. If ‘None’ is given (this is the default), it is considered the same as a tuple with all possible values.
- subworld
- Specify a split of the world data (‘sub41’, ‘sub81’, ‘sub121’, ‘sub161’) In order to be considered, “world” should be in groups.
- expressions
- The (face) expressions to be retrieved (use expression_names() to get the list of expressions) or a tuple with several of them. If ‘None’ is given (this is the default), it is considered the same as a tuple with all possible values. Notice that some protocols only contain images with ‘neutral’ expression.
- cameras
- The cameras to be retrieved (use camera_names() to get the list of cameras) r a tuple with several of them. If ‘None’ is given (this is the default), it is considered the same as a tuple with all possible values. The cameras keyword has no impact for some protocols (frontal images ones).
- world_sampling
Samples the files from the world data set. Keeps only files such as:
File.client_id + File.shot_id % world_sampling == 0
This argument should be an integer between 1 (keep everything) and 19. It is not used if world_noflash is also set.
- world_nshots
- Only considers the n first shots from the world data set.
- world_shots
- Only considers the shots with the given ids.
- world_noflash
- Keeps the files from the world dataset recorded without flash (shot 0)
- world_first
- Only uses data from the first recorded session of each user of the world dataset.
- world_second
- Only uses data from the second recorded session of each user of the world dataset.
- world_third
- Only uses data from the third recorded session of each user of the world dataset.
- world_fourth
- Only uses data from the fourth recorded session of each user of the world dataset.
Returns: A set of Files with the given properties.
-
original_file_name(file, check_existence=True)[source]¶ This function returns the original file name for the given File object.
Keyword parameters:
- file :
Fileor a derivative - The File objects for which the file name should be retrieved
- check_existence : bool
- Check if the original file exists?
- Return value : str
- The original file name for the given File object
- file :
-
original_file_names(files, check_existence=True)[source]¶ This function returns the list of original file names for the given list of File objects.
Keyword parameters:
- files : [
File] - The list of File objects for which the file names should be retrieved
- check_existence : bool
- Check if the original files exists?
- Return value : [str]
- The original file names for the given File objects, in the same order.
- files : [
-
paths(ids, prefix=None, suffix=None, preserve_order=True)¶ Returns a full file paths considering particular file ids, a given directory and an extension
Keyword Parameters:
- ids : [various type]
- The ids of the object in the database table “file”. This object should be a python iterable (such as a tuple or list).
- prefix : str or None
- The bit of path to be prepended to the filename stem
- suffix : str or None
- The extension determines the suffix that will be appended to the filename stem.
- preserve_order : bool
- If True (the default) the order of elements is preserved, but the execution time increases.
Returns a list (that may be empty) of the fully constructed paths given the file ids.
-
probe_files(protocol=None, model_id=None, groups='dev', **kwargs)[source]¶ Returns the list of probe File objects to probe the model with the given model id of the given protocol for the given groups that satisfy your query. If the model_id is None (the default), all possible probe files are returned. For possible keyword arguments, please check the
objects()function.
-
protocol(name)[source]¶ Returns the protocol object in the database given a certain name. Raises an error if that does not exist.
-
provides_file_set_for_protocol(protocol=None)[source]¶ Returns True if the given protocol specifies file sets for probes, instead of a single probe file. In this default implementation, False is returned, throughout. If you need different behavior, please overload this function in your derived class.
-
query(*args)¶ Creates a query to the database using the given arguments.
-
reverse(paths, preserve_order=True)¶ Reverses the lookup: from certain paths, return a list of File objects
Keyword Parameters:
- paths : [str]
- The filename stems to query for. This object should be a python iterable (such as a tuple or list)
- preserve_order : True
- If True (the default) the order of elements is preserved, but the execution time increases.
Returns a list (that may be empty).
-
t_enroll_files(protocol, model_id, groups='dev', **kwargs)¶ Returns the list of T-Norm model enrollment File objects from the given model id of the given protocol for the given group that satisfy your query. For possible keyword arguments, please check the
tobjects()function.
-
t_model_ids(protocol, groups='dev', **kwargs)¶ Returns the list of model ids used for T-Norm of the given protocol for the given group that satisfy your query. For possible keyword arguments, please check the
tmodel_ids()function.
-
tclients(protocol=None, groups=None)[source]¶ Returns a set of T-Norm clients for the specific query by the user.
Keyword Parameters:
- protocol
- One of the Multi-PIE protocols (use protocol_names() to get the list of available ones)
- groups
- The groups to which the clients belong (‘dev’, ‘eval’).
Returns: A list containing all the client ids belonging to the given group.
-
test_files(protocol=None, groups='dev', **kwargs)[source]¶ Returns the list of all test File objects of the given groups that satisfy your query. Test objects are all File objects that serve either for enrollment or probing. For possible keyword arguments, please check the
objects()function.
-
tmodel_ids(protocol=None, groups=None)[source]¶ Returns a set of T-Norm model ids for the specific query by the user.
Keyword Parameters:
- protocol
- One of the Multi-PIE protocols (use protocol_names() to get the list of available ones)
- groups
- The groups to which the models belong (‘dev’, ‘eval’).
Returns: A list containing all ids of the T-Norm models belonging to the given group.
-
tmodels(protocol=None, groups=None)[source]¶ Returns a set of T-Norm models for the specific query by the user.
Keyword Parameters:
- protocol
- One of the Multi-PIE protocols (use protocol_names() to get the list of available ones)
- groups
- The groups to which the models belong (‘dev’, ‘eval’).
Returns: A list containing all the T-Norm models belonging to the given group.
-
tobjects(protocol=None, model_ids=None, groups=None, expressions=None)[source]¶ - Returns a set of filenames for enrolling T-norm models for score
- normalization.
Keyword Parameters:
- protocol
- One of the Multi-PIE protocols (use protocol_names() to get the list of available ones)
- model_ids
- Only retrieves the files for the provided list of model ids (claimed client id). If ‘None’ is given (this is the default), no filter over the model_ids is performed.
- groups
- The groups to which the clients belong (‘dev’, ‘eval’).
- expressions
- The (face) expressions to be retrieved (use expression_names() to get the list of expressions) or a tuple with several of them. If ‘None’ is given (this is the default), it is considered the same as a tuple with all possible values. Notice that some protocols only contain images with ‘neutral’ expression.
Returns: A list of Files with the given properties.
-
training_files(protocol=None, **kwargs)[source]¶ Returns the list of all training (world) File objects that satisfy your query. For possible keyword arguments, please check the
objects()function.
-
uniquify(file_list)[source]¶ Sorts the given list of File objects and removes duplicates from it.
Keyword parameters:
- file_list : [
File] - A list of File objects to be handled. Also other objects can be handled, as long as they are sortable.
- Returns
- A sorted copy of the given
file_listwith the duplicates removed.
- file_list : [
-
z_probe_files(protocol, groups='dev', **kwargs)¶ Returns the list of Z-Norm probe File objects to probe the model with the given model id of the given protocol for the given group that satisfy your query. For possible keyword arguments, please check the
zobjects()function.
-
zclients(protocol=None, groups=None)[source]¶ Returns a set of Z-Norm clients for the specific query by the user.
Keyword Parameters:
- protocol
- One of the Multi-PIE protocols (use protocol_names() to get the list of available ones)
- groups
- The groups to which the clients belong (‘dev’, ‘eval’).
Returns: A list containing all the client ids belonging to the given group.
-
zobjects(protocol=None, model_ids=None, groups=None, expressions=None)[source]¶ Returns a set of filenames of impostors for Z-norm score normalization.
Keyword Parameters:
- protocol
- One of the Multi-PIE protocols (use protocol_names() to get the list of available ones)
- model_ids
- Only retrieves the files for the provided list of model ids (client id). If ‘None’ is given (this is the default), no filter over the model_ids is performed.
- groups
- The groups to which the clients belong (‘dev’, ‘eval’).
- expressions
- The (face) expressions to be retrieved (use expression_names() to get the list of expressions) or a tuple with several of them. If ‘None’ is given (this is the default), it is considered the same as a tuple with all possible values. Notice that some protocols only contain images with ‘neutral’ expression.
Returns: A list of Files with the given properties.
-
-
class
bob.db.multipie.Expression(name)[source]¶ Bases:
sqlalchemy.ext.declarative.api.BaseMulti-PIE expressions
-
files¶
-
id¶
-
metadata= MetaData(bind=None)¶
-
name¶
-
-
class
bob.db.multipie.File(client_id, path, session_id, recording_id, img_type, expression_id)[source]¶ Bases:
sqlalchemy.ext.declarative.api.Base,bob.db.verification.utils.file.FileGeneric file container
-
client¶
-
client_id¶
-
expression_id¶
-
id¶
-
imagetype_choices= ('multiview', 'highres')¶
-
img_type¶
-
make_path(directory=None, extension=None)[source]¶ Wraps the current path so that a complete path is formed
Keyword parameters:
- directory : str or None
- An optional directory name that will be prefixed to the returned result.
- extension : str or None
- An optional extension that will be suffixed to the returned filename.
The extension normally includes the leading
.character as in.jpgor.hdf5.
Returns a string containing the newly generated file path.
-
metadata= MetaData(bind=None)¶
-
path¶
-
recording_id¶
-
save(data, directory=None, extension='.hdf5', create_directories=True)[source]¶ Saves the input data at the specified location and using the given extension.
Keyword parameters:
- data : various types
- The data blob to be saved (normally a
numpy.ndarray). - directory : str or None
- If not empty or None, this directory is prefixed to the final file destination
- extension : str or None
- The extension of the filename. This extension will control the type of output and the codec for saving the input blob.
- create_directories : bool
- Should the directory structure be created (if necessary) before writing the data?
-
session_id¶
-
-
class
bob.db.multipie.FileMultiview(file_id, shot_id, camera_id)[source]¶ Bases:
sqlalchemy.ext.declarative.api.BaseAdditional file information for multiview-like files
-
camera_id¶
-
file¶
-
id¶
-
metadata= MetaData(bind=None)¶
-
shot_id¶
-
-
class
bob.db.multipie.Protocol(name)[source]¶ Bases:
sqlalchemy.ext.declarative.api.BaseMulti-PIE protocols
-
id¶
-
metadata= MetaData(bind=None)¶
-
name¶
-
-
class
bob.db.multipie.ProtocolPurpose(protocol_id, sgroup, purpose)[source]¶ Bases:
sqlalchemy.ext.declarative.api.BaseMulti-PIE protocol purposes
-
files¶
-
group_choices= ('dev', 'eval', 'world')¶
-
id¶
-
metadata= MetaData(bind=None)¶
-
protocol¶
-
protocol_id¶
-
purpose¶
-
purpose_choices= ('train', 'enroll', 'probe')¶
-
sgroup¶
-