diff --git a/bob/bio/face/config/preprocessor/face_detect.py b/bob/bio/face/config/preprocessor/face_detect.py index c30eb351ce158c05b9be974ea533f2a28ea32a4e..1b6e0d4d71165541ebdb9df88bdda7fa466eb06f 100644 --- a/bob/bio/face/config/preprocessor/face_detect.py +++ b/bob/bio/face/config/preprocessor/face_detect.py @@ -1,16 +1,15 @@ #!/usr/bin/env python import bob.bio.face -import functools # Detects the face and eye landmarks crops it using the detected eyes -preprocessor = functools.partial(bob.bio.face.preprocessor.FaceDetect, +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 = functools.partial(bob.bio.face.preprocessor.FaceDetect, +preprocessor_no_eyes = bob.bio.face.preprocessor.FaceDetect( face_cropper = 'face-crop-eyes', use_flandmark = False ) diff --git a/bob/bio/face/preprocessor/utils.py b/bob/bio/face/preprocessor/utils.py index 8c54e95435f76bbc22825ad743777b3407469bd9..2a7ccdcf7a952c8e7097996d3844198adec3ef8f 100644 --- a/bob/bio/face/preprocessor/utils.py +++ b/bob/bio/face/preprocessor/utils.py @@ -1,36 +1,37 @@ import bob.bio.base import six -import functools - def load_cropper(face_cropper): - from .FaceCrop import FaceCrop - from .FaceDetect import FaceDetect - if face_cropper is None: - cropper = None - elif isinstance(face_cropper, six.string_types): - cropper = bob.bio.base.load_resource(face_cropper, 'preprocessor') - # In Dask, face_cropper is a functools. TODO: check that the object inside functool is valid - elif isinstance(face_cropper, (FaceCrop, FaceDetect, functools.partial)): - cropper = face_cropper - else: - raise ValueError("The given face cropper type is not understood") - - assert cropper is None or isinstance(cropper, (FaceCrop, FaceDetect)) or isinstance(cropper, functools.partial) - return cropper + from .FaceCrop import FaceCrop + from .FaceDetect import FaceDetect + + if face_cropper is None: + cropper = None + elif isinstance(face_cropper, six.string_types): + cropper = bob.bio.base.load_resource(face_cropper, "preprocessor") + else: + raise ValueError("The given face cropper type is not understood") + + assert ( + cropper is None + or isinstance(cropper, (FaceCrop, FaceDetect)) + or isinstance(cropper, functools.partial) + ) + return cropper def load_cropper_only(face_cropper): - from .FaceCrop import FaceCrop - if face_cropper is None: - cropper = None - elif isinstance(face_cropper, six.string_types): - cropper = bob.bio.base.load_resource(face_cropper, 'preprocessor') - elif isinstance(face_cropper, FaceCrop): - cropper = face_cropper - else: - raise ValueError("The given face cropper type is not understood") - - assert cropper is None or isinstance(cropper, FaceCrop) - return cropper + from .FaceCrop import FaceCrop + + if face_cropper is None: + cropper = None + elif isinstance(face_cropper, six.string_types): + cropper = bob.bio.base.load_resource(face_cropper, "preprocessor") + elif isinstance(face_cropper, FaceCrop): + cropper = face_cropper + else: + raise ValueError("The given face cropper type is not understood") + + assert cropper is None or isinstance(cropper, FaceCrop) + return cropper diff --git a/bob/bio/face/test/test_preprocessors.py b/bob/bio/face/test/test_preprocessors.py index 634a495a7cf2a169abc7f8c04ce58f8ee36c225d..ffdf8384d7a59688bb3cca5f7f613819ad7558fd 100644 --- a/bob/bio/face/test/test_preprocessors.py +++ b/bob/bio/face/test/test_preprocessors.py @@ -119,7 +119,6 @@ def test_face_crop(): def test_face_detect(): image, annotation = _image(), None - 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)