Commit 0229bcc4 authored by Xinyi ZHANG's avatar Xinyi ZHANG Committed by Tiago de Freitas Pereira
Browse files

”new_version”

parent 038e214b
......@@ -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
......@@ -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}
......@@ -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}
......
......@@ -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)
......
Supports Markdown
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