diff --git a/bob/bio/face/config/baseline/pytorch_pipe_v2.py b/bob/bio/face/config/baseline/pytorch_pipe_v2.py index 8cb2af0f71f2453e6b5631fb95c226edd5292c8b..630609e6fb22085783fa8c977ddc9702615d3364 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 d816e0421b514e8623972b5375df7036fe91c039..7634e4c13a870d297119515ae219678372759916 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 96a57cb9e1f45cd2a85a643146e69b3d873e787a..d784d7f48e6cd9c6eae1607b2a103940a01edfb7 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 001410786ae28278fea055c212bd9d5bd6a31972..ae39ebb45f65cd8601715f2de88e890c727df245 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 28b98d5f0cbb37e59bfb9f9623b31b966493ed85..bbb5417a0b6d3bf20a07c65c115921c57437ff0f 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