Presentation Attack Detection in Voice Biometrics

This package is an extension of the bob.pad.base presentation attack detection (PAD) framework package for voice biometrics.

Tools implemented in bob.pad.voice

Extractors

class bob.pad.voice.extractor.LBPs(features_processor, n_lbps=2, lbp_neighbors=16, lbp_to_average=False, lbp_uniform=False, lbp_radius=1, lbp_circular=True, lbp_elbp_type='regular', band_ratios=True, **kwargs)

Bases: bob.pad.voice.extractor.Ratios

Extractor that computes histograms of LBP features from a textogram, which, in turn, is computed by a cepstral or spectral extractor passed as an argument.

compute_lbps(data)[source]
compute_ratios(data)
get_features(input_data, annotations)[source]
load(extractor_file)

Loads the parameters required for feature extraction from the extractor file. This function usually is only useful in combination with the train() function. In this base class implementation, it does nothing.

Parameters:

extractor_filestr

The file to read the extractor from.

read_feature(feature_file)

Reads the extracted feature from file. In this base class implementation, it uses bob.bio.base_legacy.load() to do that. If you have different format, please overwrite this function.

Parameters:

feature_filestr or bob.io.base.HDF5File

The file open for reading or the name of the file to read from.

Returns:

featureobject (usually numpy.ndarray)

The feature read from file.

train(training_data, extractor_file)

This function can be overwritten to train the feature extractor. If you do this, please also register the function by calling this base class constructor and enabling the training by requires_training = True.

Parameters:

training_data[object] or [[object]]

A list of preprocessed data that can be used for training the extractor. Data will be provided in a single list, if split_training_features_by_client = False was specified in the constructor, otherwise the data will be split into lists, each of which contains the data of a single (training-)client.

extractor_filestr

The file to write. This file should be readable with the load() function.

write_feature(feature, feature_file)

Writes the given extracted feature to a file with the given name. In this base class implementation, we simply use bob.bio.base_legacy.save() for that. If you have a different format, please overwrite this function.

Parameters:

featureobject

The extracted feature, i.e., what is returned from __call__.

feature_filestr or bob.io.base.HDF5File

The file open for writing, or the name of the file to write.

class bob.pad.voice.extractor.Ratios(features_processor, n_bands=5, **kwargs)

Bases: bob.bio.base_legacy.extractor.Extractor

compute_ratios(data)[source]
load(extractor_file)

Loads the parameters required for feature extraction from the extractor file. This function usually is only useful in combination with the train() function. In this base class implementation, it does nothing.

Parameters:

extractor_filestr

The file to read the extractor from.

read_feature(feature_file)

Reads the extracted feature from file. In this base class implementation, it uses bob.bio.base_legacy.load() to do that. If you have different format, please overwrite this function.

Parameters:

feature_filestr or bob.io.base.HDF5File

The file open for reading or the name of the file to read from.

Returns:

featureobject (usually numpy.ndarray)

The feature read from file.

train(training_data, extractor_file)

This function can be overwritten to train the feature extractor. If you do this, please also register the function by calling this base class constructor and enabling the training by requires_training = True.

Parameters:

training_data[object] or [[object]]

A list of preprocessed data that can be used for training the extractor. Data will be provided in a single list, if split_training_features_by_client = False was specified in the constructor, otherwise the data will be split into lists, each of which contains the data of a single (training-)client.

extractor_filestr

The file to write. This file should be readable with the load() function.

write_feature(feature, feature_file)

Writes the given extracted feature to a file with the given name. In this base class implementation, we simply use bob.bio.base_legacy.save() for that. If you have a different format, please overwrite this function.

Parameters:

featureobject

The extracted feature, i.e., what is returned from __call__.

feature_filestr or bob.io.base.HDF5File

The file open for writing, or the name of the file to write.

class bob.pad.voice.extractor.VectorsRatios(features_processor, n_bands=5, feature_vector_length=50, vectors_overlap=5, **kwargs)

Bases: bob.pad.voice.extractor.Ratios

compute_ratios(data)[source]
load(extractor_file)

Loads the parameters required for feature extraction from the extractor file. This function usually is only useful in combination with the train() function. In this base class implementation, it does nothing.

Parameters:

extractor_filestr

The file to read the extractor from.

read_feature(feature_file)

Reads the extracted feature from file. In this base class implementation, it uses bob.bio.base_legacy.load() to do that. If you have different format, please overwrite this function.

Parameters:

feature_filestr or bob.io.base.HDF5File

The file open for reading or the name of the file to read from.

Returns:

featureobject (usually numpy.ndarray)

The feature read from file.

train(training_data, extractor_file)

This function can be overwritten to train the feature extractor. If you do this, please also register the function by calling this base class constructor and enabling the training by requires_training = True.

Parameters:

training_data[object] or [[object]]

A list of preprocessed data that can be used for training the extractor. Data will be provided in a single list, if split_training_features_by_client = False was specified in the constructor, otherwise the data will be split into lists, each of which contains the data of a single (training-)client.

extractor_filestr

The file to write. This file should be readable with the load() function.

write_feature(feature, feature_file)

Writes the given extracted feature to a file with the given name. In this base class implementation, we simply use bob.bio.base_legacy.save() for that. If you have a different format, please overwrite this function.

Parameters:

featureobject

The extracted feature, i.e., what is returned from __call__.

feature_filestr or bob.io.base.HDF5File

The file open for writing, or the name of the file to write.

class bob.pad.voice.extractor.GLCMs(features_processor, n_glcms=1, offset_vector=[[0, 1], [1, 0]], properties=True, **kwargs)

Bases: bob.pad.voice.extractor.Ratios

Extractor that computes histograms of LBP features from a textogram, which, in turn, is computed by a cepstral or spectral extractor passed as an argument.

compute_glcms(data)[source]
compute_ratios(data)
get_features(input_data, annotations)[source]
load(extractor_file)

Loads the parameters required for feature extraction from the extractor file. This function usually is only useful in combination with the train() function. In this base class implementation, it does nothing.

Parameters:

extractor_filestr

The file to read the extractor from.

read_feature(feature_file)

Reads the extracted feature from file. In this base class implementation, it uses bob.bio.base_legacy.load() to do that. If you have different format, please overwrite this function.

Parameters:

feature_filestr or bob.io.base.HDF5File

The file open for reading or the name of the file to read from.

Returns:

featureobject (usually numpy.ndarray)

The feature read from file.

train(training_data, extractor_file)

This function can be overwritten to train the feature extractor. If you do this, please also register the function by calling this base class constructor and enabling the training by requires_training = True.

Parameters:

training_data[object] or [[object]]

A list of preprocessed data that can be used for training the extractor. Data will be provided in a single list, if split_training_features_by_client = False was specified in the constructor, otherwise the data will be split into lists, each of which contains the data of a single (training-)client.

extractor_filestr

The file to write. This file should be readable with the load() function.

write_feature(feature, feature_file)

Writes the given extracted feature to a file with the given name. In this base class implementation, we simply use bob.bio.base_legacy.save() for that. If you have a different format, please overwrite this function.

Parameters:

featureobject

The extracted feature, i.e., what is returned from __call__.

feature_filestr or bob.io.base.HDF5File

The file open for writing, or the name of the file to write.

class bob.pad.voice.extractor.SpectrogramExtended(win_length_ms=20.0, win_shift_ms=10.0, n_filters=40, f_min=0.0, f_max=4000, pre_emphasis_coef=1.0, mel_scale=True, rect_filter=False, inverse_filter=False, normalize_spectrum=False, log_filter=True, energy_filter=False, energy_bands=True, vad_filter='trim_silence', normalize_feature_vector=False, **kwargs)

Bases: bob.bio.base_legacy.extractor.Extractor

Extract energy bands from spectrogram and VAD labels based on the modulation of the energy around 4 Hz

compute_spectrogram(rate, data)[source]
load(extractor_file)

Loads the parameters required for feature extraction from the extractor file. This function usually is only useful in combination with the train() function. In this base class implementation, it does nothing.

Parameters:

extractor_filestr

The file to read the extractor from.

normalize_features(features)[source]
read_feature(feature_file)

Reads the extracted feature from file. In this base class implementation, it uses bob.bio.base_legacy.load() to do that. If you have different format, please overwrite this function.

Parameters:

feature_filestr or bob.io.base.HDF5File

The file open for reading or the name of the file to read from.

Returns:

featureobject (usually numpy.ndarray)

The feature read from file.

train(training_data, extractor_file)

This function can be overwritten to train the feature extractor. If you do this, please also register the function by calling this base class constructor and enabling the training by requires_training = True.

Parameters:

training_data[object] or [[object]]

A list of preprocessed data that can be used for training the extractor. Data will be provided in a single list, if split_training_features_by_client = False was specified in the constructor, otherwise the data will be split into lists, each of which contains the data of a single (training-)client.

extractor_filestr

The file to write. This file should be readable with the load() function.

write_feature(feature, feature_file)

Writes the given extracted feature to a file with the given name. In this base class implementation, we simply use bob.bio.base_legacy.save() for that. If you have a different format, please overwrite this function.

Parameters:

featureobject

The extracted feature, i.e., what is returned from __call__.

feature_filestr or bob.io.base.HDF5File

The file open for writing, or the name of the file to write.

class bob.pad.voice.extractor.LBPHistograms(features_processor, n_lbp_histograms=2, lbp_neighbors=16, lbp_to_average=False, lbp_uniform=False, lbp_radius=1, lbp_circular=True, lbp_elbp_type='regular', histograms_for_rows=False, band_ratios=True, **kwargs)

Bases: bob.pad.voice.extractor.LBPs

Extractor that computes histograms of LBP features from a textogram, which, in turn, is computed by a cepstral or spectral extractor passed as an argument.

compute_histograms(lbp_wrapper, lbpimages)[source]
compute_lbps(data)
compute_ratios(data)
get_features(input_data, annotations)
load(extractor_file)

Loads the parameters required for feature extraction from the extractor file. This function usually is only useful in combination with the train() function. In this base class implementation, it does nothing.

Parameters:

extractor_filestr

The file to read the extractor from.

read_feature(feature_file)

Reads the extracted feature from file. In this base class implementation, it uses bob.bio.base_legacy.load() to do that. If you have different format, please overwrite this function.

Parameters:

feature_filestr or bob.io.base.HDF5File

The file open for reading or the name of the file to read from.

Returns:

featureobject (usually numpy.ndarray)

The feature read from file.

train(training_data, extractor_file)

This function can be overwritten to train the feature extractor. If you do this, please also register the function by calling this base class constructor and enabling the training by requires_training = True.

Parameters:

training_data[object] or [[object]]

A list of preprocessed data that can be used for training the extractor. Data will be provided in a single list, if split_training_features_by_client = False was specified in the constructor, otherwise the data will be split into lists, each of which contains the data of a single (training-)client.

extractor_filestr

The file to write. This file should be readable with the load() function.

write_feature(feature, feature_file)

Writes the given extracted feature to a file with the given name. In this base class implementation, we simply use bob.bio.base_legacy.save() for that. If you have a different format, please overwrite this function.

Parameters:

featureobject

The extracted feature, i.e., what is returned from __call__.

feature_filestr or bob.io.base.HDF5File

The file open for writing, or the name of the file to write.

class bob.pad.voice.extractor.DummyTF(**kwargs)

Bases: bob.bio.spear_legacy.preprocessor.Base, bob.bio.base_legacy.extractor.Extractor

This class can be used as a simple preprocessor (reads data only) and a dummy extractor (reads saved data)

load(extractor_file)

Loads the parameters required for feature extraction from the extractor file. This function usually is only useful in combination with the train() function. In this base class implementation, it does nothing.

Parameters:

extractor_filestr

The file to read the extractor from.

read_data(data_file) → data

Reads the preprocessed data from file. In this base class implementation, it uses bob.bio.base_legacy.load() to do that. If you have different format, please overwrite this function.

Parameters:

data_filestr or bob.io.base.HDF5File

The file open for reading or the name of the file to read from.

Returns:

dataobject (usually numpy.ndarray)

The preprocessed data read from file.

read_feature(feature_file)

Reads the extracted feature from file. In this base class implementation, it uses bob.bio.base_legacy.load() to do that. If you have different format, please overwrite this function.

Parameters:

feature_filestr or bob.io.base.HDF5File

The file open for reading or the name of the file to read from.

Returns:

featureobject (usually numpy.ndarray)

The feature read from file.

train(training_data, extractor_file)

This function can be overwritten to train the feature extractor. If you do this, please also register the function by calling this base class constructor and enabling the training by requires_training = True.

Parameters:

training_data[object] or [[object]]

A list of preprocessed data that can be used for training the extractor. Data will be provided in a single list, if split_training_features_by_client = False was specified in the constructor, otherwise the data will be split into lists, each of which contains the data of a single (training-)client.

extractor_filestr

The file to write. This file should be readable with the load() function.

write_data(data, data_file, compression=0)

Writes the given preprocessed data to a file with the given name.

write_feature(feature, feature_file)

Writes the given extracted feature to a file with the given name. In this base class implementation, we simply use bob.bio.base_legacy.save() for that. If you have a different format, please overwrite this function.

Parameters:

featureobject

The extracted feature, i.e., what is returned from __call__.

feature_filestr or bob.io.base.HDF5File

The file open for writing, or the name of the file to write.

class bob.pad.voice.extractor.AudioTFExtractor(feature_layer='fc1', **kwargs)

Bases: bob.bio.base_legacy.extractor.Extractor

Parameters:

feature_layer: The layer to be used as features. Possible values are fc1 or ‘fc2’.

load(extractor_file)[source]

Loads the parameters required for feature extraction from the extractor file. This function usually is only useful in combination with the train() function. In this base class implementation, it does nothing.

Parameters:

extractor_filestr

The file to read the extractor from.

read_feature(feature_file)

Reads the extracted feature from file. In this base class implementation, it uses bob.bio.base_legacy.load() to do that. If you have different format, please overwrite this function.

Parameters:

feature_filestr or bob.io.base.HDF5File

The file open for reading or the name of the file to read from.

Returns:

featureobject (usually numpy.ndarray)

The feature read from file.

train(**kwargs)[source]

This function can be overwritten to train the feature extractor. If you do this, please also register the function by calling this base class constructor and enabling the training by requires_training = True.

Parameters:

training_data[object] or [[object]]

A list of preprocessed data that can be used for training the extractor. Data will be provided in a single list, if split_training_features_by_client = False was specified in the constructor, otherwise the data will be split into lists, each of which contains the data of a single (training-)client.

extractor_filestr

The file to write. This file should be readable with the load() function.

write_feature(feature, feature_file)

Writes the given extracted feature to a file with the given name. In this base class implementation, we simply use bob.bio.base_legacy.save() for that. If you have a different format, please overwrite this function.

Parameters:

featureobject

The extracted feature, i.e., what is returned from __call__.

feature_filestr or bob.io.base.HDF5File

The file open for writing, or the name of the file to write.

Algorithms

class bob.pad.voice.algorithm.GMM(normalize_features=False, number_of_gaussians=512, kmeans_training_iterations=25, gmm_training_iterations=10, training_threshold=0.0005, variance_threshold=0.0005, update_weights=True, update_means=True, update_variances=True, responsibility_threshold=0, INIT_SEED=2015, requires_projector_training=False, **kwargs)

Bases: bob.pad.base.algorithm.Algorithm

Trains Logistical Regression classifier and projects testing dat on it.

load_projector(projector_file)[source]

Loads the parameters required for feature projection from file. This function usually is useful in combination with the train_projector() function. In this base class implementation, it does nothing.

Please register performs_projection = True in the constructor to enable this function.

Parameters:

projector_filestr

The file to read the projector from.

project(feature) → projected[source]

Projects the given feature into GMM space.

Parameters:

feature1D numpy.ndarray

The 1D feature to be projected.

Returns:

projected1D numpy.ndarray

The feature projected into GMM space.

project_feature(feature)[source]
read_feature(feature_file) → feature

Reads the projected feature from file. In this base class implementation, it uses bob.io.base.load() to do that. If you have different format, please overwrite this function.

Please register performs_projection = True in the constructor to enable this function.

Parameters:

feature_filestr or bob.io.base.HDF5File

The file open for reading, or the file name to read from.

Returns:

featureobject

The feature that was read from file.

read_gmm_stats(gmm_stats_file)[source]

Reads GMM stats from file.

save_gmms(projector_file)[source]

Save projector to file

score(toscore)[source]

Returns the difference between log likelihoods of being real or attack

score_for_multiple_projections(toscore)[source]

Returns the difference between log likelihoods of being real or attack

train_gmm(array)[source]
train_projector(training_features, projector_file)[source]

This function can be overwritten to train the feature projector. If you do this, please also register the function by calling this base class constructor and enabling the training by requires_projector_training = True.

Parameters:

training_features[object] or [[object]]

A list of extracted features that can be used for training the projector. Features will be provided in a single list

projector_filestr

The file to write. This file should be readable with the load_projector() function.

write_feature(feature, feature_file)

Saves the given projected feature to a file with the given name. In this base class implementation:

  • If the given feature has a save attribute, it calls feature.save(bob.io.base.HDF5File(feature_file), 'w'). In this case, the given feature_file might be either a file name or a bob.io.base.HDF5File.

  • Otherwise, it uses bob.io.base.save() to do that.

If you have a different format, please overwrite this function.

Please register ‘performs_projection = True’ in the constructor to enable this function.

Parameters:

featureobject

A feature as returned by the project() function, which should be written.

feature_filestr or bob.io.base.HDF5File

The file open for writing, or the file name to write to.

class bob.pad.voice.algorithm.LogRegr(use_PCA_training=False, normalize_features=False, **kwargs)

Bases: bob.pad.base.algorithm.Algorithm

Trains Logistical Regression classifier and projects testing dat on it.

enroll(enroll_features)[source]

We do no enrollment here

load_projector(projector_file)[source]

Loads the parameters required for feature projection from file. This function usually is useful in combination with the train_projector() function. In this base class implementation, it does nothing.

Please register performs_projection = True in the constructor to enable this function.

Parameters:

projector_filestr

The file to read the projector from.

project(feature) → projected[source]

Projects the given feature into Fisher space.

Parameters:

feature1D numpy.ndarray

The 1D feature to be projected.

Returns:

projected1D numpy.ndarray

The feature projected into Fisher space.

project_feature(feature)[source]
read_feature(feature_file) → feature

Reads the projected feature from file. In this base class implementation, it uses bob.io.base.load() to do that. If you have different format, please overwrite this function.

Please register performs_projection = True in the constructor to enable this function.

Parameters:

feature_filestr or bob.io.base.HDF5File

The file open for reading, or the file name to read from.

Returns:

featureobject

The feature that was read from file.

score(toscore)[source]

Returns the output of a classifier

score_for_multiple_projections(toscore)[source]

scorescore_for_multiple_projections(toscore) -> score

This function will compute the score for a list of objects in toscore. It must be overwritten by derived classes.

Parameters:

toscore[object]

A list of objects to compute the score for.

Returns:

scorefloat

A score value for the object toscore.

train_projector(training_features, projector_file)[source]

This function can be overwritten to train the feature projector. If you do this, please also register the function by calling this base class constructor and enabling the training by requires_projector_training = True.

Parameters:

training_features[object] or [[object]]

A list of extracted features that can be used for training the projector. Features will be provided in a single list

projector_filestr

The file to write. This file should be readable with the load_projector() function.

write_feature(feature, feature_file)

Saves the given projected feature to a file with the given name. In this base class implementation:

  • If the given feature has a save attribute, it calls feature.save(bob.io.base.HDF5File(feature_file), 'w'). In this case, the given feature_file might be either a file name or a bob.io.base.HDF5File.

  • Otherwise, it uses bob.io.base.save() to do that.

If you have a different format, please overwrite this function.

Please register ‘performs_projection = True’ in the constructor to enable this function.

Parameters:

featureobject

A feature as returned by the project() function, which should be written.

feature_filestr or bob.io.base.HDF5File

The file open for writing, or the file name to write to.

class bob.pad.voice.algorithm.TensorflowEval(architecture_name='mlp', input_shape=[200, 81], network_size=60, normalization_file=None, **kwargs)

Bases: bob.pad.base.algorithm.Algorithm

This class is for evaluating data stored in tensorflow tfrecord format using a pre-trained LSTM model.

load_projector(projector_file)[source]

Loads the parameters required for feature projection from file. This function usually is useful in combination with the train_projector() function. In this base class implementation, it does nothing.

Please register performs_projection = True in the constructor to enable this function.

Parameters:

projector_filestr

The file to read the projector from.

normalize_data(features)[source]
project(feature) → projected[source]

This function will project the given feature. It is assured that the load_projector() was called once before the project function is executed.

Parameters:

featureobject

The feature to be projected.

Returns:

projectedobject

The projected features. Must be writable with the write_feature() function and readable with the read_feature() function.

project_feature(feature)[source]
read_feature(feature_file) → feature

Reads the projected feature from file. In this base class implementation, it uses bob.io.base.load() to do that. If you have different format, please overwrite this function.

Please register performs_projection = True in the constructor to enable this function.

Parameters:

feature_filestr or bob.io.base.HDF5File

The file open for reading, or the file name to read from.

Returns:

featureobject

The feature that was read from file.

restore_trained_model(projector_file)[source]
score(toscore)[source]

Returns the evarage value of the probe

score_for_multiple_projections(toscore)[source]

scorescore_for_multiple_projections(toscore) -> score

Returns:

scorefloat

A score value for the object toscore.

train_projector(training_features, projector_file)

This function can be overwritten to train the feature projector. If you do this, please also register the function by calling this base class constructor and enabling the training by requires_projector_training = True.

Parameters:

training_features[object] or [[object]]

A list of extracted features that can be used for training the projector. Features will be provided in a single list

projector_filestr

The file to write. This file should be readable with the load_projector() function.

write_feature(feature, feature_file)

Saves the given projected feature to a file with the given name. In this base class implementation:

  • If the given feature has a save attribute, it calls feature.save(bob.io.base.HDF5File(feature_file), 'w'). In this case, the given feature_file might be either a file name or a bob.io.base.HDF5File.

  • Otherwise, it uses bob.io.base.save() to do that.

If you have a different format, please overwrite this function.

Please register ‘performs_projection = True’ in the constructor to enable this function.

Parameters:

featureobject

A feature as returned by the project() function, which should be written.

feature_filestr or bob.io.base.HDF5File

The file open for writing, or the file name to write to.

Databases

class bob.pad.voice.database.PadVoiceFile(client_id, path, attack_type=None, file_id=None)

Bases: bob.pad.base.database.PadFile

A simple base class that defines basic properties of File object for the use in PAD experiments

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

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

Parameters
  • directory (str, optional) – If not empty or None, this directory is prefixed to the final file destination

  • extension (str, optional) – If not empty or None, this extension is suffixed to the final file destination

Returns

The loaded data (normally numpy.ndarray).

Return type

object

make_path(directory=None, extension=None)

Wraps the current path so that a complete path is formed

Parameters
  • directory (str, optional) – An optional directory name that will be prefixed to the returned result.

  • extension (str, optional) – An optional extension that will be suffixed to the returned filename. The extension normally includes the leading . character as in .jpg or .hdf5.

Returns

Returns a string containing the newly generated file path.

Return type

str

save(data, directory=None, extension='.hdf5', create_directories=True)

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

Parameters
  • data (object) – The data blob to be saved (normally a numpy.ndarray).

  • directory (str, optional) – If not empty or None, this directory is prefixed to the final file destination

  • extension (str, optional) – The extension of the filename - this will control the type of output and the codec for saving the input blob.

  • create_directories (bool, optional) – Whether to create the required directories to save the data.

bob.pad.voice.database.VoicePadFile

alias of bob.pad.voice.database.PadVoiceFile

class bob.pad.voice.database.ASVspoofPadDatabase(protocol='CM', **kwargs)

Bases: bob.pad.base.database.PadDatabase

Implements verification API for querying ASVspoof database.

all_files(groups=('train', 'dev', 'eval'), flat=False)

Returns all files of the database, respecting the current protocol. The files can be limited using the all_files_options in the constructor.

Parameters
  • groups (str or tuple or None) – The groups to get the data for. it should be some of ('train', 'dev', 'eval') or None

  • flat (bool) – if True, it will merge the real and attack files into one list.

Returns

files – The sorted and unique list of all files of the database.

Return type

[bob.pad.base.database.PadFile]

abstract annotations(file)

Returns the annotations for the given File object, if available. You need to override this method in your high-level implementation. If your database does not have annotations, it should return None.

Parameters:

filebob.pad.base.database.PadFile

The file for which annotations should be returned.

Returns:

annotsdict or None

The annotations for the file, if available.

arrange_by_client(files) → files_by_client

Arranges the given list of files by client id. This function returns a list of lists of File’s.

Parameters:

filesbob.bio.base_legacy.database.BioFile

A list of files that should be split up by BioFile.client_id.

Returns:

files_by_client[[bob.bio.base_legacy.database.BioFile]]

The list of lists of files, where each sub-list groups the files with the same BioFile.client_id

check_parameter_for_validity(parameter, parameter_description, valid_parameters, default_parameter=None)
check_parameters_for_validity(parameters, parameter_description, valid_parameters, default_parameters=None)
client_id_from_model_id(model_id, group='dev')

Return the client id associated with the given model id. In this base class implementation, it is assumed that only one model is enrolled for each client and, thus, client id and model id are identical. All key word arguments are ignored. Please override this function in derived class implementations to change this behavior.

convert_names_to_highlevel(names, low_level_names, high_level_names)
convert_names_to_lowlevel(names, low_level_names, high_level_names)
enroll_files(model_id, group = 'dev') → files

Returns a list of File objects that should be used to enroll the model with the given model id from the given group, respecting the current protocol. If the model_id is None (the default), enrollment files for all models are returned.

Parameters:

model_idint or str

A unique ID that identifies the model.

groupone of ('dev', 'eval')

The group to get the enrollment files for.

Returns:

files[bob.bio.base_legacy.database.BioFile]

The list of files used for to enroll the model with the given model id.

file_names(files, directory, extension) → paths

Returns the full path of the given File objects.

Parameters:

files[bob.bio.base_legacy.database.BioFile]

The list of file object to retrieve the file names for.

directorystr

The base directory, where the files can be found.

extensionstr

The file name extension to add to all files.

Returns:

paths[str] or [[str]]

The paths extracted for the files, in the same order. If this database provides file sets, a list of lists of file names is returned, one sub-list for each file set.

groups(protocol=None)

Returns the names of all registered groups in the database

Keyword parameters:

protocol: str

The protocol for which the groups should be retrieved. If you do not have protocols defined, just ignore this field.

model_ids(group = 'dev') → ids

Returns a list of model ids for the given group, respecting the current protocol.

Parameters:

groupone of ('dev', 'eval')

The group to get the model ids for.

Returns:

ids[int] or [str]

The list of (unique) model ids for models of the given group.

model_ids_with_protocol(groups = None, protocol = None, **kwargs) → ids

Client-based PAD is not implemented.

object_sets(groups=None, protocol=None, purposes=None, model_ids=None, **kwargs)

This function returns lists of FileSet objects, which fulfill the given restrictions.

Keyword parameters:

groupsstr or [str]

The groups of which the clients should be returned. Usually, groups are one or more elements of (‘world’, ‘dev’, ‘eval’)

protocol

The protocol for which the clients should be retrieved. The protocol is dependent on your database. If you do not have protocols defined, just ignore this field.

purposesstr or [str]

The purposes for which File objects should be retrieved. Usually, purposes are one of (‘enroll’, ‘probe’).

model_ids[various type]

The model ids for which the File objects should be retrieved. What defines a ‘model id’ is dependent on the database. In cases, where there is only one model per client, model ids and client ids are identical. In cases, where there is one model per file, model ids and file ids are identical. But, there might also be other cases.

objects(groups=None, protocol=None, purposes=None, model_ids=None, **kwargs)[source]

Returns a set of Files for the specific query by the user.

Keyword Parameters:

groups

One of the groups (‘dev’, ‘eval’, ‘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.

protocol

The protocol for which the clients should be retrieved. The protocol is dependent on your database. If you do not have protocols defined, just ignore this field.

purposes

The purposes can be either ‘real’ or ‘attack’.

model_ids

This parameter is not supported in this implementation.

Returns: A set of Files with the specified properties.

original_file_name(file)

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

Parameters

filebob.db.base.File or a derivative The File objects for which the file name should be retrieved

Returns

The original file name for the given bob.db.base.File object.

Return type

str

Raises

ValueError – if the file is not found.

original_file_names(files) → paths

Returns the full paths of the real and attack data of the given PadFile objects.

Parameters:

files[[bob.pad.base.database.PadFile], [bob.pad.base.database.PadFile]

The list of lists ([real, attack]) of file object to retrieve the original data file names for.

Returns:

paths[str] or [[str]]

The paths extracted for the concatenated real+attack files, in the preserved order.

probe_file_sets(model_id = None, group = 'dev') → files

Returns a list of probe FileSet objects, respecting the current protocol. If a model_id is specified, only the probe files that should be compared with the given model id are returned (for most databases, these are all probe files of the given group). Otherwise, all probe files of the given group are returned.

Parameters:

model_idint or str or None

A unique ID that identifies the model.

groupone of ('dev', 'eval')

The group to get the enrollment files for.

Returns:

files[bob.bio.base_legacy.database.BioFileSet] or something similar

The list of file sets used to probe the model with the given model id.

probe_files(model_id = None, group = 'dev') → files

Returns a list of probe File objects, respecting the current protocol. If a model_id is specified, only the probe files that should be compared with the given model id are returned (for most databases, these are all probe files of the given group). Otherwise, all probe files of the given group are returned.

Parameters:

model_idint or str or None

A unique ID that identifies the model.

groupone of ('dev', 'eval')

The group to get the enrollment files for.

Returns:

files[bob.bio.base_legacy.database.BioFile]

The list of files used for to probe the model with the given model id.

replace_directories(replacements=None)

This helper function replaces the original_directory and the annotation_directory of the database with the directories read from the given replacement file.

This function is provided for convenience, so that the database configuration files do not need to be modified. Instead, this function uses the given dictionary of replacements to change the original directory and the original extension (if given).

The given replacements can be of type dict, including all replacements, or a file name (as a str), in which case the file is read. The structure of the file should be:

# Comments starting with # and empty lines are ignored

[YOUR_..._DATA_DIRECTORY] = /path/to/your/data
[YOUR_..._ANNOTATION_DIRECTORY] = /path/to/your/annotations

If no annotation files are available (e.g. when they are stored inside the database), the annotation directory can be left out.

Parameters:

replacementsdict or str

A dictionary with replacements, or a name of a file to read the dictionary from. If the file name does not exist, no directories are replaced.

sort(files)
test_files(groups = ['dev']) → files

Returns all test files (i.e., files used for enrollment and probing) for the given groups, respecting the current protocol. The files for the steps can be limited using the all_files_options defined in the constructor.

Parameters:

groupssome of ('dev', 'eval')

The groups to get the data for.

Returns:

files[bob.bio.base_legacy.database.BioFile]

The sorted and unique list of test files of the database.

training_files(step = None, arrange_by_client = False) → files

Returns all training File objects This function needs to be implemented in derived class implementations.

Parameters:

The parameters are not applicable in this version of anti-spoofing experiments

Returns:

files[bob.pad.base.database.PadFile] or [[bob.pad.base.database.PadFile]]

The (arranged) list of files used for the training.

uses_probe_file_sets(protocol=None)

Defines if, for the current protocol, the database uses several probe files to generate a score. 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.

class bob.pad.voice.database.ASVspoof2017PadDatabase(protocol='competition', **kwargs)

Bases: bob.pad.base.database.PadDatabase

Implements verification API for querying ASVspoof2017 database.

all_files(groups=('train', 'dev', 'eval'), flat=False)

Returns all files of the database, respecting the current protocol. The files can be limited using the all_files_options in the constructor.

Parameters
  • groups (str or tuple or None) – The groups to get the data for. it should be some of ('train', 'dev', 'eval') or None

  • flat (bool) – if True, it will merge the real and attack files into one list.

Returns

files – The sorted and unique list of all files of the database.

Return type

[bob.pad.base.database.PadFile]

abstract annotations(file)

Returns the annotations for the given File object, if available. You need to override this method in your high-level implementation. If your database does not have annotations, it should return None.

Parameters:

filebob.pad.base.database.PadFile

The file for which annotations should be returned.

Returns:

annotsdict or None

The annotations for the file, if available.

arrange_by_client(files) → files_by_client

Arranges the given list of files by client id. This function returns a list of lists of File’s.

Parameters:

filesbob.bio.base_legacy.database.BioFile

A list of files that should be split up by BioFile.client_id.

Returns:

files_by_client[[bob.bio.base_legacy.database.BioFile]]

The list of lists of files, where each sub-list groups the files with the same BioFile.client_id

check_parameter_for_validity(parameter, parameter_description, valid_parameters, default_parameter=None)
check_parameters_for_validity(parameters, parameter_description, valid_parameters, default_parameters=None)
client_id_from_model_id(model_id, group='dev')

Return the client id associated with the given model id. In this base class implementation, it is assumed that only one model is enrolled for each client and, thus, client id and model id are identical. All key word arguments are ignored. Please override this function in derived class implementations to change this behavior.

convert_names_to_highlevel(names, low_level_names, high_level_names)
convert_names_to_lowlevel(names, low_level_names, high_level_names)
convert_purposes(names, low_level_names, high_level_names)[source]

Converts purposes names from a low level to high level API

enroll_files(model_id, group = 'dev') → files

Returns a list of File objects that should be used to enroll the model with the given model id from the given group, respecting the current protocol. If the model_id is None (the default), enrollment files for all models are returned.

Parameters:

model_idint or str

A unique ID that identifies the model.

groupone of ('dev', 'eval')

The group to get the enrollment files for.

Returns:

files[bob.bio.base_legacy.database.BioFile]

The list of files used for to enroll the model with the given model id.

file_names(files, directory, extension) → paths

Returns the full path of the given File objects.

Parameters:

files[bob.bio.base_legacy.database.BioFile]

The list of file object to retrieve the file names for.

directorystr

The base directory, where the files can be found.

extensionstr

The file name extension to add to all files.

Returns:

paths[str] or [[str]]

The paths extracted for the files, in the same order. If this database provides file sets, a list of lists of file names is returned, one sub-list for each file set.

groups(protocol=None)

Returns the names of all registered groups in the database

Keyword parameters:

protocol: str

The protocol for which the groups should be retrieved. If you do not have protocols defined, just ignore this field.

model_ids(group = 'dev') → ids

Returns a list of model ids for the given group, respecting the current protocol.

Parameters:

groupone of ('dev', 'eval')

The group to get the model ids for.

Returns:

ids[int] or [str]

The list of (unique) model ids for models of the given group.

model_ids_with_protocol(groups = None, protocol = None, **kwargs) → ids

Client-based PAD is not implemented.

object_sets(groups=None, protocol=None, purposes=None, model_ids=None, **kwargs)

This function returns lists of FileSet objects, which fulfill the given restrictions.

Keyword parameters:

groupsstr or [str]

The groups of which the clients should be returned. Usually, groups are one or more elements of (‘world’, ‘dev’, ‘eval’)

protocol

The protocol for which the clients should be retrieved. The protocol is dependent on your database. If you do not have protocols defined, just ignore this field.

purposesstr or [str]

The purposes for which File objects should be retrieved. Usually, purposes are one of (‘enroll’, ‘probe’).

model_ids[various type]

The model ids for which the File objects should be retrieved. What defines a ‘model id’ is dependent on the database. In cases, where there is only one model per client, model ids and client ids are identical. In cases, where there is one model per file, model ids and file ids are identical. But, there might also be other cases.

objects(groups=None, protocol=None, purposes=None, model_ids=None, **kwargs)[source]

Returns a set of Files for the specific query by the user.

Keyword Parameters:

groups

One of the groups (‘dev’, ‘eval’, ‘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.

protocol

The protocol for which the clients should be retrieved. The protocol is dependent on your database. If you do not have protocols defined, just ignore this field.

purposes

The purposes can be either ‘real’ or ‘attack’.

model_ids

This parameter is not supported in this implementation.

Returns: A set of Files with the specified properties.

original_file_name(file)

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

Parameters

filebob.db.base.File or a derivative The File objects for which the file name should be retrieved

Returns

The original file name for the given bob.db.base.File object.

Return type

str

Raises

ValueError – if the file is not found.

original_file_names(files) → paths

Returns the full paths of the real and attack data of the given PadFile objects.

Parameters:

files[[bob.pad.base.database.PadFile], [bob.pad.base.database.PadFile]

The list of lists ([real, attack]) of file object to retrieve the original data file names for.

Returns:

paths[str] or [[str]]

The paths extracted for the concatenated real+attack files, in the preserved order.

probe_file_sets(model_id = None, group = 'dev') → files

Returns a list of probe FileSet objects, respecting the current protocol. If a model_id is specified, only the probe files that should be compared with the given model id are returned (for most databases, these are all probe files of the given group). Otherwise, all probe files of the given group are returned.

Parameters:

model_idint or str or None

A unique ID that identifies the model.

groupone of ('dev', 'eval')

The group to get the enrollment files for.

Returns:

files[bob.bio.base_legacy.database.BioFileSet] or something similar

The list of file sets used to probe the model with the given model id.

probe_files(model_id = None, group = 'dev') → files

Returns a list of probe File objects, respecting the current protocol. If a model_id is specified, only the probe files that should be compared with the given model id are returned (for most databases, these are all probe files of the given group). Otherwise, all probe files of the given group are returned.

Parameters:

model_idint or str or None

A unique ID that identifies the model.

groupone of ('dev', 'eval')

The group to get the enrollment files for.

Returns:

files[bob.bio.base_legacy.database.BioFile]

The list of files used for to probe the model with the given model id.

replace_directories(replacements=None)

This helper function replaces the original_directory and the annotation_directory of the database with the directories read from the given replacement file.

This function is provided for convenience, so that the database configuration files do not need to be modified. Instead, this function uses the given dictionary of replacements to change the original directory and the original extension (if given).

The given replacements can be of type dict, including all replacements, or a file name (as a str), in which case the file is read. The structure of the file should be:

# Comments starting with # and empty lines are ignored

[YOUR_..._DATA_DIRECTORY] = /path/to/your/data
[YOUR_..._ANNOTATION_DIRECTORY] = /path/to/your/annotations

If no annotation files are available (e.g. when they are stored inside the database), the annotation directory can be left out.

Parameters:

replacementsdict or str

A dictionary with replacements, or a name of a file to read the dictionary from. If the file name does not exist, no directories are replaced.

sort(files)
test_files(groups = ['dev']) → files

Returns all test files (i.e., files used for enrollment and probing) for the given groups, respecting the current protocol. The files for the steps can be limited using the all_files_options defined in the constructor.

Parameters:

groupssome of ('dev', 'eval')

The groups to get the data for.

Returns:

files[bob.bio.base_legacy.database.BioFile]

The sorted and unique list of test files of the database.

training_files(step = None, arrange_by_client = False) → files

Returns all training File objects This function needs to be implemented in derived class implementations.

Parameters:

The parameters are not applicable in this version of anti-spoofing experiments

Returns:

files[bob.pad.base.database.PadFile] or [[bob.pad.base.database.PadFile]]

The (arranged) list of files used for the training.

uses_probe_file_sets(protocol=None)

Defines if, for the current protocol, the database uses several probe files to generate a score. 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.

class bob.pad.voice.database.AVspoofPadDatabase(protocol='grandtest', **kwargs)

Bases: bob.pad.base.database.PadDatabase

Implements verification API for querying AVspoof database.

all_files(groups=('train', 'dev', 'eval'), flat=False)

Returns all files of the database, respecting the current protocol. The files can be limited using the all_files_options in the constructor.

Parameters
  • groups (str or tuple or None) – The groups to get the data for. it should be some of ('train', 'dev', 'eval') or None

  • flat (bool) – if True, it will merge the real and attack files into one list.

Returns

files – The sorted and unique list of all files of the database.

Return type

[bob.pad.base.database.PadFile]

annotations(file)[source]

Returns the annotations for the given File object, if available. You need to override this method in your high-level implementation. If your database does not have annotations, it should return None.

Parameters:

filebob.pad.base.database.PadFile

The file for which annotations should be returned.

Returns:

annotsdict or None

The annotations for the file, if available.

arrange_by_client(files) → files_by_client

Arranges the given list of files by client id. This function returns a list of lists of File’s.

Parameters:

filesbob.bio.base_legacy.database.BioFile

A list of files that should be split up by BioFile.client_id.

Returns:

files_by_client[[bob.bio.base_legacy.database.BioFile]]

The list of lists of files, where each sub-list groups the files with the same BioFile.client_id

check_parameter_for_validity(parameter, parameter_description, valid_parameters, default_parameter=None)
check_parameters_for_validity(parameters, parameter_description, valid_parameters, default_parameters=None)
client_id_from_model_id(model_id, group='dev')

Return the client id associated with the given model id. In this base class implementation, it is assumed that only one model is enrolled for each client and, thus, client id and model id are identical. All key word arguments are ignored. Please override this function in derived class implementations to change this behavior.

convert_names_to_highlevel(names, low_level_names, high_level_names)
convert_names_to_lowlevel(names, low_level_names, high_level_names)
enroll_files(model_id, group = 'dev') → files

Returns a list of File objects that should be used to enroll the model with the given model id from the given group, respecting the current protocol. If the model_id is None (the default), enrollment files for all models are returned.

Parameters:

model_idint or str

A unique ID that identifies the model.

groupone of ('dev', 'eval')

The group to get the enrollment files for.

Returns:

files[bob.bio.base_legacy.database.BioFile]

The list of files used for to enroll the model with the given model id.

file_names(files, directory, extension) → paths

Returns the full path of the given File objects.

Parameters:

files[bob.bio.base_legacy.database.BioFile]

The list of file object to retrieve the file names for.

directorystr

The base directory, where the files can be found.

extensionstr

The file name extension to add to all files.

Returns:

paths[str] or [[str]]

The paths extracted for the files, in the same order. If this database provides file sets, a list of lists of file names is returned, one sub-list for each file set.

groups(protocol=None)

Returns the names of all registered groups in the database

Keyword parameters:

protocol: str

The protocol for which the groups should be retrieved. If you do not have protocols defined, just ignore this field.

model_ids(group = 'dev') → ids

Returns a list of model ids for the given group, respecting the current protocol.

Parameters:

groupone of ('dev', 'eval')

The group to get the model ids for.

Returns:

ids[int] or [str]

The list of (unique) model ids for models of the given group.

model_ids_with_protocol(groups = None, protocol = None, **kwargs) → ids

Client-based PAD is not implemented.

object_sets(groups=None, protocol=None, purposes=None, model_ids=None, **kwargs)

This function returns lists of FileSet objects, which fulfill the given restrictions.

Keyword parameters:

groupsstr or [str]

The groups of which the clients should be returned. Usually, groups are one or more elements of (‘world’, ‘dev’, ‘eval’)

protocol

The protocol for which the clients should be retrieved. The protocol is dependent on your database. If you do not have protocols defined, just ignore this field.

purposesstr or [str]

The purposes for which File objects should be retrieved. Usually, purposes are one of (‘enroll’, ‘probe’).

model_ids[various type]

The model ids for which the File objects should be retrieved. What defines a ‘model id’ is dependent on the database. In cases, where there is only one model per client, model ids and client ids are identical. In cases, where there is one model per file, model ids and file ids are identical. But, there might also be other cases.

objects(groups=None, protocol=None, purposes=None, model_ids=None, **kwargs)[source]

Returns a set of Files for the specific query by the user.

Keyword Parameters:

groups

One of the groups (‘dev’, ‘eval’, ‘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.

protocol

The protocol for which the clients should be retrieved. The protocol is dependent on your database. If you do not have protocols defined, just ignore this field.

purposes

The purposes can be either ‘real’ or ‘attack’.

model_ids

This parameter is not supported in this implementation.

Returns: A set of Files with the specified properties.

original_file_name(file)

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

Parameters

filebob.db.base.File or a derivative The File objects for which the file name should be retrieved

Returns

The original file name for the given bob.db.base.File object.

Return type

str

Raises

ValueError – if the file is not found.

original_file_names(files) → paths

Returns the full paths of the real and attack data of the given PadFile objects.

Parameters:

files[[bob.pad.base.database.PadFile], [bob.pad.base.database.PadFile]

The list of lists ([real, attack]) of file object to retrieve the original data file names for.

Returns:

paths[str] or [[str]]

The paths extracted for the concatenated real+attack files, in the preserved order.

probe_file_sets(model_id = None, group = 'dev') → files

Returns a list of probe FileSet objects, respecting the current protocol. If a model_id is specified, only the probe files that should be compared with the given model id are returned (for most databases, these are all probe files of the given group). Otherwise, all probe files of the given group are returned.

Parameters:

model_idint or str or None

A unique ID that identifies the model.

groupone of ('dev', 'eval')

The group to get the enrollment files for.

Returns:

files[bob.bio.base_legacy.database.BioFileSet] or something similar

The list of file sets used to probe the model with the given model id.

probe_files(model_id = None, group = 'dev') → files

Returns a list of probe File objects, respecting the current protocol. If a model_id is specified, only the probe files that should be compared with the given model id are returned (for most databases, these are all probe files of the given group). Otherwise, all probe files of the given group are returned.

Parameters:

model_idint or str or None

A unique ID that identifies the model.

groupone of ('dev', 'eval')

The group to get the enrollment files for.

Returns:

files[bob.bio.base_legacy.database.BioFile]

The list of files used for to probe the model with the given model id.

replace_directories(replacements=None)

This helper function replaces the original_directory and the annotation_directory of the database with the directories read from the given replacement file.

This function is provided for convenience, so that the database configuration files do not need to be modified. Instead, this function uses the given dictionary of replacements to change the original directory and the original extension (if given).

The given replacements can be of type dict, including all replacements, or a file name (as a str), in which case the file is read. The structure of the file should be:

# Comments starting with # and empty lines are ignored

[YOUR_..._DATA_DIRECTORY] = /path/to/your/data
[YOUR_..._ANNOTATION_DIRECTORY] = /path/to/your/annotations

If no annotation files are available (e.g. when they are stored inside the database), the annotation directory can be left out.

Parameters:

replacementsdict or str

A dictionary with replacements, or a name of a file to read the dictionary from. If the file name does not exist, no directories are replaced.

sort(files)
test_files(groups = ['dev']) → files

Returns all test files (i.e., files used for enrollment and probing) for the given groups, respecting the current protocol. The files for the steps can be limited using the all_files_options defined in the constructor.

Parameters:

groupssome of ('dev', 'eval')

The groups to get the data for.

Returns:

files[bob.bio.base_legacy.database.BioFile]

The sorted and unique list of test files of the database.

training_files(step = None, arrange_by_client = False) → files

Returns all training File objects This function needs to be implemented in derived class implementations.

Parameters:

The parameters are not applicable in this version of anti-spoofing experiments

Returns:

files[bob.pad.base.database.PadFile] or [[bob.pad.base.database.PadFile]]

The (arranged) list of files used for the training.

uses_probe_file_sets(protocol=None)

Defines if, for the current protocol, the database uses several probe files to generate a score. 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.

class bob.pad.voice.database.VoicePAPadDatabase(protocol='grandtest', **kwargs)

Bases: bob.pad.base.database.PadDatabase

Implements verification API for querying voicePA database.

all_files(groups=('train', 'dev', 'eval'), flat=False)

Returns all files of the database, respecting the current protocol. The files can be limited using the all_files_options in the constructor.

Parameters
  • groups (str or tuple or None) – The groups to get the data for. it should be some of ('train', 'dev', 'eval') or None

  • flat (bool) – if True, it will merge the real and attack files into one list.

Returns

files – The sorted and unique list of all files of the database.

Return type

[bob.pad.base.database.PadFile]

abstract annotations(file)

Returns the annotations for the given File object, if available. You need to override this method in your high-level implementation. If your database does not have annotations, it should return None.

Parameters:

filebob.pad.base.database.PadFile

The file for which annotations should be returned.

Returns:

annotsdict or None

The annotations for the file, if available.

arrange_by_client(files) → files_by_client

Arranges the given list of files by client id. This function returns a list of lists of File’s.

Parameters:

filesbob.bio.base_legacy.database.BioFile

A list of files that should be split up by BioFile.client_id.

Returns:

files_by_client[[bob.bio.base_legacy.database.BioFile]]

The list of lists of files, where each sub-list groups the files with the same BioFile.client_id

check_parameter_for_validity(parameter, parameter_description, valid_parameters, default_parameter=None)
check_parameters_for_validity(parameters, parameter_description, valid_parameters, default_parameters=None)
client_id_from_model_id(model_id, group='dev')

Return the client id associated with the given model id. In this base class implementation, it is assumed that only one model is enrolled for each client and, thus, client id and model id are identical. All key word arguments are ignored. Please override this function in derived class implementations to change this behavior.

convert_names_to_highlevel(names, low_level_names, high_level_names)
convert_names_to_lowlevel(names, low_level_names, high_level_names)
enroll_files(model_id, group = 'dev') → files

Returns a list of File objects that should be used to enroll the model with the given model id from the given group, respecting the current protocol. If the model_id is None (the default), enrollment files for all models are returned.

Parameters:

model_idint or str

A unique ID that identifies the model.

groupone of ('dev', 'eval')

The group to get the enrollment files for.

Returns:

files[bob.bio.base_legacy.database.BioFile]

The list of files used for to enroll the model with the given model id.

file_names(files, directory, extension) → paths

Returns the full path of the given File objects.

Parameters:

files[bob.bio.base_legacy.database.BioFile]

The list of file object to retrieve the file names for.

directorystr

The base directory, where the files can be found.

extensionstr

The file name extension to add to all files.

Returns:

paths[str] or [[str]]

The paths extracted for the files, in the same order. If this database provides file sets, a list of lists of file names is returned, one sub-list for each file set.

groups(protocol=None)

Returns the names of all registered groups in the database

Keyword parameters:

protocol: str

The protocol for which the groups should be retrieved. If you do not have protocols defined, just ignore this field.

model_ids(group = 'dev') → ids

Returns a list of model ids for the given group, respecting the current protocol.

Parameters:

groupone of ('dev', 'eval')

The group to get the model ids for.

Returns:

ids[int] or [str]

The list of (unique) model ids for models of the given group.

model_ids_with_protocol(groups = None, protocol = None, **kwargs) → ids

Client-based PAD is not implemented.

object_sets(groups=None, protocol=None, purposes=None, model_ids=None, **kwargs)

This function returns lists of FileSet objects, which fulfill the given restrictions.

Keyword parameters:

groupsstr or [str]

The groups of which the clients should be returned. Usually, groups are one or more elements of (‘world’, ‘dev’, ‘eval’)

protocol

The protocol for which the clients should be retrieved. The protocol is dependent on your database. If you do not have protocols defined, just ignore this field.

purposesstr or [str]

The purposes for which File objects should be retrieved. Usually, purposes are one of (‘enroll’, ‘probe’).

model_ids[various type]

The model ids for which the File objects should be retrieved. What defines a ‘model id’ is dependent on the database. In cases, where there is only one model per client, model ids and client ids are identical. In cases, where there is one model per file, model ids and file ids are identical. But, there might also be other cases.

objects(groups=None, protocol=None, purposes=None, model_ids=None, **kwargs)[source]

Returns a set of Files for the specific query by the user.

Keyword Parameters:

groups

One of the groups (‘train’, ‘dev’, ‘eval’) 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.

protocol

The protocol for which the clients should be retrieved. The protocol is dependent on your database. If you do not have protocols defined, just ignore this field.

purposes

The purposes can be either ‘real’ or ‘attack’.

model_ids

This parameter is not supported in this implementation.

Returns: A set of Files with the specified properties.

original_file_name(file)

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

Parameters

filebob.db.base.File or a derivative The File objects for which the file name should be retrieved

Returns

The original file name for the given bob.db.base.File object.

Return type

str

Raises

ValueError – if the file is not found.

original_file_names(files) → paths

Returns the full paths of the real and attack data of the given PadFile objects.

Parameters:

files[[bob.pad.base.database.PadFile], [bob.pad.base.database.PadFile]

The list of lists ([real, attack]) of file object to retrieve the original data file names for.

Returns:

paths[str] or [[str]]

The paths extracted for the concatenated real+attack files, in the preserved order.

probe_file_sets(model_id = None, group = 'dev') → files

Returns a list of probe FileSet objects, respecting the current protocol. If a model_id is specified, only the probe files that should be compared with the given model id are returned (for most databases, these are all probe files of the given group). Otherwise, all probe files of the given group are returned.

Parameters:

model_idint or str or None

A unique ID that identifies the model.

groupone of ('dev', 'eval')

The group to get the enrollment files for.

Returns:

files[bob.bio.base_legacy.database.BioFileSet] or something similar

The list of file sets used to probe the model with the given model id.

probe_files(model_id = None, group = 'dev') → files

Returns a list of probe File objects, respecting the current protocol. If a model_id is specified, only the probe files that should be compared with the given model id are returned (for most databases, these are all probe files of the given group). Otherwise, all probe files of the given group are returned.

Parameters:

model_idint or str or None

A unique ID that identifies the model.

groupone of ('dev', 'eval')

The group to get the enrollment files for.

Returns:

files[bob.bio.base_legacy.database.BioFile]

The list of files used for to probe the model with the given model id.

replace_directories(replacements=None)

This helper function replaces the original_directory and the annotation_directory of the database with the directories read from the given replacement file.

This function is provided for convenience, so that the database configuration files do not need to be modified. Instead, this function uses the given dictionary of replacements to change the original directory and the original extension (if given).

The given replacements can be of type dict, including all replacements, or a file name (as a str), in which case the file is read. The structure of the file should be:

# Comments starting with # and empty lines are ignored

[YOUR_..._DATA_DIRECTORY] = /path/to/your/data
[YOUR_..._ANNOTATION_DIRECTORY] = /path/to/your/annotations

If no annotation files are available (e.g. when they are stored inside the database), the annotation directory can be left out.

Parameters:

replacementsdict or str

A dictionary with replacements, or a name of a file to read the dictionary from. If the file name does not exist, no directories are replaced.

sort(files)
test_files(groups = ['dev']) → files

Returns all test files (i.e., files used for enrollment and probing) for the given groups, respecting the current protocol. The files for the steps can be limited using the all_files_options defined in the constructor.

Parameters:

groupssome of ('dev', 'eval')

The groups to get the data for.

Returns:

files[bob.bio.base_legacy.database.BioFile]

The sorted and unique list of test files of the database.

training_files(step = None, arrange_by_client = False) → files

Returns all training File objects This function needs to be implemented in derived class implementations.

Parameters:

The parameters are not applicable in this version of anti-spoofing experiments

Returns:

files[bob.pad.base.database.PadFile] or [[bob.pad.base.database.PadFile]]

The (arranged) list of files used for the training.

uses_probe_file_sets(protocol=None)

Defines if, for the current protocol, the database uses several probe files to generate a score. 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.