From b30702b715fee0b74b37a52a783d924ca91388df Mon Sep 17 00:00:00 2001
From: Amir MOHAMMADI <amir.mohammadi@idiap.ch>
Date: Thu, 15 Oct 2020 18:18:11 +0200
Subject: [PATCH] [preprocessor][FaceCrop] Load annotators if they are passed
 as a string

---
 bob/bio/face/preprocessor/FaceCrop.py | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/bob/bio/face/preprocessor/FaceCrop.py b/bob/bio/face/preprocessor/FaceCrop.py
index e19f34c8..47454060 100644
--- a/bob/bio/face/preprocessor/FaceCrop.py
+++ b/bob/bio/face/preprocessor/FaceCrop.py
@@ -10,8 +10,8 @@ import logging
 from .Base import Base
 
 logger = logging.getLogger("bob.bio.face")
-from sklearn.utils import check_array
-from bob.pipelines.sample import SampleBatch
+from bob.bio.base import load_resource
+
 
 class FaceCrop(Base):
     """Crops the face according to the given annotations.
@@ -85,18 +85,18 @@ class FaceCrop(Base):
   mask_seed : int or None
     The random seed to apply for mask extrapolation.
 
-  allow_upside_down_normalized_faces: bool, optional
-    If ``False`` (default), a ValueError is raised when normalized faces are going to be
-    upside down compared to input image. This allows you to catch wrong annotations in
-    your database easily. If you are sure about your input, you can set this flag to
-    ``True``.
-
     .. warning::
 
        When run in parallel, the same random seed will be applied to all
        parallel processes. Hence, results of parallel execution will differ
        from the results in serial execution.
 
+  allow_upside_down_normalized_faces: bool, optional
+    If ``False`` (default), a ValueError is raised when normalized faces are going to be
+    upside down compared to input image. This allows you to catch wrong annotations in
+    your database easily. If you are sure about your input, you can set this flag to
+    ``True``.
+
   annotator : :any:`bob.bio.base.annotator.Annotator`
     If provided, the annotator will be used if the required annotations are
     missing.
@@ -142,7 +142,7 @@ class FaceCrop(Base):
         self.mask_sigma = mask_sigma
         self.mask_neighbors = mask_neighbors
         self.mask_seed = mask_seed
-        self.annotator = annotator
+        self.annotator = load_resource(annotator, "annotator")
         self.allow_upside_down_normalized_faces = allow_upside_down_normalized_faces
 
         # create objects required for face cropping
@@ -300,7 +300,7 @@ class FaceCrop(Base):
                 The cropped face.
             """
 
-        def _crop(image, annot):            
+        def _crop(image, annot):
             # if annotations are missing and cannot do anything else return None.
             if (
                 not self.is_annotations_valid(annot)
-- 
GitLab