Commit 7e74b2f0 authored by Tiago de Freitas Pereira's avatar Tiago de Freitas Pereira
Browse files

Removing traces of functools

parent b1aff89f
Pipeline #39178 failed with stage
in 4 minutes and 59 seconds
#!/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
)
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
......@@ -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)
......
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