Python API

Note

If this section is empty, please go to the console and type:

$ ./bin/sphinx-build doc sphinx

again, after you have successfully patched the CSU code.

LRPCA

class xfacereclib.extension.CSU.lrpca.ImageCrop(TUNING)[source]

Bases: facereclib.preprocessing.Preprocessor.Preprocessor

This class defines a wrapper for the facerec2010.baseline.lrpca.LRPCA class to be used as an image facereclib.preprocessing.Preprocessor in the FaceRecLib.

Constructor Documentation:

TUNING
The tuning for the LRPCA algorithm as taken from the facerec2010.baseline.lrpca.GBU_TUNING
read_original_data(image_file)[source]

Reads the original images using functionality from pyvision.

quality()

Returns the quality of the last preprocessed image. This quality term is application dependent. By default, None is returned.

read_data(data_file)

Reads the preprocessed data 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.

save_data(data, data_file)

Saves the given preprocessed data to a file with the given name. In this base class implementation:

  • If the given data has a save attribute, it calls data.save(bob.io.base.HDF5File(data_file), 'w'). In this case, the given data_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 (e.g. not images), please overwrite this function.

class xfacereclib.extension.CSU.lrpca.Features(TUNING)[source]

Bases: facereclib.features.Extractor.Extractor

This class defines a wrapper for the facerec2010.baseline.lrpca.LRPCA class to be used as a facereclib.feature.Extractor in the FaceRecLib.

Constructor Documentation:

TUNING
The tuning for the LRPCA algorithm as taken from the facerec2010.baseline.lrpca.GBU_TUNING
train(image_list, extractor_file)[source]

Trains the LRPCA module with the given image list and saves the result into the given extractor file using the pickle module.

load(extractor_file)[source]

Loads the trained LRPCA feature extractor from the given extractor file using the pickle module.

read_feature(feature_file)

Reads the extracted 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.

save_feature(feature, feature_file)

Saves the given extracted 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.

class xfacereclib.extension.CSU.lrpca.Tool(TUNING, multiple_model_scoring='average', multiple_probe_scoring='average')[source]

Bases: facereclib.tools.Tool.Tool

This class defines a wrapper for the facerec2010.baseline.lrpca.LRPCA class to be used as a face recognition facereclib.tools.Tool in the FaceRecLib.

Constructor Documentation:

TUNING
The tuning for the LRPCA algorithm as taken from the facerec2010.baseline.lrpca.GBU_TUNING
multiple_model_scoring
The scoring strategy if models are enrolled from several images, see facereclib.tools.Tool for more information.
multiple_probe_scoring
The scoring strategy if a score is computed from several probe images, see facereclib.tools.Tool for more information.
enroll(enroll_features)[source]

Enrolls a model from features from several images by simply storing all given features.

save_model(model, model_file)[source]

Saves the enrolled model to file using the pickle module.

read_model(model_file)[source]

Loads an enrolled model from file using the pickle module.

score(model, probe)[source]

Computes the score for the given model (a list of FaceRecords) and a probe feature (a numpy.ndarray)

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

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

LDA-IR

class xfacereclib.extension.CSU.ldair.ImageCrop(REGION_ARGS, REGION_KEYWORDS)[source]

Bases: facereclib.preprocessing.Preprocessor.Preprocessor

This class defines a wrapper for the facerec2010.baseline.lda.LRLDA class to be used as an image facereclib.preprocessing.Preprocessor in the FaceRecLib.

Constructor Documentation:

REGION_ARGS
The region arguments as taken from facerec2010.baseline.lda.CohortLDA_REGIONS
REGION_KEYWORDS
The region keywords as taken from facerec2010.baseline.lda.CohortLDA_KEYWORDS
read_original_data(image_file)[source]

Reads the original images using functionality from pyvision.

quality()

Returns the quality of the last preprocessed image. This quality term is application dependent. By default, None is returned.

read_data(data_file)

Reads the preprocessed data 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.

save_data(data, data_file)

Saves the given preprocessed data to a file with the given name. In this base class implementation:

  • If the given data has a save attribute, it calls data.save(bob.io.base.HDF5File(data_file), 'w'). In this case, the given data_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 (e.g. not images), please overwrite this function.

class xfacereclib.extension.CSU.ldair.Features(REGION_ARGS, REGION_KEYWORDS)[source]

Bases: facereclib.features.Extractor.Extractor

This class defines a wrapper for the facerec2010.baseline.lda.LRLDA class to be used as a facereclib.feature.Extractor in the FaceRecLib.

Constructor Documentation:

REGION_ARGS
The region arguments as taken from facerec2010.baseline.lda.CohortLDA_REGIONS
REGION_KEYWORDS
The region keywords as taken from facerec2010.baseline.lda.CohortLDA_KEYWORDS
train(image_list, extractor_file)[source]

Trains the LDA-IR module with the given image list and saves its result into the given extractor file using the pickle module.

load(extractor_file)[source]

Loads the LDA-IR from the given extractor file using the pickle module.

save_feature(feature, feature_file)[source]

Saves the projected LDA-IR feature to file using the pickle module.

read_feature(feature_file)[source]

Reads the projected LDA-IR feature from file using the pickle module.

class xfacereclib.extension.CSU.ldair.Tool(REGION_ARGS, REGION_KEYWORDS, multiple_model_scoring='average', multiple_probe_scoring='average')[source]

Bases: facereclib.tools.Tool.Tool

This class defines a wrapper for the facerec2010.baseline.lda.LRLDA class to be used as a face recognition facereclib.tools.Tool in the FaceRecLib.

Constructor Documentation:

REGION_ARGS
The region arguments as taken from facerec2010.baseline.lda.CohortLDA_REGIONS
REGION_KEYWORDS
The region keywords as taken from facerec2010.baseline.lda.CohortLDA_KEYWORDS
multiple_model_scoring
The scoring strategy if models are enrolled from several images, see facereclib.tools.Tool for more information.
multiple_probe_scoring
The scoring strategy if a score is computed from several probe images, see facereclib.tools.Tool for more information.
load_projector(projector_file)[source]

This function loads the Projector from the given projector file. This is only required when the cohort adjustment is enabled.

enroll(enroll_features)[source]

Enrolls a model from features from several images by simply storing all given features.

save_model(model, model_file)[source]

Saves the enrolled model to file using the pickle module.

read_model(model_file)[source]

Loads an enrolled model from file using the pickle module.

read_probe(model_file)

Loads an enrolled model from file using the pickle module.

score(model, probe)[source]

Compute the score for the given model (a list of FaceRecords) and a probe (a FaceRecord)

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.

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.

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.

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

Table Of Contents

Previous topic

Installation

This Page