CAS-PEAL Database
This is the Bob database entry for the CAS-PEAL database.
-
bob.db.caspeal.get_config()[source]
Returns a string containing the configuration information.
-
class bob.db.caspeal.Annotation(file_id, eyes)
Bases: sqlalchemy.ext.declarative.api.Base
Annotations of the CAS-PEAL database consists only of the left and right eye positions.
There is exactly one annotation for each file.
-
file_id
-
id
-
le_x
-
le_y
-
metadata = MetaData(bind=None)
-
re_x
-
re_y
-
class bob.db.caspeal.Client(client_type, client_id)
Bases: sqlalchemy.ext.declarative.api.Base
Information about the clients (identities) of the CAS-PEAL database
Creates a client name by parsing the given first two part of the filename
-
age
-
age_choices = ('Y', 'M', 'O')
-
gender
-
gender_choices = ('F', 'M')
-
id
-
metadata = MetaData(bind=None)
-
class bob.db.caspeal.Database(original_directory=None, original_extension='.tif')
Bases: bob.db.verification.utils.database.SQLiteDatabase
The database 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)
Returns the list of all File objects that satisfy your query.
For possible keyword arguments, please check the implementation of the derived class Database.objects() function.
-
annotations(file)
Returns the annotations for the given file id as a dictionary {‘reye’:(y,x), ‘leye’:(y,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)
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)
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_ids(groups=None, genders=None, ages=None, protocol=None)
Returns a list of client ids for the specific query by the user.
Keyword Parameters:
- groups
- One or several groups to which the models belong (‘world’, ‘dev’, ‘eval’).
If not specified, all groups are returned.
- genders
- One of the genders (‘m’, ‘w’) of the clients.
If not specified, clients of all genders are returned.
- ages
- One or several of the age ranges (‘Y’, ‘M’, ‘O’) of the clients.
If not specified, clients of all age ranges are returned.
- protocol
- Ignored since clients are identical for all protocols.
Returns: A list containing all the client ids which have the desired properties.
-
clients(groups=None, genders=None, ages=None, protocol=None)
Returns a list of Client objects for the specific query by the user.
Keyword Parameters:
- groups
- One or several groups to which the models belong (‘world’, ‘dev’).
If not specified, all groups are returned.
- genders
- One or several of the genders (‘F’, ‘M’) of the clients.
If not specified, clients of all genders are returned.
- ages
- One or several of the age ranges (‘Y’, ‘M’, ‘O’) of the clients.
If not specified, clients of all age ranges are returned.
- protocol
- Ignored since clients are identical for all protocols.
Returns: A list containing all the Client objects which have the desired properties.
-
enroll_files(protocol=None, model_id=None, groups='dev', **kwargs)
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 implementation of the derived class Database.objects() function.
-
file_names(files, directory, extension)
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(ids, preserve_order=True)
Returns a list of File objects with the given file ids
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).
- 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 File objects.
-
get_client_id_from_file_id(file_id, **kwargs)
Returns the client_id attached to the given file_id
Keyword Parameters:
- file_id
- The file_id to consider
Returns: The client_id attached to the given file_id
-
get_client_id_from_model_id(model_id)
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
-
groups(protocol=None)
Returns a list of groups for the given protocol
Keyword Parameters:
- protocol
- Ignored since groups are identical for all protocols.
Returns: a list of groups
-
has_protocol(name)
Tells if a certain protocol is available
-
is_valid()
Returns if a valid session has been opened for reading the database.
-
model_ids(groups=None, genders=None, ages=None, protocol=None)
Returns a list of client ids for the specific query by the user.
Keyword Parameters:
- groups
- One or several groups to which the models belong (‘world’, ‘dev’, ‘eval’).
If not specified, all groups are returned.
- genders
- One of the genders (‘m’, ‘w’) of the clients.
If not specified, clients of all genders are returned.
- ages
- One or several of the age ranges (‘Y’, ‘M’, ‘O’) of the clients.
If not specified, clients of all age ranges are returned.
- protocol
- Ignored since clients are identical for all protocols.
Returns: A list containing all the client ids which have the desired properties.
-
objects(groups=None, protocol=None, purposes=None, model_ids=None, genders=None, ages=None, lightings=None, poses=None, expressions=None, accessories=None, distances=None, sessions=None, backgrounds=None)
Using the specified restrictions, this function returns a list of File objects.
Note that in rare cases, File objects with the same path, but different ID’s might be returned.
This is due to the fact that some images are in both the training list and in one of the gallery or probe lists.
Note further that the training set consists only of files with frontal pose (‘M+00’).
Keyword Parameters:
- groups
- One or several groups to which the models belong (‘world’, ‘dev’).
- protocol
- One of the CAS-PEAL protocols (‘accessory’, ‘aging’, ‘background’, ‘distance’, ‘expression’, ‘lighting’, ‘pose’).
Note: this field is ignored for group ‘world’.
Note: this field is ignored for purpose ‘enroll’.
- purposes
- One or several purposes for which files should be retrieved (‘enroll’, ‘probe’).
Note: this field is ignored for group ‘world’.
- model_ids
- If given (as a list of model id’s or a single one), only the files belonging to the specified model id is returned.
For ‘probe’ purposes, this field is ignored since probe files are identical for all models.
- genders
- One or several of the genders (‘F’, ‘M’) of the clients.
If not specified, objects of all genders are returned.
- ages
- One or several of the age ranges (‘Y’, ‘M’, ‘O’) of the clients.
If not specified, objects of all age ranges are returned.
- lightings
- One or several of the possible lightings (e.g. ‘EU+00’ or ‘FM-45’).
If not specified, objects of all lightings will be returned.
Note: this field is ignored for purpose ‘enroll’.
- poses
- One or several of the possible poses (e.g. ‘M+00’, ‘U-67’).
If not specified, objects of all poses are returned.
Note: this field is ignored for purpose ‘enroll’.
Note: for group ‘world’, only pose ‘M+00’ is available.
- expressions
- One or several expressions from (‘N’, ‘L’, ‘F’, ‘S’, ‘C’, ‘O’).
If not specified, objects of all expressions are returned.
Note: this field is ignored for purpose ‘enroll’.
- accessories
- One or several accessories from (0, 1, 2, 3, 4, 5, 6).
If not specified, objects of all accessories are returned.
Note: this field is ignored for purpose ‘enroll’.
- distances
- One or several distances from (0, 1, 2).
If not specified, objects of all distances are returned.
Note: this field is ignored for purpose ‘enroll’.
- sessions
- One or several sessions from (0, 1, 2).
If not specified, objects of all sessions are returned.
Note: this field is ignored for purpose ‘enroll’.
- backgrounds
- One or several backgrounds from (‘B’, ‘R’, ‘D’, ‘Y’, ‘W’).
If not specified, objects of all backgrounds are returned.
Note: this field is ignored for purpose ‘enroll’.
-
original_file_name(file, check_existence=True)
This function returns the original file name for the given File object.
Keyword parameters:
- file : File or 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
-
original_file_names(files, check_existence=True)
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.
-
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)
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 implementation of the derived class Database.objects() function.
-
protocol_names()
Returns all registered protocol names
-
protocols()
Returns all registered protocols
-
provides_file_set_for_protocol(protocol=None)
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).
-
test_files(protocol=None, groups='dev', **kwargs)
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 implementation of the derived class Database.objects() function.
-
training_files(protocol=None, **kwargs)
Returns the list of all training (world) File objects that satisfy your query.
For possible keyword arguments, please check the implementation of the derived class Database.objects() function.
-
uniquify(file_list)
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 list with the duplicated removed.
-
class bob.db.caspeal.File(image_path, protocol)
Bases: sqlalchemy.ext.declarative.api.Base, bob.db.verification.utils.file.File
Information about the files of the CAS-PEAL face database. Each file includes
- the session
- the expression
- the pose
- the lighting
- the camera distance
- the accessory
- the background
- a privacy field describing whether the image file might be published in papers
- the client id
- the path
-
a = '+90'
-
accessory
-
accessory_choices = [0, 1, 2, 3, 4, 5, 6]
-
accessory_type()
-
annotation
-
background
-
background_choices = ('B', 'R', 'D', 'Y', 'W')
-
background_type()
-
client
-
client_id
-
distance
-
distance_choices = [0, 1, 2]
-
e = 'D'
-
elevation_choices = ('U', 'M', 'D')
-
expression
-
expression_choices = ('N', 'L', 'F', 'S', 'C', 'O')
-
expression_type()
-
id
-
itertools = <module 'itertools' from '/home/travis/virtualenv/python3.12.2/lib/python2.7/lib-dynload/itertools.so'>
-
lighting
-
lighting_azimuth()
-
lighting_azimuth_choices = ('-90', '-45', '+00', '+45', '+90')
-
lighting_choices = ['EU-90', 'EU-45', 'EU+00', 'EU+45', 'EU+90', 'EM-90', 'EM-45', 'EM+00', 'EM+45', 'EM+90', 'ED-90', 'ED-45', 'ED+00', 'ED+45', 'ED+90', 'FU-90', 'FU-45', 'FU+00', 'FU+45', 'FU+90', 'FM-90', 'FM-45', 'FM+00', 'FM+45', 'FM+90', 'FD-90', 'FD-45', 'FD+00', 'FD+45', 'FD+90', 'LU-90', 'LU-45', 'LU+00', 'LU+45', 'LU+90', 'LM-90', 'LM-45', 'LM+00', 'LM+45', 'LM+90', 'LD-90', 'LD-45', 'LD+00', 'LD+45', 'LD+90']
-
lighting_elevation()
-
lighting_type()
-
lighting_type_choices = ('E', 'F', 'L')
-
make_path(directory=None, extension=None)
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 .jpg or .hdf5.
Returns a string containing the newly generated file path.
-
metadata = MetaData(bind=None)
-
path
-
pose
-
pose_azimuth()
-
pose_azimuth_choices = ('-90', '-67', '-45', '-30', '-22', '-15', '+00', '+15', '+22', '+30', '+45', '+67', '+90')
-
pose_choices = ['U-90', 'U-67', 'U-45', 'U-30', 'U-22', 'U-15', 'U+00', 'U+15', 'U+22', 'U+30', 'U+45', 'U+67', 'U+90', 'M-90', 'M-67', 'M-45', 'M-30', 'M-22', 'M-15', 'M+00', 'M+15', 'M+22', 'M+30', 'M+45', 'M+67', 'M+90', 'D-90', 'D-67', 'D-45', 'D-30', 'D-22', 'D-15', 'D+00', 'D+15', 'D+22', 'D+30', 'D+45', 'D+67', 'D+90']
-
pose_elevation()
-
privacy
-
protocol
-
protocol_id
-
purpose
-
purpose_choices = ('world', 'enroll', 'probe')
-
save(data, directory=None, extension='.hdf5', create_directories=True)
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
-
session_choices = [0, 1, 2]
-
t = 'L'
-
class bob.db.caspeal.Protocol(name)
Bases: sqlalchemy.ext.declarative.api.Base
The probe protocols of the CAS-PEAL database. Training and enrollment is identical for all protocols of CAS-PEAL.
-
id
-
metadata = MetaData(bind=None)
-
name
-
protocol_choices = ('training', 'gallery', 'accessory', 'aging', 'background', 'distance', 'expression', 'lighting', 'pose')