Tools implemented in bob.bio.gmm

Summary

Details

class bob.bio.gmm.algorithm.GMM(number_of_gaussians, kmeans_training_iterations=25, gmm_training_iterations=25, training_threshold=0.0005, variance_threshold=0.0005, update_weights=True, update_means=True, update_variances=True, relevance_factor=4, gmm_enroll_iterations=1, responsibility_threshold=0, INIT_SEED=5489, scoring_function=<built-in function linear_scoring>)[source]

Bases: bob.bio.base.algorithm.Algorithm.Algorithm

Algorithm for computing Universal Background Models and Gaussian Mixture Models of the features. Features must be normalized to zero mean and unit standard deviation.

Initializes the local UBM-GMM tool chain with the given file selector object

enroll(feature_arrays)[source]

Enrolls a GMM using MAP adaptation, given a list of 2D numpy.ndarray’s of feature vectors

enroll_gmm(array)[source]
load_enroller(enroller_file)

Loads the parameters required for model enrollment from file. This function usually is only useful in combination with the train_enroller() function. This function is always called after calling load_projector(). In this base class implementation, it does nothing.

Parameters:

enroller_file : str
The file to read the enroller from.
load_projector(projector_file)[source]

Reads the UBM model from file

load_ubm(ubm_file)[source]
project(feature)[source]

Computes GMM statistics against a UBM, given an input 2D numpy.ndarray of feature vectors

project_ubm(array)[source]
read_feature(feature_file)[source]

Read the type of features that we require, namely GMM_Stats

read_gmm_stats(gmm_stats_file)[source]

Reads GMM stats from file.

read_model(model_file)[source]

Reads the model, which is a GMM machine

read_probe(feature_file)

Read the type of features that we require, namely GMM_Stats

save_ubm(projector_file)[source]

Save projector to file

score(model, probe)[source]

Computes the score for the given model and the given probe using the scoring function from the config file

score_for_multiple_models(models, probe) → score

This function computes the score between the given model list and the given probe. In this base class implementation, it computes the scores for each model using the score() method, and fuses the scores using the fusion method specified in the constructor of this class. Usually this function is called from derived class score() functions.

Parameters:

models : [object]
A list of model objects.
probe : object
The probe object to compare the models with.

Returns:

score : float
The fused similarity between the given models and the probe.
score_for_multiple_probes(model, probes)[source]

This function computes the score between the given model and several given probe files.

train_enroller(training_features, enroller_file)

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

Parameters:

training_features : [object] or [[object]]
A list of extracted features that can be used for training the projector. Features will be split into lists, each of which contains the features of a single (training-)client.
enroller_file : str
The file to write. This file should be readable with the load_enroller() function.
train_projector(train_features, projector_file)[source]

Computes the Universal Background Model from the training (“world”) data

train_ubm(array)[source]
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:

feature : object
A feature as returned by the project() function, which should be written.
feature_file : str or bob.io.base.HDF5File
The file open for writing, or the file name to write to.
write_model(model, model_file)

Writes the enrolled model to the given file. In this base class implementation:

  • If the given model has a ‘save’ attribute, it calls model.save(bob.io.base.HDF5File(model_file), 'w'). In this case, the given model_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.

Parameters:

model : object
A model as returned by the enroll() function, which should be written.
model_file : str or bob.io.base.HDF5File
The file open for writing, or the file name to write to.
class bob.bio.gmm.algorithm.GMMRegular(**kwargs)[source]

Bases: bob.bio.gmm.algorithm.GMM.GMM

Algorithm for computing Universal Background Models and Gaussian Mixture Models of the features

Initializes the local UBM-GMM tool chain with the given file selector object

enroll(feature_arrays)

Enrolls a GMM using MAP adaptation, given a list of 2D numpy.ndarray’s of feature vectors

enroll_gmm(array)
load_enroller(enroller_file)[source]

Reads the UBM model from file

load_projector(projector_file)

Reads the UBM model from file

load_ubm(ubm_file)
project(feature)

Computes GMM statistics against a UBM, given an input 2D numpy.ndarray of feature vectors

project_ubm(array)
read_feature(feature_file)

Read the type of features that we require, namely GMM_Stats

read_gmm_stats(gmm_stats_file)

Reads GMM stats from file.

read_model(model_file)

Reads the model, which is a GMM machine

read_probe(probe_file)[source]

Reads a feature from file, which is supposed to be a simple 2D array

save_ubm(projector_file)

Save projector to file

score(model, probe)[source]

Computes the score for the given model and the given probe. The score are Log-Likelihood. Therefore, the log of the likelihood ratio is obtained by computing the following difference.

score_for_multiple_models(models, probe) → score

This function computes the score between the given model list and the given probe. In this base class implementation, it computes the scores for each model using the score() method, and fuses the scores using the fusion method specified in the constructor of this class. Usually this function is called from derived class score() functions.

Parameters:

models : [object]
A list of model objects.
probe : object
The probe object to compare the models with.

Returns:

score : float
The fused similarity between the given models and the probe.
score_for_multiple_probes(model, probes)[source]
train_enroller(train_features, enroller_file)[source]

Computes the Universal Background Model from the training (“world”) data

train_projector(train_features, projector_file)

Computes the Universal Background Model from the training (“world”) data

train_ubm(array)
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:

feature : object
A feature as returned by the project() function, which should be written.
feature_file : str or bob.io.base.HDF5File
The file open for writing, or the file name to write to.
write_model(model, model_file)

Writes the enrolled model to the given file. In this base class implementation:

  • If the given model has a ‘save’ attribute, it calls model.save(bob.io.base.HDF5File(model_file), 'w'). In this case, the given model_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.

Parameters:

model : object
A model as returned by the enroll() function, which should be written.
model_file : str or bob.io.base.HDF5File
The file open for writing, or the file name to write to.
class bob.bio.gmm.algorithm.ISV(subspace_dimension_of_u, isv_training_iterations=10, isv_enroll_iterations=1, multiple_probe_scoring=None, **kwargs)[source]

Bases: bob.bio.gmm.algorithm.GMM.GMM

Tool for computing Unified Background Models and Gaussian Mixture Models of the features

Initializes the local UBM-GMM tool with the given file selector object

enroll(enroll_features)[source]

Performs ISV enrollment

enroll_gmm(array)
load_enroller(enroller_file)

Loads the parameters required for model enrollment from file. This function usually is only useful in combination with the train_enroller() function. This function is always called after calling load_projector(). In this base class implementation, it does nothing.

Parameters:

enroller_file : str
The file to read the enroller from.
load_isv(isv_file)[source]
load_projector(projector_file)[source]

Load the GMM and the ISV model from the same HDF5 file

load_ubm(ubm_file)
project(feature)[source]

Computes GMM statistics against a UBM, then corresponding Ux vector

project_isv(projected_ubm)[source]
project_ubm(array)
read_feature(feature_file)[source]

Read the type of features that we require, namely GMMStats

read_gmm_stats(gmm_stats_file)

Reads GMM stats from file.

read_model(model_file)[source]

Reads the ISV Machine that holds the model

read_probe(probe_file)[source]

Read the type of features that we require, namely GMMStats

save_projector(projector_file)[source]

Save the GMM and the ISV model in the same HDF5 file

save_ubm(projector_file)

Save projector to file

score(model, probe)[source]

Computes the score for the given model and the given probe.

score_for_multiple_models(models, probe) → score

This function computes the score between the given model list and the given probe. In this base class implementation, it computes the scores for each model using the score() method, and fuses the scores using the fusion method specified in the constructor of this class. Usually this function is called from derived class score() functions.

Parameters:

models : [object]
A list of model objects.
probe : object
The probe object to compare the models with.

Returns:

score : float
The fused similarity between the given models and the probe.
score_for_multiple_probes(model, probes)[source]

This function computes the score between the given model and several given probe files.

train_enroller(training_features, enroller_file)

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

Parameters:

training_features : [object] or [[object]]
A list of extracted features that can be used for training the projector. Features will be split into lists, each of which contains the features of a single (training-)client.
enroller_file : str
The file to write. This file should be readable with the load_enroller() function.
train_isv(data)[source]

Train the ISV model given a dataset

train_projector(train_features, projector_file)[source]

Train Projector and Enroller at the same time

train_ubm(array)
write_feature(data, feature_file)[source]
write_model(model, model_file)

Writes the enrolled model to the given file. In this base class implementation:

  • If the given model has a ‘save’ attribute, it calls model.save(bob.io.base.HDF5File(model_file), 'w'). In this case, the given model_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.

Parameters:

model : object
A model as returned by the enroll() function, which should be written.
model_file : str or bob.io.base.HDF5File
The file open for writing, or the file name to write to.
class bob.bio.gmm.algorithm.IVector(subspace_dimension_of_t, tv_training_iterations=25, update_sigma=True, **kwargs)[source]

Bases: bob.bio.gmm.algorithm.GMM.GMM

Tool for extracting I-Vectors

Initializes the local GMM tool with the given file selector object

enroll(enroll_features)[source]

Performs IVector enrollment

enroll_gmm(array)
load_enroller(enroller_file)

Loads the parameters required for model enrollment from file. This function usually is only useful in combination with the train_enroller() function. This function is always called after calling load_projector(). In this base class implementation, it does nothing.

Parameters:

enroller_file : str
The file to read the enroller from.
load_projector(projector_file)[source]

Load the GMM and the ISV model from the same HDF5 file

load_tv(tv_file)[source]
load_ubm(ubm_file)
load_whitener(whitening_file)[source]
project(feature_array)[source]

Computes GMM statistics against a UBM, then corresponding Ux vector

project_ivector(gmm_stats)[source]
project_ubm(array)
project_whitening(ivector)[source]
read_feature(feature_file)[source]

Read the type of features that we require, namely i-vectors (stored as simple numpy arrays)

read_gmm_stats(gmm_stats_file)

Reads GMM stats from file.

read_model(model_file)[source]

Reads the whitened i-vector that holds the model

read_probe(probe_file)[source]

read probe file which is an i-vector

save_projector(projector_file)[source]
save_ubm(projector_file)

Save projector to file

score(model, probe)[source]

Computes the score for the given model and the given probe.

score_for_multiple_models(models, probe) → score

This function computes the score between the given model list and the given probe. In this base class implementation, it computes the scores for each model using the score() method, and fuses the scores using the fusion method specified in the constructor of this class. Usually this function is called from derived class score() functions.

Parameters:

models : [object]
A list of model objects.
probe : object
The probe object to compare the models with.

Returns:

score : float
The fused similarity between the given models and the probe.
score_for_multiple_probes(model, probes)[source]

This function computes the score between the given model and several given probe files.

train_enroller(training_features, enroller_file)

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

Parameters:

training_features : [object] or [[object]]
A list of extracted features that can be used for training the projector. Features will be split into lists, each of which contains the features of a single (training-)client.
enroller_file : str
The file to write. This file should be readable with the load_enroller() function.
train_ivector(training_stats)[source]
train_projector(train_features, projector_file)[source]

Train Projector and Enroller at the same time

train_ubm(array)
train_whitener(training_features)[source]
write_feature(data, feature_file)[source]

Saves the feature, which is the (whitened) I-Vector.

write_model(model, model_file)

Writes the enrolled model to the given file. In this base class implementation:

  • If the given model has a ‘save’ attribute, it calls model.save(bob.io.base.HDF5File(model_file), 'w'). In this case, the given model_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.

Parameters:

model : object
A model as returned by the enroll() function, which should be written.
model_file : str or bob.io.base.HDF5File
The file open for writing, or the file name to write to.
class bob.bio.gmm.algorithm.JFA(subspace_dimension_of_u, subspace_dimension_of_v, jfa_training_iterations=10, jfa_enroll_iterations=1, **kwargs)[source]

Bases: bob.bio.gmm.algorithm.GMM.GMM

Tool for computing Unified Background Models and Gaussian Mixture Models of the features and project it via JFA

Initializes the local UBM-GMM tool with the given file selector object

enroll(enroll_features)[source]

Enrolls a GMM using MAP adaptation

enroll_gmm(array)
load_enroller(enroller_file)[source]

Reads the JFA base from file

load_projector(projector_file)[source]

Reads the UBM model from file

load_ubm(ubm_file)
project(feature)

Computes GMM statistics against a UBM, given an input 2D numpy.ndarray of feature vectors

project_ubm(array)
read_feature(feature_file)[source]

Reads the projected feature to be enrolled as a model

read_gmm_stats(gmm_stats_file)

Reads GMM stats from file.

read_model(model_file)[source]

Reads the JFA Machine that holds the model

read_probe(feature_file)

Reads the projected feature to be enrolled as a model

save_ubm(projector_file)

Save projector to file

score(model, probe)[source]

Computes the score for the given model and the given probe

score_for_multiple_models(models, probe) → score

This function computes the score between the given model list and the given probe. In this base class implementation, it computes the scores for each model using the score() method, and fuses the scores using the fusion method specified in the constructor of this class. Usually this function is called from derived class score() functions.

Parameters:

models : [object]
A list of model objects.
probe : object
The probe object to compare the models with.

Returns:

score : float
The fused similarity between the given models and the probe.
score_for_multiple_probes(model, probes)[source]

This function computes the score between the given model and several probes.

train_enroller(train_features, enroller_file)[source]
train_projector(train_features, projector_file)

Computes the Universal Background Model from the training (“world”) data

train_ubm(array)
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:

feature : object
A feature as returned by the project() function, which should be written.
feature_file : str or bob.io.base.HDF5File
The file open for writing, or the file name to write to.
write_model(model, model_file)

Writes the enrolled model to the given file. In this base class implementation:

  • If the given model has a ‘save’ attribute, it calls model.save(bob.io.base.HDF5File(model_file), 'w'). In this case, the given model_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.

Parameters:

model : object
A model as returned by the enroll() function, which should be written.
model_file : str or bob.io.base.HDF5File
The file open for writing, or the file name to write to.