Skip to content
Snippets Groups Projects
Commit b2af052c authored by Manuel Günther's avatar Manuel Günther
Browse files

Corrected bug in DCT_UBM toolchain; added --help option; added source file headers.

parent 1ad53869
No related branches found
No related tags found
No related merge requests found
#!/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/>.
#!/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
......
#!/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
......
#!/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)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment