diff --git a/bob/pad/face/database/casiasurf.py b/bob/pad/face/database/casiasurf.py index 6590c3af4eaa3c98b5a2e3dc12aa78e4a09214ea..b4bad6de9bc6cfb9ce9e595c8150732030f36b72 100644 --- a/bob/pad/face/database/casiasurf.py +++ b/bob/pad/face/database/casiasurf.py @@ -144,7 +144,7 @@ class CasiaSurfPadDatabase(PadDatabase): The protocol for which the samples should be retrieved. purposes : :py:class:`str` The purposes for which Sample objects should be retrieved. - Usually it is either 'real' or 'attack', but could be 'unknown' as well + Usually it is either 'real' or 'attack' model_ids This parameter is not supported in PAD databases yet. @@ -160,9 +160,9 @@ class CasiaSurfPadDatabase(PadDatabase): # for training lowlevel_purposes = [] - if 'train' in groups and purposes == 'real': + if 'train' in groups and 'real' in purposes: lowlevel_purposes.append('real') - if 'train' in groups and purposes == 'attack': + if 'train' in groups and 'attack' in purposes: lowlevel_purposes.append('attack') # for dev and eval diff --git a/bob/pad/face/preprocessor/FaceCropAlign.py b/bob/pad/face/preprocessor/FaceCropAlign.py index 7efeb31ea6afd60e6d638881fde4df65ef895aca..387e7681191d13564c6a5ff3b181c2c1f4666c29 100644 --- a/bob/pad/face/preprocessor/FaceCropAlign.py +++ b/bob/pad/face/preprocessor/FaceCropAlign.py @@ -19,8 +19,10 @@ import bob.ip.base import importlib -import bob.bio.face +import bob.bio.face +import logging +logger = logging.getLogger("bob.pad.face") # ============================================================================== @@ -551,6 +553,7 @@ class FaceCropAlign(Preprocessor): self.normalization_function = normalization_function self.normalization_function_kwargs = normalization_function_kwargs + self.supported_face_detection_method = ["dlib", "mtcnn"] @@ -619,6 +622,15 @@ class FaceCropAlign(Preprocessor): (self.face_size, self.face_size), RGB 3D or gray-scale 2D. """ + # sanity check: + if not self.rgb_output_flag and len(image.shape) != 2: + logger.warning("This image has 3 channels") + if self.normalization_function is not None: + import bob.ip.color + image = bob.ip.color.rgb_to_gray(image) + logger.warning("Image has been converted to grayscale") + + if self.face_detection_method is not None: if self.max_image_size is not None: # max_image_size = 1920, for example @@ -633,7 +645,7 @@ class FaceCropAlign(Preprocessor): method=self.face_detection_method) except: - + logger.warning("Face not detected") return None if not annotations: # if empty dictionary is returned @@ -656,7 +668,6 @@ class FaceCropAlign(Preprocessor): return None if self.normalization_function is not None: - image = self.normalization_function(image, annotations, **self.normalization_function_kwargs) norm_face_image = normalize_image_size(image=image,