diff --git a/bob/bio/gmm/__init__.py b/bob/bio/gmm/__init__.py index e021e4d68c6113effecfacd0cf9f59cad6b9edd3..0d1bcfedaa329d2a32b2141d3ece3110beaf5625 100644 --- a/bob/bio/gmm/__init__.py +++ b/bob/bio/gmm/__init__.py @@ -1,9 +1,8 @@ from . import algorithm - +from . import tools from . import test - def get_config(): """Returns a string containing the configuration information. """ diff --git a/bob/bio/gmm/algorithm/__init__.py b/bob/bio/gmm/algorithm/__init__.py index e3029635df3a5671fb218e7df6042e56d68b8ba8..18612fe9cbde0c3e590e946bd0768013a5686231 100644 --- a/bob/bio/gmm/algorithm/__init__.py +++ b/bob/bio/gmm/algorithm/__init__.py @@ -2,3 +2,6 @@ from .GMM import GMM, GMMRegular from .JFA import JFA from .ISV import ISV from .IVector import IVector + +# gets sphinx autodoc done right - don't remove it +__all__ = [_ for _ in dir() if not _.startswith('_')] diff --git a/bob/bio/gmm/tools/__init__.py b/bob/bio/gmm/tools/__init__.py index 353d85ab58d83922199c740a5a467fed4851598c..b42c342b5c0da565f2957efff645dd3e2fb2bde6 100644 --- a/bob/bio/gmm/tools/__init__.py +++ b/bob/bio/gmm/tools/__init__.py @@ -3,3 +3,6 @@ from .command_line import * from .gmm import * from .isv import * from .ivector import * + +# gets sphinx autodoc done right - don't remove it +__all__ = [_ for _ in dir() if not _.startswith('_')] diff --git a/bob/bio/gmm/tools/ivector.py b/bob/bio/gmm/tools/ivector.py index 561ba7aa4040ee395e594570ac0665cdc54490df..56b2d9e1f03a0ff6517e9c496ec1066193bcec22 100644 --- a/bob/bio/gmm/tools/ivector.py +++ b/bob/bio/gmm/tools/ivector.py @@ -179,33 +179,3 @@ def train_whitener(algorithm, force=False): algorithm.load_whitener(fs.whitener_file) logger.info("Writing projector into file %s", fs.projector_file) algorithm.save_projector(fs.projector_file) - - -""" -def whitening_ivector(self, indices=None, force=False): - ""Performs IVector projection"" - # read UBM into the IVector class - projector = self.m_tool.load_whitening(self.m_configuration.whitening_file) - - projected_ivec_files = self.projected_list(groups=self.groups(), directory=self.m_configuration.ivec_directory) - projected_whitened_files = self.projected_list(groups=self.groups(), directory=self.m_configuration.whitening_directory) - - # select a subset of indices to iterate - if indices != None: - index_range = range(indices[0], indices[1]) - facereclib.utils.info("- Projection: splitting of index range %s" % str(indices)) - else: - index_range = range(len(projected_ivec_files)) - - facereclib.utils.info("- Projection: projecting %d gmm stats from directory '%s' to directory '%s'" % (len(index_range), self.m_configuration.ivec_directory, self.m_configuration.whitening_directory)) - # extract the features - for i in index_range: - if not self.m_tool_chain.__check_file__(projected_whitened_files[i], force): - # load feature - feature = facereclib.utils.load(str(projected_ivec_files[i])) - # project feature - whitened = self.m_tool.project_whitening(feature) - # write it - facereclib.utils.ensure_dir(os.path.dirname(projected_whitened_files[i])) - facereclib.utils.save(whitened, str(projected_whitened_files[i])) -""" diff --git a/doc/conf.py b/doc/conf.py index d676a72a0ceb1cfe8af62e618b5ff3eb27b82aca..72672f323f65099723b62cffaff307a6dafdf7be 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -86,7 +86,7 @@ release = distribution.version # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. -#exclude_patterns = ['**/links.rst'] +exclude_patterns = ['links.rst', 'references.rst'] # The reST default role (used for this markup: `text`) to use for all documents. #default_role = None @@ -133,12 +133,12 @@ if sphinx.__version__ >= "1.0": # The name of an image file (relative to this directory) to place at the top # of the sidebar. -html_logo = '' +html_logo = 'img/logo.png' # The name of an image file (within the static path) to use as favicon of the # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 # pixels large. -html_favicon = '' +html_favicon = 'img/favicon.ico' # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, @@ -187,7 +187,7 @@ html_favicon = '' #html_file_suffix = None # Output file base name for HTML help builder. -htmlhelp_basename = 'bob_example_project_doc' +htmlhelp_basename = 'bob_bio_gmm_doc' # -- Options for LaTeX output -------------------------------------------------- @@ -201,7 +201,7 @@ latex_font_size = '10pt' # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, author, documentclass [howto/manual]). latex_documents = [ - ('index', 'bob_example_project.tex', u'Bob', + ('index', 'bob_bio_gmm.tex', u'Bob', u'Biometrics Group, Idiap Research Institute', 'manual'), ] @@ -236,7 +236,7 @@ rst_epilog = '' # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [ - ('index', 'bob.example.project', u'Bob Example Project Documentation', [u'Idiap Research Institute'], 1) + ('index', 'bob.bio.gmm', u'Gaussian Mixture Models in bob.bio Documentation', [u'Idiap Research Institute'], 1) ] # Default processing flags for sphinx @@ -246,8 +246,14 @@ autodoc_default_flags = ['members', 'undoc-members', 'inherited-members', 'show- # For inter-documentation mapping: from bob.extension.utils import link_documentation -intersphinx_mapping = link_documentation(['python', 'numpy', 'bob.io.gmm', 'bob.db.verification.utils']) +intersphinx_mapping = link_documentation(['python', 'numpy', 'bob.io.gmm']) +def skip(app, what, name, obj, skip, options): + # Do not skip the __call__ and the __str__ functions as we have special implementations for them. + if name in ("__call__"): + return False + return skip + def setup(app): - pass + app.connect("autodoc-skip-member", skip) diff --git a/doc/img/favicon.ico b/doc/img/favicon.ico new file mode 100644 index 0000000000000000000000000000000000000000..4cc3264302627d40868261add69eb755856611b6 Binary files /dev/null and b/doc/img/favicon.ico differ diff --git a/doc/img/logo.png b/doc/img/logo.png new file mode 100644 index 0000000000000000000000000000000000000000..b9dd573a01019afd1af58a881996930e5212699d Binary files /dev/null and b/doc/img/logo.png differ diff --git a/doc/implementation.rst b/doc/implementation.rst new file mode 100644 index 0000000000000000000000000000000000000000..db822095c52a01bd2d2e381ba78ee96b86b65f66 --- /dev/null +++ b/doc/implementation.rst @@ -0,0 +1,10 @@ + +====================== +Implementation Details +====================== + +.. todo:: + Document the details of the GMM-based algorithms. + + +.. include:: links.rst diff --git a/doc/implemented.rst b/doc/implemented.rst new file mode 100644 index 0000000000000000000000000000000000000000..c280808ffc505694236d6eb51776d12719c68d01 --- /dev/null +++ b/doc/implemented.rst @@ -0,0 +1,22 @@ + +.. _bob.bio.gmm.implemented: + +================================ +Tools implemented in bob.bio.gmm +================================ + +Summary +------- + +.. autosummary:: + + bob.bio.gmm.algorithm.GMM + bob.bio.gmm.algorithm.ISV + bob.bio.gmm.algorithm.JFA + bob.bio.gmm.algorithm.IVector + + +Details +------- + +.. automodule:: bob.bio.gmm.algorithm diff --git a/doc/index.rst b/doc/index.rst index 89ddf3d24f6ecc1e12499e3457a5cc15230ac131..14cd5e256ff443de6cd4e4d3be1689abb0cfe514 100644 --- a/doc/index.rst +++ b/doc/index.rst @@ -4,17 +4,57 @@ .. _bob.bio.gmm: -==================================================== - Biometric Recognition with Gaussian Mixture Models -==================================================== +========================================= + Gaussian Mixture Model based Algorithms +========================================= +This package is part of the ``bob.bio`` packages, which provide open source tools to run comparable and reproducible biometric recognition experiments. +In this package, algorithms for executing experiments based on Gaussian Mixture Models are provided, including scripts to run the training procedures of the Expectation-Maximization loops in parallel. -Package Documentation ---------------------- +For more detailed information about the structure of the ``bob.bio`` packages, please refer to the documentation of :ref:`bob.bio.base <bob.bio.base>`. +Particularly, the installation of this and other ``bob.bio`` packages, please read the :ref:`bob.bio.base.installation`. -.. automodule:: bob.bio.gmm +In the following, we provide more detailed information about the particularities of this package only. -Databases ---------- +=========== +Users Guide +=========== -.. automodule:: bob.bio.gmm.database +.. toctree:: + :maxdepth: 2 + + implementation + parallel + +================ +Reference Manual +================ + +.. toctree:: + :maxdepth: 2 + + implemented + py_api + + +.. include:: references.rst + +========= +ToDo-List +========= + +This documentation is still under development. +Here is a list of things that needs to be done: + +.. todolist:: + + +================== +Indices and tables +================== + +* :ref:`genindex` +* :ref:`modindex` +* :ref:`search` + +.. include:: links.rst diff --git a/doc/links.rst b/doc/links.rst new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/doc/parallel.rst b/doc/parallel.rst new file mode 100644 index 0000000000000000000000000000000000000000..b459625062b475c9369ad1fdf5a873761c6077e4 --- /dev/null +++ b/doc/parallel.rst @@ -0,0 +1,18 @@ + + + +================================== +Executing the Training in Parallel +================================== + +Sometimes the training of the GMM-based models require a lot of time. +However, the training procedures can be parallelized, i.e., by running the E-steps of the EM loop in parallel. +For this purpose, we provide a set of scripts ``./bin/verify_gmm.py``, ``./bin/verify_isv.py`` and ``./bin/verify_ivector.py``. +These scripts integrate perfectly into the ``bob.bio`` packages. +Particularly, they have exactly the same set of options as documented in :ref:`bob.bio.base.experiments`. + +In fact, the scripts above only run in parallelized mode, i.e., the ``--grid`` option is required. +During the submission of the jobs, several hundred jobs might be created (depending on the ``number_of_..._training_iterations`` that you specify in the :py:class:`bob.bio.gmm.algorithms.GMM` constructor). +However, after the training has finished, it is possible to use the normal ``./bin/verify.py`` script to run similar experiments, e.g., if you want to change the protocol of your experiment. + +.. todo:: improve the documentation of the parallelized scripts. diff --git a/doc/py_api.rst b/doc/py_api.rst new file mode 100644 index 0000000000000000000000000000000000000000..ab3fd2bffbbd36a0881dc155439854091561e8f5 --- /dev/null +++ b/doc/py_api.rst @@ -0,0 +1,72 @@ + +========================== +Python API for bob.bio.gmm +========================== + +.. todo:: Improve documentation of the functions and classes of bob.bio.gmm. + +Generic functions +----------------- + +Miscellaneous functions +~~~~~~~~~~~~~~~~~~~~~~~ + +.. autosummary:: + bob.bio.base.get_config + + +Tools to run recognition experiments +------------------------------------ + +Command line generation +~~~~~~~~~~~~~~~~~~~~~~~ + +.. autosummary:: + bob.bio.gmm.tools.add_parallel_gmm_options + bob.bio.gmm.tools.initialize_parallel_gmm + bob.bio.gmm.tools.add_jobs + +Parallel GMM +~~~~~~~~~~~~ + +.. autosummary:: + bob.bio.gmm.tools.kmeans_initialize + bob.bio.gmm.tools.kmeans_estep + bob.bio.gmm.tools.kmeans_mstep + bob.bio.gmm.tools.gmm_initialize + bob.bio.gmm.tools.gmm_estep + bob.bio.gmm.tools.gmm_mstep + bob.bio.gmm.tools.gmm_project + +Parallel ISV +~~~~~~~~~~~~ + +.. autosummary:: + bob.bio.gmm.tools.train_isv + +Parallel I-Vector +~~~~~~~~~~~~~~~~~ + +.. autosummary:: + bob.bio.gmm.tools.ivector_estep + bob.bio.gmm.tools.ivector_mstep + bob.bio.gmm.tools.ivector_project + bob.bio.gmm.tools.train_whitener + + +Integration with bob.bio.video +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. autosummary:: + bob.bio.gmm.tools.is_video_extension + bob.bio.gmm.tools.base + bob.bio.gmm.tools.read_feature + + +Details +------- + +.. automodule:: bob.bio.gmm.tools + + +.. include:: links.rst diff --git a/doc/references.rst b/doc/references.rst new file mode 100644 index 0000000000000000000000000000000000000000..4e765ccc9b1e7110d13cf567d64097d42103831f --- /dev/null +++ b/doc/references.rst @@ -0,0 +1,5 @@ +========== +References +========== + +.. todo:: Provide the correct references for the algorithms defined in this package.