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

Corrected gabor_graph test.

parent 35c8f87c
No related branches found
No related tags found
No related merge requests found
......@@ -10,4 +10,5 @@ bob.example.faceverify.egg-info/
src/
bin/
dist/
Database
sphinx/
Database/
......@@ -72,6 +72,9 @@ def extract_feature(image, graph_machine):
return gabor_graph
# define a certain Gabor jet similarity function that should be used
SIMILARITY_FUNCTION = bob.machine.GaborJetSimilarity(bob.machine.gabor_jet_similarity_type.CANBERRA)
def main():
"""This function will perform Gabor graph comparison test on the AT&T database"""
......@@ -98,7 +101,7 @@ def main():
# for Gabor graphs, no training is required.
print "Creating Gabor graph machine"
# create a machine that will produce tight Gabor graphs with inter-node distance (1,1)
# create a machine that will produce tight Gabor graphs with inter-node distance (4,4)
graph_machine = bob.machine.GaborGraphMachine((8,6), (104,86), (4,4))
#####################################################################
......@@ -123,8 +126,6 @@ def main():
negative_scores = []
print "Computing scores"
# define a certain Gabor jet similarity function that should be used
similarity_function = bob.machine.GaborJetSimilarity(bob.machine.gabor_jet_similarity_type.CANBERRA)
# iterate through models and probes and compute scores
model_count = 1
......@@ -134,7 +135,7 @@ def main():
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)
score = graph_machine.similarity(model_feature, probe_feature, SIMILARITY_FUNCTION)
# check if this is a positive score
if atnt_db.get_client_id_from_file_id(model_key) == atnt_db.get_client_id_from_file_id(probe_key):
......
......@@ -96,10 +96,10 @@ class FaceVerifyExampleTest(unittest.TestCase):
self.assertAlmostEqual(score, 3498.308154114)
def test02_gabor_phase(self):
def test02_gabor_graph(self):
# test the gabor phase algorithm
try:
from faceverify.gabor_phase import load_images, extract_feature, ATNT_IMAGE_DIRECTORY
from faceverify.gabor_graph import load_images, extract_feature, ATNT_IMAGE_DIRECTORY, SIMILARITY_FUNCTION
except ImportError as e:
raise SkipTest("Skipping the tests since importing from faceverify.gabor_phase raised exception '%s'"%e)
......@@ -113,11 +113,11 @@ class FaceVerifyExampleTest(unittest.TestCase):
self.assertEqual(len(images), 200)
# extract features; for test purposes we wil use smaller features with inter-node-distance 8
graph = bob.machine.GaborGraphMachine((0,0), (111,91), (8,8))
graph_machine = bob.machine.GaborGraphMachine((0,0), (111,91), (8,8))
# check the the projection is the same
model = extract_feature(images[1], graph)
probe = extract_feature(images[2], graph)
model = extract_feature(images[1], graph_machine)
probe = extract_feature(images[2], graph_machine)
if regenerate_references:
bob.io.save(model, self.resource('gabor_model.hdf5'))
......@@ -130,9 +130,8 @@ class FaceVerifyExampleTest(unittest.TestCase):
self.assertTrue(numpy.allclose(probe_ref, probe))
# compute score
similarity_function = bob.machine.GaborJetSimilarity(bob.machine.gabor_jet_similarity_type.PHASE_DIFF)
score = graph.similarity(model, probe, similarity_function)
self.assertAlmostEqual(score, 0.110043015)
score = graph_machine.similarity(model, probe, SIMILARITY_FUNCTION)
self.assertAlmostEqual(score, 0.66058309)
def test03_dct_ubm(self):
......
No preview for this file type
No preview for this file type
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment