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

Added configurations for preprocessors including landmark detection

parent 28e42c8b
No related branches found
No related tags found
No related merge requests found
......@@ -4,6 +4,10 @@ preprocessor = bob.bio.face.preprocessor.HistogramEqualization(
face_cropper = 'face-crop-eyes'
)
preprocessor_landmark = bob.bio.face.preprocessor.HistogramEqualization(
face_cropper = 'landmark-detect'
)
preprocessor_no_crop = bob.bio.face.preprocessor.HistogramEqualization(
face_cropper = None
)
......@@ -6,6 +6,11 @@ preprocessor = bob.bio.face.preprocessor.INormLBP(
dtype = numpy.float64
)
preprocessor_landmark = bob.bio.face.preprocessor.INormLBP(
face_cropper = 'landmark-detect',
dtype = numpy.float64
)
preprocessor_no_crop = bob.bio.face.preprocessor.INormLBP(
face_cropper = None,
dtype = numpy.float64
......
......@@ -4,6 +4,10 @@ preprocessor = bob.bio.face.preprocessor.SelfQuotientImage(
face_cropper = 'face-crop-eyes'
)
preprocessor_landmark = bob.bio.face.preprocessor.SelfQuotientImage(
face_cropper = 'landmark-detect'
)
preprocessor_no_crop = bob.bio.face.preprocessor.SelfQuotientImage(
face_cropper = None
)
......@@ -4,6 +4,10 @@ preprocessor = bob.bio.face.preprocessor.TanTriggs(
face_cropper = 'face-crop-eyes'
)
preprocessor_landmark = bob.bio.face.preprocessor.TanTriggs(
face_cropper = 'landmark-detect'
)
preprocessor_no_crop = bob.bio.face.preprocessor.TanTriggs(
face_cropper = None
)
......@@ -11,6 +11,8 @@ from .Base import Base
from .utils import load_cropper_only
from bob.bio.base.preprocessor import Preprocessor
import logging
logger = logging.getLogger("bob.bio.face")
class FaceDetect (Base):
......@@ -75,7 +77,7 @@ class FaceDetect (Base):
'leye' : ((landmarks[2][0] + landmarks[6][0])/2., (landmarks[2][1] + landmarks[6][1])/2.)
}
else:
utils.warn("Could not detect landmarks -- using estimated landmarks")
logger.warn("Could not detect landmarks -- using estimated landmarks")
# estimate from default locations
return bob.ip.facedetect.expected_eye_positions(bounding_box)
......
......@@ -128,10 +128,15 @@ def test_tan_triggs():
_compare(preprocessor(image, annotation), pkg_resources.resource_filename('bob.bio.face.test', 'data/tan_triggs_cropped.hdf5'), preprocessor.write_data, preprocessor.read_data)
# test the preprocessor without cropping
preprocessor = bob.bio.face.preprocessor.TanTriggs(face_cropper=None)
preprocessor = bob.bio.base.load_resource('tan-triggs', 'preprocessor')
assert preprocessor.cropper is None
# result must be identical to the original face cropper (same eyes are used)
_compare(preprocessor(image, annotation), pkg_resources.resource_filename('bob.bio.face.test', 'data/tan_triggs_none.hdf5'), preprocessor.write_data, preprocessor.read_data)
preprocessor = bob.bio.base.load_resource('tan-triggs-landmark', 'preprocessor')
assert isinstance(preprocessor.cropper, bob.bio.face.preprocessor.FaceDetect)
assert preprocessor.cropper.flandmark is not None
def test_inorm_lbp():
# read input
......@@ -145,6 +150,13 @@ def test_inorm_lbp():
# execute preprocessor
_compare(preprocessor(image, annotation), pkg_resources.resource_filename('bob.bio.face.test', 'data/inorm_lbp_cropped.hdf5'), preprocessor.write_data, preprocessor.read_data)
# load the preprocessor without cropping
preprocessor = bob.bio.base.load_resource('inorm-lbp', 'preprocessor')
assert preprocessor.cropper is None
# load the preprocessor landmark detection
preprocessor = bob.bio.base.load_resource('inorm-lbp-landmark', 'preprocessor')
assert isinstance(preprocessor.cropper, bob.bio.face.preprocessor.FaceDetect)
def test_heq():
# read input
......@@ -158,6 +170,13 @@ def test_heq():
# execute preprocessor
_compare(preprocessor(image, annotation), pkg_resources.resource_filename('bob.bio.face.test', 'data/histogram_cropped.hdf5'), preprocessor.write_data, preprocessor.read_data)
# load the preprocessor without cropping
preprocessor = bob.bio.base.load_resource('histogram', 'preprocessor')
assert preprocessor.cropper is None
# load the preprocessor landmark detection
preprocessor = bob.bio.base.load_resource('histogram-landmark', 'preprocessor')
assert isinstance(preprocessor.cropper, bob.bio.face.preprocessor.FaceDetect)
def test_sqi():
# read input
......@@ -171,6 +190,13 @@ def test_sqi():
# execute preprocessor
_compare(preprocessor(image, annotation), pkg_resources.resource_filename('bob.bio.face.test', 'data/self_quotient_cropped.hdf5'), preprocessor.write_data, preprocessor.read_data)
# load the preprocessor without cropping
preprocessor = bob.bio.base.load_resource('self-quotient', 'preprocessor')
assert preprocessor.cropper is None
# load the preprocessor landmark detection
preprocessor = bob.bio.base.load_resource('self-quotient-landmark', 'preprocessor')
assert isinstance(preprocessor.cropper, bob.bio.face.preprocessor.FaceDetect)
"""
def test06a_key_points(self):
......
......@@ -122,24 +122,28 @@ setup(
'multipie-pose = bob.bio.face.config.database.multipie_pose:database',
'scface = bob.bio.face.config.database.scface:database',
'xm2vts = bob.bio.face.config.database.xm2vts:database',
],
'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
'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-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-landmark = bob.bio.face.config.preprocessor.inorm_lbp:preprocessor_landmark', # face detection + landmark detection + cropping + inorm-lbp
'tan-triggs-landmark = bob.bio.face.config.preprocessor.tan_triggs:preprocessor_landmark', # face detection + landmark detection + cropping + Tan&Triggs
'histogram-landmark = bob.bio.face.config.preprocessor.histogram_equalization:preprocessor_landmark', # face detection + landmark detection + cropping + histogram equalization
'self-quotient-landmark = bob.bio.face.config.preprocessor.self_quotient_image:preprocessor_landmark', # face detection + landmark detection + cropping + self quotient image
'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
],
'bob.bio.extractor': [
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment