From 0229bcc4e2b3b2f3f9a5de3316f3e6a127767cb3 Mon Sep 17 00:00:00 2001
From: Xinyi ZHANG <xzhang@vws101.idiap.ch>
Date: Mon, 12 Apr 2021 13:22:48 +0200
Subject: [PATCH] =?UTF-8?q?=E2=80=9Dnew=5Fversion=E2=80=9D?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../face/config/baseline/pytorch_pipe_v2.py   | 92 +++++--------------
 bob/bio/face/extractor/opencv_caffe.py        |  2 +
 bob/bio/face/extractor/pytorch_model.py       |  3 +-
 bob/bio/face/extractor/tf_model.py            |  2 +-
 doc/references.rst                            |  2 +-
 5 files changed, 27 insertions(+), 74 deletions(-)

diff --git a/bob/bio/face/config/baseline/pytorch_pipe_v2.py b/bob/bio/face/config/baseline/pytorch_pipe_v2.py
index 8cb2af0f..630609e6 100644
--- a/bob/bio/face/config/baseline/pytorch_pipe_v2.py
+++ b/bob/bio/face/config/baseline/pytorch_pipe_v2.py
@@ -24,28 +24,38 @@ else:
     fixed_positions = None
 
 
+cropped_positions = {"leye": (49, 72), "reye": (49, 38)}
 
-cropped_positions={'leye':(49,72), 'reye':(49,38)}
-
-preprocessor_transformer = FaceCrop(cropped_image_size=(224,224), cropped_positions={'leye':(49,72), 'reye':(49,38)}, color_channel='rgb',fixed_positions=fixed_positions)
-
-transform_extra_arguments = (None if (cropped_positions is None or fixed_positions is not None) else (("annotations", "annotations"),))
-
+preprocessor_transformer = FaceCrop(
+    cropped_image_size=(224, 224),
+    cropped_positions={"leye": (49, 72), "reye": (49, 38)},
+    color_channel="rgb",
+    fixed_positions=fixed_positions,
+)
 
+transform_extra_arguments = (
+    None
+    if (cropped_positions is None or fixed_positions is not None)
+    else (("annotations", "annotations"),)
+)
 
 
-model = InceptionResnetV1(pretrained='vggface2').eval()
+model = InceptionResnetV1(pretrained="vggface2").eval()
 extractor_transformer = pytorch_library_model(model=model)
 
 
-
-
-algorithm = Distance(distance_function = scipy.spatial.distance.cosine,is_distance_function = True)
+algorithm = Distance(
+    distance_function=scipy.spatial.distance.cosine, is_distance_function=True
+)
 
 
 # Chain the Transformers together
 transformer = make_pipeline(
-    wrap(["sample"], preprocessor_transformer,transform_extra_arguments=transform_extra_arguments),
+    wrap(
+        ["sample"],
+        preprocessor_transformer,
+        transform_extra_arguments=transform_extra_arguments,
+    ),
     wrap(["sample"], extractor_transformer)
     # Add more transformers here if needed
 )
@@ -54,63 +64,3 @@ transformer = make_pipeline(
 # Assemble the Vanilla Biometric pipeline and execute
 pipeline = VanillaBiometricsPipeline(transformer, algorithm)
 transformer = pipeline.transformer
-<<<<<<< HEAD
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-=======
->>>>>>> ”new”
diff --git a/bob/bio/face/extractor/opencv_caffe.py b/bob/bio/face/extractor/opencv_caffe.py
index d816e042..7634e4c1 100644
--- a/bob/bio/face/extractor/opencv_caffe.py
+++ b/bob/bio/face/extractor/opencv_caffe.py
@@ -84,6 +84,7 @@ class opencv_model(TransformerMixin, BaseEstimator):
     """
 
         if self.model is None:
+
             self._load_model()
 
         img = np.array(X)
@@ -100,4 +101,5 @@ class opencv_model(TransformerMixin, BaseEstimator):
         return d
 
     def _more_tags(self):
+
         return {"stateless": True, "requires_fit": False}
diff --git a/bob/bio/face/extractor/pytorch_model.py b/bob/bio/face/extractor/pytorch_model.py
index 96a57cb9..d784d7f4 100644
--- a/bob/bio/face/extractor/pytorch_model.py
+++ b/bob/bio/face/extractor/pytorch_model.py
@@ -80,7 +80,7 @@ class pytorch_loaded_model(TransformerMixin, BaseEstimator):
     """
 
         if self.model is None:
-            self.load_model()
+            self._load_model()
 
         X = torch.Tensor(X)
 
@@ -94,6 +94,7 @@ class pytorch_loaded_model(TransformerMixin, BaseEstimator):
         return d
 
     def _more_tags(self):
+
         return {"stateless": True, "requires_fit": False}
 
 
diff --git a/bob/bio/face/extractor/tf_model.py b/bob/bio/face/extractor/tf_model.py
index 00141078..ae39ebb4 100644
--- a/bob/bio/face/extractor/tf_model.py
+++ b/bob/bio/face/extractor/tf_model.py
@@ -74,7 +74,7 @@ class tf_model(TransformerMixin, BaseEstimator):
     """
 
         if self.model is None:
-            self.load_model()
+            self._load_model()
 
         X = check_array(X, allow_nd=True)
         X = tf.convert_to_tensor(X)
diff --git a/doc/references.rst b/doc/references.rst
index 28b98d5f..bbb5417a 100644
--- a/doc/references.rst
+++ b/doc/references.rst
@@ -17,4 +17,4 @@ References
 .. [ZSQ09]  *W. Zhang, S. Shan, L. Qing, X. Chen and W. Gao*. **Are Gabor phases really useless for face recognition?** Pattern Analysis & Applications, 12:301-307, 2009.
 .. [TFP18] de Freitas Pereira, Tiago, André Anjos, and Sébastien Marcel. "Heterogeneous face recognition using domain specific units." IEEE Transactions on Information Forensics and Security 14.7 (2018): 1803-1816.
 .. [HRM06]   *G. Heusch, Y. Rodriguez, and S. Marcel*. **Local Binary Patterns as an Image Preprocessing for Face Authentication**. In IEEE International Conference on Automatic Face and Gesture Recognition (AFGR), 2006.
-.. [LGB18]    *C. Li, M. Gunther and T. E. Boult*. **ECLIPSE: Ensembles of Centroids Leveraging Iteratively Processed Spatial Eclipse Clustering**. 2018 IEEE Winter Conference on Applications of Computer Vision (WACV), Lake Tahoe, NV, USA, 2018, pp. 131-140, doi: 10.1109/WACV.2018.00021.
+.. [LGB18]    *C. Li, M. Gunther and T. E. Boult*. **ECLIPSE: Ensembles of Centroids Leveraging Iteratively Processed Spatial Eclipse Clustering**. 2018 IEEE Winter Conference on Applications of Computer Vision (WACV), Lake Tahoe, NV, USA, 2018, pp. 131-140, doi: 10.1109/WACV.2018.00021.
\ No newline at end of file
-- 
GitLab