Commit 5882bc98 authored by Manuel Günther's avatar Manuel Günther
Browse files

Added and corrected preferred_package option to bob.bio.base.load_resource calls

parent c9352210
......@@ -34,7 +34,7 @@ seed_value = 5489
def test_gabor_jet():
jets = bob.bio.base.load_resource("gabor-jet", "algorithm")
jets = bob.bio.base.load_resource("gabor-jet", "algorithm", preferred_package='bob.bio.face')
assert isinstance(jets, bob.bio.face.algorithm.GaborJet)
assert isinstance(jets, bob.bio.base.algorithm.Algorithm)
assert not jets.performs_projection
......@@ -78,7 +78,7 @@ def test_gabor_jet():
def test_histogram():
histogram = bob.bio.base.load_resource("histogram", "algorithm")
histogram = bob.bio.base.load_resource("histogram", "algorithm", preferred_package='bob.bio.face')
assert isinstance(histogram, bob.bio.face.algorithm.Histogram)
assert isinstance(histogram, bob.bio.base.algorithm.Algorithm)
assert not histogram.performs_projection
......@@ -114,7 +114,7 @@ def test_histogram():
def test_bic_jets():
bic = bob.bio.base.load_resource("bic-jets", "algorithm")
bic = bob.bio.base.load_resource("bic-jets", "algorithm", preferred_package='bob.bio.face')
assert isinstance(bic, bob.bio.base.algorithm.BIC)
assert isinstance(bic, bob.bio.base.algorithm.Algorithm)
......
......@@ -69,7 +69,7 @@ def _check_annotations(database):
@db_available('arface')
def test_arface():
database = bob.bio.base.load_resource('arface', 'database', preferred_extension='bob.bio.face')
database = bob.bio.base.load_resource('arface', 'database', preferred_package='bob.bio.face')
try:
_check_database(database, groups=('dev', 'eval'))
_check_annotations(database)
......@@ -78,12 +78,12 @@ def test_arface():
def test_atnt():
_check_database(bob.bio.base.load_resource('atnt', 'database', preferred_extension='bob.bio.face'))
_check_database(bob.bio.base.load_resource('atnt', 'database', preferred_package='bob.bio.face'))
@db_available('banca')
def test_banca():
database = bob.bio.base.load_resource('banca', 'database', preferred_extension='bob.bio.face')
database = bob.bio.base.load_resource('banca', 'database', preferred_package='bob.bio.face')
try:
_check_database_zt(database)
_check_annotations(database)
......@@ -93,7 +93,7 @@ def test_banca():
@db_available('caspeal')
def test_caspeal():
database = bob.bio.base.load_resource('caspeal', 'database', preferred_extension='bob.bio.face')
database = bob.bio.base.load_resource('caspeal', 'database', preferred_package='bob.bio.face')
try:
_check_database(database)
_check_database(database, protocol = 'aging')
......@@ -105,7 +105,7 @@ def test_caspeal():
@db_available('frgc')
def test_frgc():
import xml.sax
database = bob.bio.base.load_resource('frgc', 'database', preferred_extension='bob.bio.face')
database = bob.bio.base.load_resource('frgc', 'database', preferred_package='bob.bio.face')
try:
_check_database(database, models_depend = True)
_check_database(database, protocol = '2.0.2', models_depend = True)
......@@ -116,7 +116,7 @@ def test_frgc():
@db_available('gbu')
def test_gbu():
database = bob.bio.base.load_resource('gbu', 'database', preferred_extension='bob.bio.face')
database = bob.bio.base.load_resource('gbu', 'database', preferred_package='bob.bio.face')
try:
_check_database(database, models_depend=True)
_check_database(database, protocol = 'Bad', models_depend=True)
......@@ -128,11 +128,11 @@ def test_gbu():
@db_available('lfw')
def test_lfw():
database = bob.bio.base.load_resource('lfw-restricted', 'database', preferred_extension='bob.bio.face')
database = bob.bio.base.load_resource('lfw-restricted', 'database', preferred_package='bob.bio.face')
try:
_check_database(database, training_depends = True, models_depend = True)
_check_database(database, groups = ('dev', 'eval'), protocol = 'fold1', training_depends = True, models_depend = True)
_check_database(bob.bio.base.load_resource('lfw-unrestricted', 'database', preferred_extension='bob.bio.face'), training_depends = True, models_depend = True)
_check_database(bob.bio.base.load_resource('lfw-unrestricted', 'database', preferred_package='bob.bio.face'), training_depends = True, models_depend = True)
_check_annotations(database)
except IOError as e:
raise SkipTest("The database could not queried; probably the db.sql3 file is missing. Here is the error: '%s'" % e)
......@@ -140,12 +140,12 @@ def test_lfw():
@db_available('mobio')
def test_mobio():
database = bob.bio.base.load_resource('mobio-image', 'database', preferred_extension='bob.bio.face')
database = bob.bio.base.load_resource('mobio-image', 'database', preferred_package='bob.bio.face')
try:
_check_database_zt(database, models_depend=True)
_check_database_zt(database, protocol = 'female', models_depend=True)
_check_database_zt(bob.bio.base.load_resource('mobio-male', 'database', preferred_extension='bob.bio.face'), models_depend=True)
_check_database_zt(bob.bio.base.load_resource('mobio-female', 'database', preferred_extension='bob.bio.face'), models_depend=True)
_check_database_zt(bob.bio.base.load_resource('mobio-male', 'database', preferred_package='bob.bio.face'), models_depend=True)
_check_database_zt(bob.bio.base.load_resource('mobio-female', 'database', preferred_package='bob.bio.face'), models_depend=True)
except IOError as e:
raise SkipTest("The database could not be queried; probably the db.sql3 file is missing. Here is the error: '%s'" % e)
......@@ -157,10 +157,10 @@ def test_mobio():
@db_available('multipie')
def test_multipie():
database = bob.bio.base.load_resource('multipie', 'database', preferred_extension='bob.bio.face')
database = bob.bio.base.load_resource('multipie', 'database', preferred_package='bob.bio.face')
try:
_check_database_zt(database, training_depends = True)
_check_database_zt(bob.bio.base.load_resource('multipie-pose', 'database', preferred_extension='bob.bio.face'), training_depends = True)
_check_database_zt(bob.bio.base.load_resource('multipie-pose', 'database', preferred_package='bob.bio.face'), training_depends = True)
except IOError as e:
raise SkipTest("The database could not queried; probably the db.sql3 file is missing. Here is the error: '%s'" % e)
except ValueError as e:
......@@ -174,7 +174,7 @@ def test_multipie():
@db_available('scface')
def test_scface():
database = bob.bio.base.load_resource('scface', 'database', preferred_extension='bob.bio.face')
database = bob.bio.base.load_resource('scface', 'database', preferred_package='bob.bio.face')
try:
_check_database_zt(database)
_check_annotations(database)
......@@ -184,7 +184,7 @@ def test_scface():
@db_available('xm2vts')
def test_xm2vts():
database = bob.bio.base.load_resource('xm2vts', 'database', preferred_extension='bob.bio.face')
database = bob.bio.base.load_resource('xm2vts', 'database', preferred_package='bob.bio.face')
try:
_check_database(database, groups=('dev', 'eval'))
_check_database(database, groups=('dev', 'eval'), protocol = 'darkened-lp1')
......
......@@ -49,7 +49,7 @@ def _data():
def test_dct_blocks():
# read input
data = _data()
dct = bob.bio.base.load_resource('dct-blocks', 'extractor')
dct = bob.bio.base.load_resource('dct-blocks', 'extractor', preferred_package='bob.bio.face')
assert isinstance(dct, bob.bio.face.extractor.DCTBlocks)
assert isinstance(dct, bob.bio.base.extractor.Extractor)
assert not dct.requires_training
......@@ -68,7 +68,7 @@ def test_dct_blocks():
def test_graphs():
data = _data()
graph = bob.bio.base.load_resource('grid-graph', 'extractor')
graph = bob.bio.base.load_resource('grid-graph', 'extractor', preferred_package='bob.bio.face')
assert isinstance(graph, bob.bio.face.extractor.GridGraph)
assert isinstance(graph, bob.bio.base.extractor.Extractor)
assert not graph.requires_training
......@@ -92,7 +92,7 @@ def test_graphs():
# get reference face graph extractor
cropper = bob.bio.base.load_resource('face-crop-eyes', 'preprocessor')
cropper = bob.bio.base.load_resource('face-crop-eyes', 'preprocessor', preferred_package='bob.bio.face')
eyes = cropper.cropped_positions
# generate aligned graph extractor
graph = bob.bio.face.extractor.GridGraph(
......@@ -115,7 +115,7 @@ def test_graphs():
def test_lgbphs():
data = _data()
lgbphs = bob.bio.base.load_resource('lgbphs', 'extractor')
lgbphs = bob.bio.base.load_resource('lgbphs', 'extractor', preferred_package='bob.bio.face')
assert isinstance(lgbphs, bob.bio.face.extractor.LGBPHS)
assert isinstance(lgbphs, bob.bio.base.extractor.Extractor)
assert not lgbphs.requires_training
......@@ -156,7 +156,7 @@ def test_lgbphs():
def test_eigenface():
temp_file = bob.io.base.test_utils.temporary_filename()
data = _data()
eigen1 = bob.bio.base.load_resource('eigenface', 'extractor')
eigen1 = bob.bio.base.load_resource('eigenface', 'extractor', preferred_package='bob.bio.face')
assert isinstance(eigen1, bob.bio.face.extractor.Eigenface)
assert isinstance(eigen1, bob.bio.base.extractor.Extractor)
assert eigen1.requires_training
......
......@@ -52,7 +52,7 @@ def _annotation():
def test_base():
base = bob.bio.base.load_resource('base', 'preprocessor')
base = bob.bio.base.load_resource('base', 'preprocessor', preferred_package='bob.bio.face')
assert isinstance(base, bob.bio.face.preprocessor.Base)
assert isinstance(base, bob.bio.base.preprocessor.Preprocessor)
......@@ -87,7 +87,7 @@ def test_face_crop():
# read input
image, annotation = _image(), _annotation()
cropper = bob.bio.base.load_resource('face-crop-eyes', 'preprocessor')
cropper = bob.bio.base.load_resource('face-crop-eyes', 'preprocessor', preferred_package='bob.bio.face')
assert isinstance(cropper, bob.bio.face.preprocessor.FaceCrop)
assert isinstance(cropper, bob.bio.face.preprocessor.Base)
assert isinstance(cropper, bob.bio.base.preprocessor.Preprocessor)
......@@ -116,7 +116,7 @@ def test_face_crop():
def test_face_detect():
image, annotation = _image(), None
cropper = bob.bio.base.load_resource('face-detect', 'preprocessor')
cropper = bob.bio.base.load_resource('face-detect', 'preprocessor', preferred_package='bob.bio.face')
assert isinstance(cropper, bob.bio.face.preprocessor.FaceDetect)
assert isinstance(cropper, bob.bio.face.preprocessor.Base)
assert isinstance(cropper, bob.bio.base.preprocessor.Preprocessor)
......@@ -138,7 +138,7 @@ def test_face_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/flandmark.hdf5'))
tan_triggs = bob.bio.base.load_resource('tan-triggs', 'preprocessor')
tan_triggs = bob.bio.base.load_resource('tan-triggs', 'preprocessor', preferred_package='bob.bio.face')
reference = tan_triggs(detected)
assert numpy.allclose(preprocessed, reference, atol=1e-5)
......@@ -147,7 +147,7 @@ def test_tan_triggs():
# read input
image, annotation = _image(), _annotation()
preprocessor = bob.bio.base.load_resource('tan-triggs-crop', 'preprocessor')
preprocessor = bob.bio.base.load_resource('tan-triggs-crop', 'preprocessor', preferred_package='bob.bio.face')
assert isinstance(preprocessor, bob.bio.face.preprocessor.TanTriggs)
assert isinstance(preprocessor, bob.bio.face.preprocessor.Base)
assert isinstance(preprocessor, bob.bio.base.preprocessor.Preprocessor)
......@@ -157,12 +157,12 @@ 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.base.load_resource('tan-triggs', 'preprocessor')
preprocessor = bob.bio.base.load_resource('tan-triggs', 'preprocessor', preferred_package='bob.bio.face')
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')
preprocessor = bob.bio.base.load_resource('tan-triggs-landmark', 'preprocessor', preferred_package='bob.bio.face')
assert isinstance(preprocessor.cropper, bob.bio.face.preprocessor.FaceDetect)
assert preprocessor.cropper.flandmark is not None
......@@ -171,7 +171,7 @@ def test_inorm_lbp():
# read input
image, annotation = _image(), _annotation()
preprocessor = bob.bio.base.load_resource('inorm-lbp-crop', 'preprocessor')
preprocessor = bob.bio.base.load_resource('inorm-lbp-crop', 'preprocessor', preferred_package='bob.bio.face')
assert isinstance(preprocessor, bob.bio.face.preprocessor.INormLBP)
assert isinstance(preprocessor, bob.bio.face.preprocessor.Base)
assert isinstance(preprocessor, bob.bio.base.preprocessor.Preprocessor)
......@@ -180,10 +180,10 @@ def test_inorm_lbp():
_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')
preprocessor = bob.bio.base.load_resource('inorm-lbp', 'preprocessor', preferred_package='bob.bio.face')
assert preprocessor.cropper is None
# load the preprocessor landmark detection
preprocessor = bob.bio.base.load_resource('inorm-lbp-landmark', 'preprocessor')
preprocessor = bob.bio.base.load_resource('inorm-lbp-landmark', 'preprocessor', preferred_package='bob.bio.face')
assert isinstance(preprocessor.cropper, bob.bio.face.preprocessor.FaceDetect)
......@@ -191,7 +191,7 @@ def test_heq():
# read input
image, annotation = _image(), _annotation()
preprocessor = bob.bio.base.load_resource('histogram-crop', 'preprocessor')
preprocessor = bob.bio.base.load_resource('histogram-crop', 'preprocessor', preferred_package='bob.bio.face')
assert isinstance(preprocessor, bob.bio.face.preprocessor.HistogramEqualization)
assert isinstance(preprocessor, bob.bio.face.preprocessor.Base)
assert isinstance(preprocessor, bob.bio.base.preprocessor.Preprocessor)
......@@ -200,10 +200,10 @@ def test_heq():
_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')
preprocessor = bob.bio.base.load_resource('histogram', 'preprocessor', preferred_package='bob.bio.face')
assert preprocessor.cropper is None
# load the preprocessor landmark detection
preprocessor = bob.bio.base.load_resource('histogram-landmark', 'preprocessor')
preprocessor = bob.bio.base.load_resource('histogram-landmark', 'preprocessor', preferred_package='bob.bio.face')
assert isinstance(preprocessor.cropper, bob.bio.face.preprocessor.FaceDetect)
......@@ -211,7 +211,7 @@ def test_sqi():
# read input
image, annotation = _image(), _annotation()
preprocessor = bob.bio.base.load_resource('self-quotient-crop', 'preprocessor')
preprocessor = bob.bio.base.load_resource('self-quotient-crop', 'preprocessor', preferred_package='bob.bio.face')
assert isinstance(preprocessor, bob.bio.face.preprocessor.SelfQuotientImage)
assert isinstance(preprocessor, bob.bio.face.preprocessor.Base)
assert isinstance(preprocessor, bob.bio.base.preprocessor.Preprocessor)
......@@ -220,8 +220,8 @@ def test_sqi():
_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')
preprocessor = bob.bio.base.load_resource('self-quotient', 'preprocessor', preferred_package='bob.bio.face')
assert preprocessor.cropper is None
# load the preprocessor landmark detection
preprocessor = bob.bio.base.load_resource('self-quotient-landmark', 'preprocessor')
preprocessor = bob.bio.base.load_resource('self-quotient-landmark', 'preprocessor', preferred_package='bob.bio.face')
assert isinstance(preprocessor.cropper, bob.bio.face.preprocessor.FaceDetect)
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