Biometric Recognition Algorithms

Tool chain for computing verification scores

class facereclib.tools.BIC(comparison_function, maximum_training_pair_count=None, subspace_dimensions=None, uses_dffs=False, load_function=<function load>, save_function=<function save>, **kwargs)[source]

Bases: facereclib.tools.Tool.Tool

Computes the Intrapersonal/Extrapersonal classifier

enroll(enroll_features)[source]

Enrolls features by concatenating them

load_enroller(enroller_file)[source]

Reads the intrapersonal and extrapersonal mean and variance values

load_projector(projector_file)

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

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

read_feature(feature_file)

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.

read_model(model_file)[source]

Loads all features of the model from the HDF5 file, using the load_function specified in the constructor.

read_probe(probe_file)[source]

Loads the probe feature from file, using the load_function specified in the constructor.

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

save_model(model, model_file)[source]

Writes all features of the model into one HDF5 file, using the save_function specified in the constructor.

score(model, probe)[source]

Computes the IEC score for the given model and probe pair

score_for_multiple_models(models, probe)

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.

score_for_multiple_probes(model, probes)

This function computes the score between the given model and the given probe files. In this base class implementation, it computes the scores for each probe file using the ‘score’ method, and fuses the scores using the fusion method specified in the constructor of this class.

sqr(x)[source]
train_enroller(train_features, enroller_file)[source]

Trains the IEC Tool, i.e., computes intrapersonal and extrapersonal subspaces

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

The training function gets two parameters:

  • training_features: A list of extracted features that can be used for training the extractor.
  • projector_file: The file to write. This file should be readable with the ‘load_projector’ function (see above).
class facereclib.tools.Dummy[source]

Bases: facereclib.tools.Tool.Tool

This class is used to test all the possible functions of the tool chain, but it does basically nothing.

Generates a test value that is read and written

enroll(enroll_features)[source]

Returns the first feature as the model

load_enroller(enroller_file)[source]

Loads the test value from file and compares it with the desired one

load_projector(projector_file)[source]

Loads the test value from file and compares it with the desired one

project(feature)[source]

Just returns the feature since this dummy implementation does not really project the data

read_feature(feature_file)[source]

Reads the feature from the given file

read_model(model_file)[source]

Reads the model from file

read_probe(probe_file)[source]

Reads the probe from file

save_feature(feature, feature_file)[source]

Saves the given feature to the given file

save_model(model, model_file)[source]

Writes the model to the given model file

score(model, probe)[source]

Returns the Euclidean distance between model and probe

score_for_multiple_models(models, probe)

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.

score_for_multiple_probes(model, probes)

This function computes the score between the given model and the given probe files. In this base class implementation, it computes the scores for each probe file using the ‘score’ method, and fuses the scores using the fusion method specified in the constructor of this class.

train_enroller(train_files, enroller_file)[source]

Does not train the projector, but writes some file

train_projector(train_files, projector_file)[source]

Does not train the projector, but writes some file

class facereclib.tools.GaborJets(gabor_jet_similarity_type, multiple_feature_scoring='max_jet', gabor_directions=8, gabor_scales=5, gabor_sigma=6.283185307179586, gabor_maximum_frequency=1.5707963267948966, gabor_frequency_step=0.7071067811865476, gabor_power_of_k=0, gabor_dc_free=True)[source]

Bases: facereclib.tools.Tool.Tool

Tool chain for computing Gabor jets, Gabor graphs, and Gabor graph comparisons

enroll(enroll_features)[source]

Enrolls the model by computing an average graph for each model

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 (see above). This function is always called AFTER calling the ‘load_projector’. In this base class implementation, it does nothing.

load_projector(projector_file)

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

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

read_feature(feature_file)

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.

read_model(model_file)[source]
read_probe(probe_file)[source]
save_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.

save_model(model, model_file)[source]
score(model, probe)[source]

Computes the score of the probe and the model

score_for_multiple_models(models, probe)

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.

score_for_multiple_probes(model, probes)[source]

This function computes the score between the given model graph(s) and several given probe graphs.

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

The training function gets two parameters:

  • training_features: A dictionary of extracted or projected features, which are sorted by clients, that can be used for training the extractor.
  • enroller_file: The file to write. This file should be readable with the ‘load_enroller’ function (see above).
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’.

The training function gets two parameters:

  • training_features: A list of extracted features that can be used for training the extractor.
  • projector_file: The file to write. This file should be readable with the ‘load_projector’ function (see above).
class facereclib.tools.ISV(subspace_dimension_of_u, isv_training_iterations=10, isv_enroll_iterations=1, multiple_probe_scoring=None, **kwargs)[source]

Bases: facereclib.tools.UBMGMM.UBMGMM

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

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 (see above). This function is always called AFTER calling the ‘load_projector’. In this base class implementation, it does nothing.

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

Computes GMM statistics against a UBM, then corresponding Ux vector

project_isv(projected_ubm)[source]
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_feature(data, feature_file)[source]
save_model(model, model_file)

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

save_projector(projector_file)[source]

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

score(model, probe)[source]

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

score_for_multiple_models(models, probe)

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.

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

The training function gets two parameters:

  • training_features: A dictionary of extracted or projected features, which are sorted by clients, that can be used for training the extractor.
  • enroller_file: The file to write. This file should be readable with the ‘load_enroller’ function (see above).
train_projector(train_features, projector_file)[source]

Train Projector and Enroller at the same time

class facereclib.tools.IVector(subspace_dimension_of_t, update_sigma=True, tv_training_iterations=25, variance_threshold=1e-05, **kwargs)[source]

Bases: facereclib.tools.UBMGMM.UBMGMM

Tool for extracting I-Vectors

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

enroll(enroll_features)[source]

Performs IVector enrollment

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 (see above). This function is always called AFTER calling the ‘load_projector’. In this base class implementation, it does nothing.

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)[source]
load_whitening(whitening_file)[source]
project(feature_array)[source]

Computes GMM statistics against a UBM, then corresponding Ux vector

project_ivec(gmm_stats)[source]
project_ubm(features)[source]
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_feature(data, feature_file)[source]

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

save_model(model, model_file)

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

save_projector(projector_file)[source]
score(model, probe)[source]

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

score_for_multiple_models(models, probe)

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.

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

The training function gets two parameters:

  • training_features: A dictionary of extracted or projected features, which are sorted by clients, that can be used for training the extractor.
  • enroller_file: The file to write. This file should be readable with the ‘load_enroller’ function (see above).
train_projector(train_features, projector_file)[source]

Train Projector and Enroller at the same time

class facereclib.tools.JFA(subspace_dimension_of_u, subspace_dimension_of_v, jfa_training_iterations=10, jfa_enroll_iterations=1, **kwargs)[source]

Bases: facereclib.tools.UBMGMM.UBMGMM

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

load_enroller(enroller_file)[source]

Reads the UBM model from file

load_projector(projector_file)[source]

Reads the UBM model from file

load_ubm(ubm_file)
project(feature_array)

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

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

save_model(model, model_file)

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

score(model, probe)[source]

Computes the score for the given model and the given probe

score_for_multiple_models(models, probe)

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.

score_for_multiple_probes(model, probes)[source]

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

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

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

class facereclib.tools.LDA(lda_subspace_dimension=0, pca_subspace_dimension=None, distance_function=<function euclidean>, is_distance_function=True, uses_variances=False, **kwargs)[source]

Bases: facereclib.tools.Tool.Tool

Tool for computing linear discriminant analysis (so-called Fisher faces)

Initializes the LDA tool with the given configuration

enroll(enroll_features)[source]

Enrolls the model by computing an average of the given input vectors

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 (see above). This function is always called AFTER calling the ‘load_projector’. In this base class implementation, it does nothing.

load_projector(projector_file)[source]

Reads the LDA projection matrix from file

project(feature)[source]

Projects the data using the stored covariance matrix

read_feature(feature_file)

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.

read_model(model_file)

Loads the enrolled model from file. In this base class implementation, it uses bob.io.base.load to do that.

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

read_probe(probe_file)

Reads the probe feature from file. By default, the probe feature is identical to the projected feature. Hence, this base class implementation simply calls self.read_feature(...).

If your tool requires different behavior, please overwrite this function.

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

save_model(model, model_file)

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

score(model, probe)[source]

Computes the distance of the model to the probe using the distance function taken from the config file

score_for_multiple_models(models, probe)

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.

score_for_multiple_probes(model, probes)

This function computes the score between the given model and the given probe files. In this base class implementation, it computes the scores for each probe file using the ‘score’ method, and fuses the scores using the fusion method specified in the constructor of this class.

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

The training function gets two parameters:

  • training_features: A dictionary of extracted or projected features, which are sorted by clients, that can be used for training the extractor.
  • enroller_file: The file to write. This file should be readable with the ‘load_enroller’ function (see above).
train_projector(training_features, projector_file)[source]

Generates the LDA projection matrix from the given features (that are sorted by identity)

class facereclib.tools.LGBPHS(distance_function=<built-in function chi_square>, is_distance_function=True, multiple_probe_scoring='average')[source]

Bases: facereclib.tools.Tool.Tool

Tool chain for computing local Gabor binary pattern histogram sequences

Initializes the local Gabor binary pattern histogram sequence tool

enroll(enroll_features)[source]

Enrolling model by taking the average of all features

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 (see above). This function is always called AFTER calling the ‘load_projector’. In this base class implementation, it does nothing.

load_projector(projector_file)

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

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

read_feature(feature_file)

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.

read_model(model_file)

Loads the enrolled model from file. In this base class implementation, it uses bob.io.base.load to do that.

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

read_probe(probe_file)

Reads the probe feature from file. By default, the probe feature is identical to the projected feature. Hence, this base class implementation simply calls self.read_feature(...).

If your tool requires different behavior, please overwrite this function.

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

save_model(model, model_file)

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

score(model, probe)[source]

Computes the score using the specified histogram measure; returns a similarity value (bigger -> better)

score_for_multiple_models(models, probe)

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.

score_for_multiple_probes(model, probes)

This function computes the score between the given model and the given probe files. In this base class implementation, it computes the scores for each probe file using the ‘score’ method, and fuses the scores using the fusion method specified in the constructor of this class.

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

The training function gets two parameters:

  • training_features: A dictionary of extracted or projected features, which are sorted by clients, that can be used for training the extractor.
  • enroller_file: The file to write. This file should be readable with the ‘load_enroller’ function (see above).
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’.

The training function gets two parameters:

  • training_features: A list of extracted features that can be used for training the extractor.
  • projector_file: The file to write. This file should be readable with the ‘load_projector’ function (see above).
class facereclib.tools.PCA(subspace_dimension, distance_function=<function euclidean>, is_distance_function=True, uses_variances=False, **kwargs)[source]

Bases: facereclib.tools.Tool.Tool

Tool for computing eigenfaces

Initializes the PCA tool with the given setup

enroll(enroll_features)[source]

Enrolls the model by computing an average of the given input vectors

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 (see above). This function is always called AFTER calling the ‘load_projector’. In this base class implementation, it does nothing.

load_projector(projector_file)[source]

Reads the PCA projection matrix from file

project(feature)[source]

Projects the data using the stored covariance matrix

read_feature(feature_file)

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.

read_model(model_file)

Loads the enrolled model from file. In this base class implementation, it uses bob.io.base.load to do that.

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

read_probe(probe_file)

Reads the probe feature from file. By default, the probe feature is identical to the projected feature. Hence, this base class implementation simply calls self.read_feature(...).

If your tool requires different behavior, please overwrite this function.

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

save_model(model, model_file)

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

score(model, probe)[source]

Computes the distance of the model to the probe using the distance function taken from the config file

score_for_multiple_models(models, probe)

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.

score_for_multiple_probes(model, probes)

This function computes the score between the given model and the given probe files. In this base class implementation, it computes the scores for each probe file using the ‘score’ method, and fuses the scores using the fusion method specified in the constructor of this class.

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

The training function gets two parameters:

  • training_features: A dictionary of extracted or projected features, which are sorted by clients, that can be used for training the extractor.
  • enroller_file: The file to write. This file should be readable with the ‘load_enroller’ function (see above).
train_projector(training_features, projector_file)[source]

Generates the PCA covariance matrix

class facereclib.tools.PLDA(subspace_dimension_of_f, subspace_dimension_of_g, subspace_dimension_pca=None, plda_training_iterations=200, INIT_SEED=5489, INIT_F_METHOD='BETWEEN_SCATTER', INIT_G_METHOD='WITHIN_SCATTER', INIT_S_METHOD='VARIANCE_DATA', multiple_probe_scoring='joint_likelihood')[source]

Bases: facereclib.tools.Tool.Tool

Tool chain for computing PLDA (over PCA-dimensionality reduced) features

Initializes the local (PCA-)PLDA tool chain with the given file selector object

enroll(enroll_features)[source]

Enrolls the model by computing an average of the given input vectors

load_enroller(projector_file)[source]

Reads the PCA projection matrix and the PLDA model from file

load_projector(projector_file)

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

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

read_feature(feature_file)

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.

read_model(model_file)[source]

Reads the model, which in this case is a PLDA-Machine

read_probe(probe_file)

Reads the probe feature from file. By default, the probe feature is identical to the projected feature. Hence, this base class implementation simply calls self.read_feature(...).

If your tool requires different behavior, please overwrite this function.

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

save_model(model, model_file)

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

score(model, probe)[source]

Computes the PLDA score for the given model and probe

score_for_multiple_models(models, probe)

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.

score_for_multiple_probes(model, probes)[source]

This function computes the score between the given model and several given probe files. In this base class implementation, it computes the scores for each probe file using the ‘score’ method, and fuses the scores using the fusion method specified in the constructor of this class.

train_enroller(training_features, projector_file)[source]

Generates the PLDA base model from a list of arrays (one per identity), and a set of training parameters. If PCA is requested, it is trained on the same data. Both the trained PLDABase and the PCA machine are written.

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

The training function gets two parameters:

  • training_features: A list of extracted features that can be used for training the extractor.
  • projector_file: The file to write. This file should be readable with the ‘load_projector’ function (see above).
class facereclib.tools.Tool(performs_projection=False, requires_projector_training=True, split_training_features_by_client=False, use_projected_features_for_enrollment=True, requires_enroller_training=False, multiple_model_scoring='average', multiple_probe_scoring='average', **kwargs)[source]

This is the base class for all face recognition tools. It defines the minimum requirements for all derived tool classes.

Initializes the Tool. Call this constructor in derived class implementations. If your derived tool performs feature projection, please register this here. If it needs training for the projector or the enroller, please set this here, too.

enroll(enroll_features)[source]

This function will enroll and return the model from the given list of features. It must be overwritten by derived classes.

load_enroller(enroller_file)[source]

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

load_projector(projector_file)[source]

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

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

read_feature(feature_file)[source]

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.

read_model(model_file)[source]

Loads the enrolled model from file. In this base class implementation, it uses bob.io.base.load to do that.

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

read_probe(probe_file)[source]

Reads the probe feature from file. By default, the probe feature is identical to the projected feature. Hence, this base class implementation simply calls self.read_feature(...).

If your tool requires different behavior, please overwrite this function.

save_feature(feature, feature_file)[source]

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.

save_model(model, model_file)[source]

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

score(model, probe)[source]

This function will compute the score between the given model and probe. It must be overwritten by derived classes.

score_for_multiple_models(models, probe)[source]

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.

score_for_multiple_probes(model, probes)[source]

This function computes the score between the given model and the given probe files. In this base class implementation, it computes the scores for each probe file using the ‘score’ method, and fuses the scores using the fusion method specified in the constructor of this class.

train_enroller(training_features, enroller_file)[source]

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

The training function gets two parameters:

  • training_features: A dictionary of extracted or projected features, which are sorted by clients, that can be used for training the extractor.
  • enroller_file: The file to write. This file should be readable with the ‘load_enroller’ function (see above).
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’.

The training function gets two parameters:

  • training_features: A list of extracted features that can be used for training the extractor.
  • projector_file: The file to write. This file should be readable with the ‘load_projector’ function (see above).
class facereclib.tools.UBMGMM(number_of_gaussians, k_means_training_iterations=500, gmm_training_iterations=500, training_threshold=0.0005, variance_threshold=0.0005, update_weights=True, update_means=True, update_variances=True, normalize_before_k_means=True, relevance_factor=4, gmm_enroll_iterations=1, responsibility_threshold=0, INIT_SEED=5489, scoring_function=<built-in function linear_scoring>)[source]

Bases: facereclib.tools.Tool.Tool

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

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

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 (see above). This function is always called AFTER calling the ‘load_projector’. In this base class implementation, it does nothing.

load_projector(projector_file)[source]

Reads the UBM model from file

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

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

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]
read_probe(probe_file)

Reads the probe feature from file. By default, the probe feature is identical to the projected feature. Hence, this base class implementation simply calls self.read_feature(...).

If your tool requires different behavior, please overwrite this function.

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

save_model(model, model_file)

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

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)

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.

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

The training function gets two parameters:

  • training_features: A dictionary of extracted or projected features, which are sorted by clients, that can be used for training the extractor.
  • enroller_file: The file to write. This file should be readable with the ‘load_enroller’ function (see above).
train_projector(train_features, projector_file)[source]

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

class facereclib.tools.UBMGMMRegular(**kwargs)[source]

Bases: facereclib.tools.UBMGMM.UBMGMM

Tool chain 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

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

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

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)
read_probe(probe_file)[source]
save_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.

save_model(model, model_file)

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

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)

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.

score_for_multiple_probes(model, probes)

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

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