diff --git a/faceverify/__init__.py b/faceverify/__init__.py index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..b54037ae4831cf7de2db0edd721a8add684c986e 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 36389844fde97eb2f50df7fc78e86d44404d3395..fcc07347c92f36761abff8e0c2b41159451b52a5 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 ae210cf893b11c2f0443fdaa30977918a7838da0..6693570fb23503ff1e2988823cc3b988d3e52b6b 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 eddbdc527e17539db340e16fb8b33fbd11a1f4dc..fbc150718df25c07fa572e713a7ee82f30f706b3 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)