Python API
The AT&T “Database of Faces” is a small free facial image database to test face
recognition and verification algorithms on. It is also known by its former name
“The ORL Database of Faces”. You can download the AT&T database from:
http://www.cl.cam.ac.uk/research/dtg/attarchive/facedatabase.html
-
bob.db.atnt.get_config()[source]
Returns a string containing the configuration information.
-
class bob.db.atnt.Client(client_id)
The clients of this database contain ONLY client ids. Nothing special.
-
m_valid_client_ids = set([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40])
-
class bob.db.atnt.Database(original_directory=None, original_extension='.pgm')
Bases: bob.db.verification.utils.database.Database
Wrapper class for the AT&T (aka ORL) database of faces (http://www.cl.cam.ac.uk/research/dtg/attarchive/facedatabase.html).
This class defines a simple protocol for training, enrollment and probe by splitting the few images of the database in a reasonable manner.
Due to the small size of the database, there is only a ‘dev’ group, and I did not define an ‘eval’ group.
Constructor Documentation
Generates a database.
Keyword parameters
- original_directory : str, optional
- The directory, where you extracted the original images to.
- original_extension : str
- The filename extension of the original images. Rarely changed.
-
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)
This function returns the annotations for the given file id as a dictionary.
Keyword parameters:
- file : bob.db.verification.utils.File or one of its derivatives
- The File object you want to retrieve the annotations for,
- Return value:
- A dictionary of annotations, for face images usually something like {‘leye’:(le_y,le_x), ‘reye’:(re_y,re_x), ...},
or None if there are no annotations for the given file ID (which is the case in this base class implementation).
-
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, protocol=None)
Returns the vector of ids of the clients used in a given group
Keyword Parameters:
- groups : str or [str]
- One of the groups ‘world’, ‘dev’ or a tuple with both of them (which is the default).
- protocol
- Ignored.
-
clients(groups=None, protocol=None)
Returns the vector of clients used in a given group
Keyword Parameters:
- groups : str or [str]
- One of the groups ‘world’, ‘dev’ or a tuple with both of them (which is the default).
- protocol
- Ignored.
-
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.
-
get_client_id_from_file_id(file_id, groups=None, protocol=None)
Returns the client id from the given image id.
Keyword Parameters:
- file_id : int
- The ID of the File object to get the client id for
- groups
- ignored.
- protocol
- ignored.
-
get_client_id_from_model_id(model_id, groups=None, protocol=None)
Returns the client id from the given model id.
Since client and model ids are identical, the model id is returned.
Keyword Parameters:
- model_id : int
- The id of the model.
- groups
- ignored.
- protocol
- ignored.
-
groups(protocol=None)
Returns the names of all registered groups
Keyword parameters:
- protocol
- ignored.
-
model_ids(groups=None, protocol=None)
Returns the vector of ids of the models (i.e., the client ids) used in a given group
Keyword Parameters:
- groups : str or [str]
- One of the groups ‘world’, ‘dev’ or a tuple with both of them (which is the default).
- protocol
- Ignored.
-
models(groups=None, protocol=None)
Returns the vector of models ( == clients ) used in a given group
Keyword Parameters:
- groups : str or [str]
- One of the groups ‘world’, ‘dev’ or a tuple with both of them (which is the default).
- protocol
- Ignored.
-
objects(model_ids=None, groups=None, purposes=None, protocol=None)
Returns a set of File objects for the specific query by the user.
Keyword Parameters:
- model_ids : int or [int]
- The ids of the clients whose files need to be retrieved. Should be a list of integral numbers from [1,40]
- groups : str or [str]
- One of the groups ‘world’ or ‘dev’ or a list with both of them (which is the default).
- purposes : str or [str]
- One of the purposes ‘enroll’ or ‘probe’ or a list with both of them (which is the default).
This field is ignored when the group ‘world’ is selected.
- protocol
- Ignored.
Returns: A list of File’s considering all the filtering criteria.
-
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(file_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:
- file_ids : int or [int]
- The list of ids of the File objects in the database.
- prefix : str
- The bit of path to be prepended to the filename stem
- suffix : str
- The extension determines the suffix that will be appended to the filename
stem.
- preserve_order : bool
- Ignored since the order is always preserved.
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.
-
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.
-
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 : bool
- Ignored since the order is always preserved.
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.atnt.File(client_id, client_file_id)
Bases: bob.db.verification.utils.file.File
Files of this database are composed from the client id and a file id.
-
static from_file_id(file_id)
Returns the File object for a given file_id
-
static from_path(path)
Returns the File object for a given path
-
m_valid_file_ids = set([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
-
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.
-
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?