Commit 96ce339b authored by Yannick DAYER's avatar Yannick DAYER
Browse files

[py][fix] FaceCrop needs to be a functools

Accepting a functools as face_cropper argument of preprocessor in utils
Adding the processing of functools in INormLBP
Fix of a type issue in GridGraph extractor (numpy uint16 instead of float)
parent cc5c340e
Pipeline #37923 failed with stage
in 6 minutes and 40 seconds
......@@ -184,8 +184,10 @@ class GridGraph (Extractor):
The list of Gabor jets extracted from the image.
The 2D location of the jet's nodes is not returned.
"""
assert image.ndim == 2
assert isinstance(image, numpy.ndarray)
image = image.astype(numpy.float64)
assert image.dtype == numpy.float64
extractor = self._extractor(image)
......
......@@ -112,8 +112,16 @@ class INormLBP (Base):
face : 2D :py:class:`numpy.ndarray`
The cropped and photometrically enhanced face.
"""
image = self.color_channel(image)
if self.cropper is not None:
# TODO: IN DASK, SELF.CROPPER IS A FUNCTOOLS
# WE NEED TO THINK HOW TO PROPERLY APPROACH THIS ISSUE
if not isinstance(self.cropper, bob.bio.face.preprocessor.FaceCrop):
self.cropper = self.cropper()
image = self.cropper.crop_face(image, annotations)
image = self.lbp_extractor(image)
return self.data_type(image)
import bob.bio.base
import six
import functools
def load_cropper(face_cropper):
from .FaceCrop import FaceCrop
......@@ -9,12 +11,13 @@ def load_cropper(face_cropper):
cropper = None
elif isinstance(face_cropper, six.string_types):
cropper = bob.bio.base.load_resource(face_cropper, 'preprocessor')
elif isinstance(face_cropper, (FaceCrop, FaceDetect)):
# 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))
assert cropper is None or isinstance(cropper, (FaceCrop, FaceDetect)) or isinstance(cropper, functools.partial)
return cropper
......
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