Commit c8c06b23 authored by Manuel Günther's avatar Manuel Günther

Added baselines script; lots of small corrections

parent 337825c9
from . import preprocessor
from . import extractor
from . import algorithm
from . import script
from . import test
......
......@@ -105,7 +105,7 @@ class GaborJet (Algorithm):
return [[bob.ip.gabor.Jet(jets_per_node[n])] for n in range(len(jets_per_node))]
def save_model(self, model, model_file):
def write_model(self, model, model_file):
"""Saves the enrolled model of Gabor jets to file."""
f = bob.io.base.HDF5File(model_file, 'w')
# several model graphs
......
#!/usr/bin/env python
import bob.bio.base
import bob.ip.gabor
similarity_function = bob.ip.gabor.Similarity("PhaseDiffPlusCanberra", bob.ip.gabor.Transform())
def gabor_jet_similarities(f1, f2):
"""Computes the similarity vector between two Gabor graph features"""
assert len(f1) == len(f2)
return [similarity_function(f1[i], f2[i]) for i in range(len(f1))]
algorithm = bob.bio.base.algorithm.BIC(
# measure to compare two features in input space
comparison_function = gabor_jet_similarities,
# load and save functions
read_function = bob.ip.gabor.load_jets,
write_function = bob.ip.gabor.save_jets,
# Limit the number of training pairs
maximum_training_pair_count = 1000000,
# Dimensions of intrapersonal and extrapersonal subspaces
subspace_dimensions = (20, 20),
multiple_model_scoring = 'max'
)
......@@ -3,7 +3,7 @@
import bob.db.xm2vts
import bob.bio.base
xm2vts_directory = "[YOUR_XM2VTS_IMAGE_DIRECTORY]"
xm2vts_directory = "[YOUR_XM2VTS_DIRECTORY]"
# setup for XM2VTS
database = bob.bio.base.database.DatabaseBob(
......
#!/usr/bin/env python
import bob.bio.face
# Detects the face and eye landmarks crops it using the detected eyes
preprocessor = bob.bio.face.preprocessor.FaceDetect(
face_cropper = 'face-crop-eyes',
use_flandmark = True
)
# Detects the face amd crops it without eye detection
preprocessor_no_eyes = bob.bio.face.preprocessor.FaceDetect(
face_cropper = 'face-crop-eyes',
use_flandmark = False
)
#!/usr/bin/env python
import bob.bio.face
preprocessor = bob.bio.face.preprocessor.FaceDetect(
face_cropper = 'face-crop-eyes'
)
......@@ -3,3 +3,7 @@ import bob.bio.face
preprocessor = bob.bio.face.preprocessor.HistogramEqualization(
face_cropper = 'face-crop-eyes'
)
preprocessor_no_crop = bob.bio.face.preprocessor.HistogramEqualization(
face_cropper = None
)
import bob.bio.face
import numpy
preprocessor = bob.bio.face.preprocessor.INormLBP(
face_cropper = 'face-crop-eyes',
dtype = numpy.float64
)
preprocessor_no_crop = bob.bio.face.preprocessor.INormLBP(
face_cropper = None,
dtype = numpy.float64
)
import bob.bio.face
preprocessor = bob.bio.face.preprocessor.INormLBP(
face_cropper = 'face-crop-eyes'
)
......@@ -3,3 +3,7 @@ import bob.bio.face
preprocessor = bob.bio.face.preprocessor.SelfQuotientImage(
face_cropper = 'face-crop-eyes'
)
preprocessor_no_crop = bob.bio.face.preprocessor.SelfQuotientImage(
face_cropper = None
)
......@@ -3,3 +3,7 @@ import bob.bio.face
preprocessor = bob.bio.face.preprocessor.TanTriggs(
face_cropper = 'face-crop-eyes'
)
preprocessor_no_crop = bob.bio.face.preprocessor.TanTriggs(
face_cropper = None
)
This diff is collapsed.
......@@ -30,6 +30,7 @@ regenerate_refs = False
import bob.bio.base
import bob.bio.face
import bob.db.verification.utils
def _compare(data, reference, write_function = bob.bio.base.save, read_function = bob.bio.base.load):
......@@ -86,10 +87,11 @@ def test_face_crop():
def test_face_detect():
image, annotation = _image(), None
cropper = bob.bio.base.load_resource('face-detect-eyes', 'preprocessor')
cropper = bob.bio.base.load_resource('face-detect', 'preprocessor')
assert isinstance(cropper, bob.bio.face.preprocessor.FaceDetect)
assert isinstance(cropper, bob.bio.face.preprocessor.Base)
assert isinstance(cropper, bob.bio.base.preprocessor.Preprocessor)
assert cropper.flandmark is None
# execute face detector
reference = pkg_resources.resource_filename('bob.bio.face.test', 'data/detected.hdf5')
......@@ -103,11 +105,11 @@ def test_face_detect():
assert abs(cropper.quality - 33.1136586) < 1e-5
# execute face detector with tan-triggs
cropper = bob.bio.face.preprocessor.TanTriggs(face_cropper='face-detect-eyes')
cropper = bob.bio.face.preprocessor.TanTriggs(face_cropper='landmark-detect')
preprocessed = cropper(image, annotation)
# load reference and perform Tan-Triggs
detected = bob.bio.base.load(pkg_resources.resource_filename('bob.bio.face.test', 'data/detected.hdf5'))
tan_triggs = bob.bio.face.preprocessor.TanTriggs(face_cropper=None)
detected = bob.bio.base.load(pkg_resources.resource_filename('bob.bio.face.test', 'data/flandmark.hdf5'))
tan_triggs = bob.bio.base.load_resource('tan-triggs', 'preprocessor')
reference = tan_triggs(detected)
assert numpy.allclose(preprocessed, reference, atol=1e-5)
......@@ -116,7 +118,7 @@ def test_tan_triggs():
# read input
image, annotation = _image(), _annotation()
preprocessor = bob.bio.base.load_resource('tan-triggs-eyes', 'preprocessor')
preprocessor = bob.bio.base.load_resource('tan-triggs-crop', 'preprocessor')
assert isinstance(preprocessor, bob.bio.face.preprocessor.TanTriggs)
assert isinstance(preprocessor, bob.bio.face.preprocessor.Base)
assert isinstance(preprocessor, bob.bio.base.preprocessor.Preprocessor)
......@@ -135,7 +137,7 @@ def test_inorm_lbp():
# read input
image, annotation = _image(), _annotation()
preprocessor = bob.bio.base.load_resource('inorm-lbp-eyes', 'preprocessor')
preprocessor = bob.bio.base.load_resource('inorm-lbp-crop', 'preprocessor')
assert isinstance(preprocessor, bob.bio.face.preprocessor.INormLBP)
assert isinstance(preprocessor, bob.bio.face.preprocessor.Base)
assert isinstance(preprocessor, bob.bio.base.preprocessor.Preprocessor)
......@@ -148,7 +150,7 @@ def test_heq():
# read input
image, annotation = _image(), _annotation()
preprocessor = bob.bio.base.load_resource('histogram-eyes', 'preprocessor')
preprocessor = bob.bio.base.load_resource('histogram-crop', 'preprocessor')
assert isinstance(preprocessor, bob.bio.face.preprocessor.HistogramEqualization)
assert isinstance(preprocessor, bob.bio.face.preprocessor.Base)
assert isinstance(preprocessor, bob.bio.base.preprocessor.Preprocessor)
......@@ -161,7 +163,7 @@ def test_sqi():
# read input
image, annotation = _image(), _annotation()
preprocessor = bob.bio.base.load_resource('self-quotient-eyes', 'preprocessor')
preprocessor = bob.bio.base.load_resource('self-quotient-crop', 'preprocessor')
assert isinstance(preprocessor, bob.bio.face.preprocessor.SelfQuotientImage)
assert isinstance(preprocessor, bob.bio.face.preprocessor.Base)
assert isinstance(preprocessor, bob.bio.base.preprocessor.Preprocessor)
......
import bob.bio.base.test.utils
import bob.bio.face
@bob.bio.base.test.utils.grid_available
def test_baselines():
# test that all of the baselines would execute
from bob.bio.face.script.baselines import available_databases, all_algorithms, main
for database in available_databases:
parameters = ['-d', database, '--dry-run', '-vv']
main(parameters)
parameters.append('--grid')
main(parameters)
parameters.extend(['-e', 'HTER'])
main(parameters)
for algorithm in all_algorithms:
parameters = ['-a', algorithm, '--dry-run', '-vv']
main(parameters)
parameters.append('-g')
main(parameters)
parameters.extend(['-e', 'HTER'])
main(parameters)
......@@ -5,6 +5,7 @@
[buildout]
parts = scripts
eggs = bob.bio.face
bob.bio.gmm
bob.db.arface
bob.db.banca
bob.db.caspeal
......@@ -40,6 +41,7 @@ develop = src/bob.extension
src/bob.db.verification.filelist
src/bob.db.atnt
src/bob.bio.base
src/bob.bio.gmm
src/bob.learn.boosting
src/bob.ip.facedetect
src/bob.ip.flandmark
......@@ -81,6 +83,7 @@ bob.db.verification.utils = git https://github.com/bioidiap/bob.db.verification.
bob.db.verification.filelist = git https://github.com/bioidiap/bob.db.verification.filelist
bob.db.atnt = git https://github.com/bioidiap/bob.db.atnt
bob.bio.base = git https://github.com/bioidiap/bob.bio.base
bob.bio.gmm = git https://github.com/bioidiap/bob.bio.gmm
bob.learn.boosting = git https://github.com/bioidiap/bob.learn.boosting
bob.ip.facedetect = git https://github.com/bioidiap/bob.ip.facedetect
bob.ip.flandmark = git https://github.com/bioidiap/bob.ip.flandmark
......
......@@ -33,10 +33,10 @@
# allows you to test your package with new python dependencies w/o requiring
# administrative interventions.
from setuptools import setup, find_packages, dist
from setuptools import setup, dist
dist.Distribution(dict(setup_requires=['bob.extension']))
from bob.extension.utils import load_requirements
from bob.extension.utils import load_requirements, find_packages
install_requires = load_requirements()
# The only thing we do in this file is to call the setup() function with all
......@@ -103,6 +103,7 @@ setup(
# scripts should be declared using this entry:
'console_scripts' : [
'baselines.py = bob.bio.face.script.baselines:main'
],
'bob.bio.database': [
......@@ -127,12 +128,18 @@ setup(
'bob.bio.preprocessor': [
'base = bob.bio.face.config.preprocessor.base:preprocessor', # simple color conversion
'face-crop-eyes = bob.bio.face.config.preprocessor.face_crop_eyes:preprocessor', # face crop
'inorm-lbp-eyes = bob.bio.face.config.preprocessor.inorm_lbp_eyes:preprocessor', # face crop + inorm-lbp
'tan-triggs-eyes = bob.bio.face.config.preprocessor.tan_triggs_eyes:preprocessor', # face crop + inorm-lbp
'histogram-eyes = bob.bio.face.config.preprocessor.histogram_equalization_eyes:preprocessor', # face crop + inorm-lbp
'self-quotient-eyes= bob.bio.face.config.preprocessor.self_quotient_image_eyes:preprocessor', # face crop + inorm-lbp
'inorm-lbp-crop = bob.bio.face.config.preprocessor.inorm_lbp:preprocessor', # face crop + inorm-lbp
'tan-triggs-crop = bob.bio.face.config.preprocessor.tan_triggs:preprocessor', # face crop + Tan&Triggs
'histogram-crop = bob.bio.face.config.preprocessor.histogram_equalization:preprocessor', # face crop + histogram equalization
'self-quotient-crop= bob.bio.face.config.preprocessor.self_quotient_image:preprocessor', # face crop + self quotient image
'landmark-detect = bob.bio.face.config.preprocessor.face_detect:preprocessor', # face detection + landmark detection + cropping
'face-detect = bob.bio.face.config.preprocessor.face_detect:preprocessor_no_eyes', # face detection + cropping
'inorm-lbp = bob.bio.face.config.preprocessor.inorm_lbp:preprocessor_no_crop', # inorm-lbp w/o face-crop
'tan-triggs = bob.bio.face.config.preprocessor.tan_triggs:preprocessor_no_crop', # Tan&Triggs w/o face-crop
'histogram = bob.bio.face.config.preprocessor.histogram_equalization:preprocessor_no_crop', # histogram equalization w/o face-crop
'self-quotient = bob.bio.face.config.preprocessor.self_quotient_image:preprocessor_no_crop', # self quotient image w/o face-crop
'face-detect-eyes = bob.bio.face.config.preprocessor.face_detect_eyes:preprocessor', # face detection + cropping
],
'bob.bio.extractor': [
......@@ -145,6 +152,7 @@ setup(
'bob.bio.algorithm': [
'gabor-jet = bob.bio.face.config.algorithm.gabor_jet:algorithm', # Gabor jet comparison
'lgbphs = bob.bio.face.config.algorithm.lgbphs:algorithm', # LGBPHS histograms
'bic-jets = bob.bio.face.config.algorithm.bic_jets:algorithm', # BIC on gabor jets
],
},
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment