From b2af052ce530b2037e6dba1ca899691836496f8e Mon Sep 17 00:00:00 2001 From: Manuel Guenther <manuel.guenther@idiap.ch> Date: Wed, 1 May 2013 11:46:20 +0200 Subject: [PATCH] Corrected bug in DCT_UBM toolchain; added --help option; added source file headers. --- faceverify/__init__.py | 20 ++++++++++++++++++++ faceverify/dct_ubm.py | 30 +++++++++++++++++++++++++++--- faceverify/eigenface.py | 25 ++++++++++++++++++++++++- faceverify/gabor_phase.py | 30 +++++++++++++++++++++++++++++- 4 files changed, 100 insertions(+), 5 deletions(-) diff --git a/faceverify/__init__.py b/faceverify/__init__.py index e69de29..b54037a 100644 --- a/faceverify/__init__.py +++ b/faceverify/__init__.py @@ -0,0 +1,20 @@ +#!/usr/bin/env python +# vim: set fileencoding=utf-8 : +# @author: Manuel Guenther <Manuel.Guenther@idiap.ch> +# @date: Wed May 1 11:33:00 CEST 2013 +# +# Copyright (C) 2011-2013 Idiap Research Institute, Martigny, Switzerland +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, version 3 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + + diff --git a/faceverify/dct_ubm.py b/faceverify/dct_ubm.py index 3638984..fcc0734 100644 --- a/faceverify/dct_ubm.py +++ b/faceverify/dct_ubm.py @@ -1,3 +1,23 @@ +#!/usr/bin/env python +# vim: set fileencoding=utf-8 : +# @author: Manuel Guenther <Manuel.Guenther@idiap.ch> +# @date: Wed May 1 11:33:00 CEST 2013 +# +# Copyright (C) 2011-2013 Idiap Research Institute, Martigny, Switzerland +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, version 3 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + + import bob import xbob.db.atnt import os, sys @@ -16,7 +36,7 @@ ATNT_IMAGE_EXTENSION = ".pgm" def load_images(db, group = None, purpose = None, client_id = None): """Reads the images for the given group and the given client id from the given database""" # get the file names from the database - files = db.objects(groups = group, purposes = purpose) + files = db.objects(groups = group, purposes = purpose, model_ids = client_id) # iterate through the list of file names images = {} for k in files: @@ -121,6 +141,10 @@ def main(): # check if the AT&T database directory is overwritten by the command line global ATNT_IMAGE_DIRECTORY if len(sys.argv) > 1: + if sys.argv[1].lower() in ('-h', '--help'): + print "Usage:", sys.argv[0], "[DatabaseDirectory]" + print " NOTE: DatabaseDirectory defaults to the './Database' or to the environment variable 'ATNT_DATABASE_DIRECTORY', if set" + return ATNT_IMAGE_DIRECTORY = sys.argv[1] # check if the database directory exists @@ -148,8 +172,8 @@ def main(): gmm_trainer.max_iterations = 1 gmm_trainer.set_prior_gmm(ubm) - # create a GMM model for each model identity - model_ids = atnt_db.clients(groups = 'dev') + # enroll a GMM model for each model identity (i.e., each client) + model_ids = [client.id for client in atnt_db.clients(groups = 'dev')] models = {} for model_id in model_ids: # load images for the current model id diff --git a/faceverify/eigenface.py b/faceverify/eigenface.py index ae210cf..6693570 100644 --- a/faceverify/eigenface.py +++ b/faceverify/eigenface.py @@ -1,3 +1,23 @@ +#!/usr/bin/env python +# vim: set fileencoding=utf-8 : +# @author: Manuel Guenther <Manuel.Guenther@idiap.ch> +# @date: Wed May 1 11:33:00 CEST 2013 +# +# Copyright (C) 2011-2013 Idiap Research Institute, Martigny, Switzerland +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, version 3 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + + import bob import xbob.db.atnt import os, sys @@ -9,7 +29,6 @@ from matplotlib import pyplot global ATNT_IMAGE_DIRECTORY ATNT_IMAGE_DIRECTORY = os.environ['ATNT_DATABASE_DIRECTORY'] if 'ATNT_DATABASE_DIRECTORY' in os.environ else "Database" - # The default file name extension of the AT&T images ATNT_IMAGE_EXTENSION = ".pgm" @@ -68,6 +87,10 @@ def main(): # check if the AT&T database directory is overwritten by the command line global ATNT_IMAGE_DIRECTORY if len(sys.argv) > 1: + if sys.argv[1].lower() in ('-h', '--help'): + print "Usage:", sys.argv[0], "[DatabaseDirectory]" + print " NOTE: DatabaseDirectory defaults to the './Database' or to the environment variable 'ATNT_DATABASE_DIRECTORY', if set" + return ATNT_IMAGE_DIRECTORY = sys.argv[1] # check if the database directory exists diff --git a/faceverify/gabor_phase.py b/faceverify/gabor_phase.py index eddbdc5..fbc1507 100644 --- a/faceverify/gabor_phase.py +++ b/faceverify/gabor_phase.py @@ -1,3 +1,23 @@ +#!/usr/bin/env python +# vim: set fileencoding=utf-8 : +# @author: Manuel Guenther <Manuel.Guenther@idiap.ch> +# @date: Wed May 1 11:33:00 CEST 2013 +# +# Copyright (C) 2011-2013 Idiap Research Institute, Martigny, Switzerland +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, version 3 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + + import bob import xbob.db.atnt import os, sys @@ -58,6 +78,10 @@ def main(): # check if the AT&T database directory is overwritten by the command line global ATNT_IMAGE_DIRECTORY if len(sys.argv) > 1: + if sys.argv[1].lower() in ('-h', '--help'): + print "Usage:", sys.argv[0], "[DatabaseDirectory]" + print " NOTE: DatabaseDirectory defaults to the './Database' or to the environment variable 'ATNT_DATABASE_DIRECTORY', if set" + return ATNT_IMAGE_DIRECTORY = sys.argv[1] # check if the database directory exists @@ -100,7 +124,11 @@ def main(): similarity_function = bob.machine.GaborJetSimilarity(bob.machine.gabor_jet_similarity_type.PHASE_DIFF) # iterate through models and probes and compute scores + model_count = 1 for model_key, model_feature in model_features.iteritems(): + print "\rModel", model_count, "of", len(model_features), + sys.stdout.flush() + model_count += 1 for probe_key, probe_feature in probe_features.iteritems(): # compute score using the desired Gabor jet similarity function score = graph_machine.similarity(model_feature, probe_feature, similarity_function) @@ -111,7 +139,7 @@ def main(): else: negative_scores.append(score) - print "Evaluation" + print "\nEvaluation" # convert list of scores to numpy arrays positives = numpy.array(positive_scores) negatives = numpy.array(negative_scores) -- GitLab