diff --git a/bob/bio/face/config/database/mobio_male.py b/bob/bio/face/config/database/mobio_male.py new file mode 100644 index 0000000000000000000000000000000000000000..ee41b24670f8e62e828c729d58b1d8b60fcc9401 --- /dev/null +++ b/bob/bio/face/config/database/mobio_male.py @@ -0,0 +1,15 @@ +#!/usr/bin/env python + +from bob.bio.face.database import MobioBioDatabase +from bob.bio.base.pipelines.vanilla_biometrics import DatabaseConnector +from bob.extension import rc + +database = DatabaseConnector( + MobioBioDatabase( + original_directory=rc["bob.db.mobio.directory"], + annotation_directory=rc["bob.db.mobio.annotation_directory"], + original_extension=".png", + protocol="mobile0-male", + ) +) + diff --git a/bob/bio/face/preprocessor/FaceCrop.py b/bob/bio/face/preprocessor/FaceCrop.py index 96c24fa82e1aa8eb9fb905eb052db1995e5e25a5..6c0eea38bcc2e68f3380054bfdea08e2a012480c 100644 --- a/bob/bio/face/preprocessor/FaceCrop.py +++ b/bob/bio/face/preprocessor/FaceCrop.py @@ -11,7 +11,7 @@ from .Base import Base logger = logging.getLogger("bob.bio.face") from sklearn.utils import check_array - +from bob.pipelines.sample import SampleBatch class FaceCrop(Base): """Crops the face according to the given annotations. @@ -335,16 +335,17 @@ class FaceCrop(Base): # crop face return self.data_type(self.crop_face(image, annot)) - X = check_array(X, allow_nd=True) + if isinstance(X, SampleBatch): + + if annotations is None: + return [_crop(data) for data in X] + else: + return [_crop(data, annot) for data, annot in zip(X, annotations)] - if isinstance(annotations, list): - cropped_images = [] - for image, annot in zip(X, annotations): - cropped_images.append(_crop(image, annot)) - return cropped_images else: return _crop(X, annotations) + def __getstate__(self): d = dict(self.__dict__) d.pop("mask_rng") diff --git a/bob/bio/face/preprocessor/FaceDetect.py b/bob/bio/face/preprocessor/FaceDetect.py index 57dc29c76218fafbaac333546b3c8c5b4cd1c885..e6d883aa14eb1dcaa73f853c788d3ffe71829e89 100644 --- a/bob/bio/face/preprocessor/FaceDetect.py +++ b/bob/bio/face/preprocessor/FaceDetect.py @@ -10,7 +10,7 @@ import numpy from .Base import Base from .utils import load_cropper_only from sklearn.utils import check_array - +from bob.pipelines.sample import SampleBatch import logging logger = logging.getLogger("bob.bio.face") @@ -225,14 +225,13 @@ class FaceDetect(Base): return self.data_type(image) - X = check_array(X, allow_nd=True) - cropped_images = [] + if isinstance(X, SampleBatch): + + if annotations is None: + return [_crop(data) for data in X] + else: + return [_crop(data, annot) for data, annot in zip(X, annotations)] - if isinstance(annotations, list): - cropped_images = [] - for image, annot in zip(X, annotations): - cropped_images.append(_crop(image, annot)) - return cropped_images else: return _crop(X, annotations) diff --git a/bob/bio/face/test/test_baselines.py b/bob/bio/face/test/test_baselines.py index 8a6cea0d0afffc873f5466f2862303eaf072b30b..effdcdfafe43dfc4d3fe6c19ca4ee37e77863a22 100644 --- a/bob/bio/face/test/test_baselines.py +++ b/bob/bio/face/test/test_baselines.py @@ -62,7 +62,7 @@ def run_baseline(baseline, samples_for_training=[]): probes = get_fake_sample_set(purpose="probe") # Regular pipeline - pipeline = load_resource(baseline, "baseline") + pipeline = load_resource(baseline, "pipeline") scores = pipeline(samples_for_training, biometric_references, probes) assert len(scores) == 1 assert len(scores[0]) == 1 diff --git a/setup.py b/setup.py index c00a75d92403007d05af6a4211e75fbac49031bb..a6b6e056c6c990ab70eefbda8ebae42c75e2a969 100644 --- a/setup.py +++ b/setup.py @@ -115,9 +115,7 @@ setup( 'lfw-restricted = bob.bio.face.config.database.lfw_restricted:database', 'lfw-unrestricted = bob.bio.face.config.database.lfw_unrestricted:database', - 'mobio-image = bob.bio.face.config.database.mobio:mobio_image', - 'mobio-male = bob.bio.face.config.database.mobio:mobio_male', # MOBIO gender-dependent training - 'mobio-female = bob.bio.face.config.database.mobio:mobio_female', # MOBIO gender-dependent training + 'mobio-male = bob.bio.face.config.database.mobio_male:database', 'msu-mfsd-mod-licit = bob.bio.face.config.database.msu_mfsd_mod:msu_mfsd_mod_licit', 'msu-mfsd-mod-spoof = bob.bio.face.config.database.msu_mfsd_mod:msu_mfsd_mod_spoof', 'multipie = bob.bio.face.config.database.multipie:database', @@ -149,7 +147,7 @@ setup( ], #baselines - 'bob.bio.baseline':[ + 'bob.bio.pipeline':[ 'facenet_sanderberg = bob.bio.face.config.baseline.facenet_sanderberg:pipeline', 'inception_resnetv1_casiawebface = bob.bio.face.config.baseline.inception_resnetv1_casiawebface:pipeline', 'inception_resnetv2_casiawebface = bob.bio.face.config.baseline.inception_resnetv2_casiawebface:pipeline',