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)[source]

Bases: object

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')[source]

Bases: bob.db.base.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.

check_parameter_for_validity(parameter, parameter_description, valid_parameters, default_parameter=None)[source]

Checks the given parameter for validity

Ensures a given parameter is in the set of valid parameters. If the parameter is None or empty, the value in 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.

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.

Checks a given parameter is 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.

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)[source]

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)[source]

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.
convert_names_to_highlevel(names, low_level_names, high_level_names)[source]

Converts group names from a low level to high level API

This is useful for example when you want to return db.groups() for the bob.bio.base. Your instance of the database should already have low_level_names and high_level_names initialized.

convert_names_to_lowlevel(names, low_level_names, high_level_names)[source]

Same as convert_names_to_highlevel but on reverse

file_names(files, directory, extension) → paths[source]

Returns the full path of the given File objects.

Parameters:

files
: [bob.db.base.File]
The list of file object to retrieve the file names for.
directory
: str
The base directory, where the files can be found.
extension
: str
The file name extension to add to all files.

Returns:

paths
: [str]
The paths extracted for the files, in the same order.
get_client_id_from_file_id(file_id, groups=None, protocol=None)[source]

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)[source]

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)[source]

Returns the names of all registered groups

Keyword parameters:

protocol
ignored.
model_ids(groups=None, protocol=None)[source]

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)[source]

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)[source]

Returns a set of File objects for the specific query by the user.

Keyword Parameters:

model_ids
: int or [int]
Limits the returned files relevant to this model id. This is expected to be used with groups=’dev’ only. When groups=’world’, this does not have any effect. 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 objects considering all the filtering criteria.

original_file_name(file)[source]

This function returns the original file name for the given File object.

Keyword parameters:

file
: bob.bio.base.database.BioFile or a derivative
The File objects for which the file name should be retrieved
Return value
: str
The original file name for the given File object
original_file_names(files) → paths[source]

Returns the full path of the original data of the given File objects.

Parameters:

files
: [bob.db.base.File]
The list of file object to retrieve the original data file names for.

Returns:

paths
: [str]
The paths extracted for the files, in the same order.
paths(file_ids, prefix=None, suffix=None, preserve_order=True)[source]

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.

reverse(paths, preserve_order=True)[source]

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).

sort(files) → sorted[source]

Returns a sorted version of the given list of File’s (or other structures that define an ‘id’ data member). The files will be sorted according to their id, and duplicate entries will be removed.

Parameters:

files
: [bob.bio.base.database.BioFile]
The list of files to be uniquified and sorted.

Returns:

sorted
: [bob.bio.base.database.BioFile]
The sorted list of files, with duplicate BioFile.ids being removed.
class bob.db.atnt.File(client_id, client_file_id)[source]

Bases: bob.db.base.File

Files of this database are composed from the client id and a file id.

static from_file_id(file_id)[source]

Returns the File object for a given file_id

static from_path(path)[source]

Returns the File object for a given path

load(directory=None, extension='.hdf5')[source]

Loads the data at the specified location and using the given extension. Override it if you need to load differently.

Keyword Parameters:

data
The data blob to be saved (normally a numpy.ndarray).
directory
[optional] If not empty or None, this directory is prefixed to the final file destination
extension
[optional] The extension of the filename - this will control the type of output and the codec for saving the input blob.
m_valid_file_ids = set([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
make_path(directory=None, extension=None)[source]

Wraps the current path so that a complete path is formed

Keyword Parameters:

directory
An optional directory name that will be prefixed to the returned result.
extension
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)[source]

Saves the input data at the specified location and using the given extension. Override it if you need to save differently.

Keyword Parameters:

data
The data blob to be saved (normally a numpy.ndarray).
directory
[optional] If not empty or None, this directory is prefixed to the final file destination
extension
[optional] The extension of the filename - this will control the type of output and the codec for saving the input blob.