Python API

This section includes information about the Python API of bob.db.avspoof_btas2016.spoofing database interfaces.

AVspoof database implementation of antispoofing.utils.db.Database interface. This interface is useful in anti-spoofing experiments. It is an extension of an SQL-based interface, which deals with AVspoof database directly.

class bob.db.avspoof_btas2016.spoofing.File(f)[source]

Bases: antispoofing.utils.db.database.File

Initializes this File object with an File equivalent from the underlying SQl-based interface for AVspoof database

videofile(directory=None)[source]

This method is used to return an audio file (at the moment, AVspoof contains audio files only). We use ‘videofile’ method here because antispoofing.utils.db.File interface does not define an audiofile, which makes things a little ugly.

Returns:Audio file from AVspoof database.
facefile(directory=None)[source]

A legacy method from antispoofing.utils.db.File interface. Since there are no faces in AVspoof, this method returns None. :return: None

bbx(directory=None)[source]

A legacy method from antispoofing.utils.db.File interface. Since there are no bounding boxes in AVspoof, this method returns None. :return: None

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

Loads the data at the specified location and using the given extension.

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.
save(data, directory=None, extension='.hdf5')[source]

Saves the input data at the specified location and using the given extension.

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

get_client_id()[source]

The client identifier to which this file is bound to

is_real()[source]

Returns True if the file belongs to a real access, False otherwise

class bob.db.avspoof_btas2016.spoofing.Database(args=None)[source]

Bases: antispoofing.utils.db.database.Database

Implements API of antispoofing interface for AVspoof database

Initializes an instanced of the Database with argparse parsed arguments.

set_kwargs(params)[source]

Set internal __kwargs variable, since it is used as a filter to retrieve data from the database :param params: dictionary of pairs {“param”:”value”} that are accepted by the database as filters, for instance, it can be “protocol”:”specific_protocol_name”. :return: None

get_protocols()[source]

Get the protocols available for this database.

get_attack_types()[source]

Get the attack types available for this database.

create_subparser(subparser, entry_point_name)[source]

Creates a subparser for the central manager taking into consideration the options for every module that can provide those

Keyword parameters

subparser
The argparse subparser I’ll attach to
entry_point_name
My name, given on the setup of this package (or whatever I’m declared as an entry_point).
name()[source]

Returns the name (string) of the database.

short_name()[source]

Returns the short name (string) of the database.

version()[source]

Returns the version (string) of the database.

short_description()[source]

Returns a short (1 line) description about this database

long_description()[source]

Returns a longer description about this database

implements_any_of(propname)[source]

Only support for audio files is implemented/ :param propname: The type of data-support, which is checked if it contains ‘audio’ :return: True if propname is None, it is equal to or contains ‘audio’, otherwise False.

get_clients(group=None)[source]

Will return the ids of the clients in this database, based on the group (train, devel or test)

get_data(group)[source]

Returns either all objects or objects for a specific group

Parameters:group – The groups corresponds to the subset of the AVspoof data that is used for either training, development, or evaluation tasks. It can be ‘train’, ‘devel’, ‘test’, or their tuple.
Returns:Two lists of File objects (antispoofing.utils.db.File) in the form of [real, attack]. The first list - real or genuine data and the second list is attacks or spoofed data.
get_enroll_data(group=None)[source]

Will return the enrollment File objects (antispoofing.utils.db.files.File) for the specified group (or for all groups)

get_train_data()[source]

Will return the real access and the attack File objects (antispoofing.utils.db.files.File) for training the antispoofing classifier

get_devel_data()[source]

Will return the real access and the attack File objects (antispoofing.utils.db.files.File) for development (supposed to tune the antispoofing classifier)

get_test_data()[source]

Will return the real access and the attack File objects (antispoofing.utils.db.files.File) for test (supposed to report the results)

get_test_filters()[source]

Will return a list with the valid filter strings that can be used during test, to organize the data in sub-categories instead of returning a whole set of real-accesses and attacks.

get_filtered_test_data(filter)[source]

Will return a dictionary with keys corresponding to the filtered categories defined by filter and the values corresponding to the real-access and attack objects that should be considered for testing your classification for that sub-category.

get_filtered_devel_data(filter)[source]

Will return a dictionary with keys corresponding to the filtered categories defined by filter and the values corresponding to the real-access and attack objects that should be considered for development of your method for that sub-category.

create_parser(parser, implements_any_of=None)[source]

Defines a sub parser for each database, with optional properties.

Keyword Parameters:

parser
The argparse.ArgumentParser to which I’ll attach the subparsers to
implements_any_of
A string or an interable over strings that determine at least one property that the given database has to fullfill so that it gets included in the parser. This method will call the instance’s implements() to find if the instance implements or not the given access protocol.
get_all_data()[source]

Will return the real access and the attack File objects (antispoofing.utils.db.files.File) for ALL group sets