From b5fc4b73e2e9783d5fe281633d0ac8111c802e6f Mon Sep 17 00:00:00 2001
From: Tiago Freitas Pereira <tiagofrepereira@gmail.com>
Date: Mon, 23 Mar 2020 19:20:39 +0100
Subject: [PATCH] Created and example repository

---
 .../lda_atnt_legacy.py                        |  0
 .../lda_atnt_legacy_all_legacy.py             |  0
 .../{baselines => examples}/pca_atnt.py       |  0
 .../pca_atnt_legacy.py                        |  0
 .../base/config/examples/pca_mobio-male.py    | 65 +++++++++++++++++++
 5 files changed, 65 insertions(+)
 rename bob/bio/base/config/{baselines => examples}/lda_atnt_legacy.py (100%)
 rename bob/bio/base/config/{baselines => examples}/lda_atnt_legacy_all_legacy.py (100%)
 rename bob/bio/base/config/{baselines => examples}/pca_atnt.py (100%)
 rename bob/bio/base/config/{baselines => examples}/pca_atnt_legacy.py (100%)
 create mode 100644 bob/bio/base/config/examples/pca_mobio-male.py

diff --git a/bob/bio/base/config/baselines/lda_atnt_legacy.py b/bob/bio/base/config/examples/lda_atnt_legacy.py
similarity index 100%
rename from bob/bio/base/config/baselines/lda_atnt_legacy.py
rename to bob/bio/base/config/examples/lda_atnt_legacy.py
diff --git a/bob/bio/base/config/baselines/lda_atnt_legacy_all_legacy.py b/bob/bio/base/config/examples/lda_atnt_legacy_all_legacy.py
similarity index 100%
rename from bob/bio/base/config/baselines/lda_atnt_legacy_all_legacy.py
rename to bob/bio/base/config/examples/lda_atnt_legacy_all_legacy.py
diff --git a/bob/bio/base/config/baselines/pca_atnt.py b/bob/bio/base/config/examples/pca_atnt.py
similarity index 100%
rename from bob/bio/base/config/baselines/pca_atnt.py
rename to bob/bio/base/config/examples/pca_atnt.py
diff --git a/bob/bio/base/config/baselines/pca_atnt_legacy.py b/bob/bio/base/config/examples/pca_atnt_legacy.py
similarity index 100%
rename from bob/bio/base/config/baselines/pca_atnt_legacy.py
rename to bob/bio/base/config/examples/pca_atnt_legacy.py
diff --git a/bob/bio/base/config/examples/pca_mobio-male.py b/bob/bio/base/config/examples/pca_mobio-male.py
new file mode 100644
index 00000000..dd9152ec
--- /dev/null
+++ b/bob/bio/base/config/examples/pca_mobio-male.py
@@ -0,0 +1,65 @@
+
+import functools
+import bob.db.atnt
+from bob.bio.base.pipelines.vanilla_biometrics.legacy import DatabaseConnector, DatabaseConnectorAnnotated
+from bob.extension import rc
+import bob.bio.face
+
+from bob.bio.base.mixins.legacy import LegacyProcessorMixin, LegacyAlgorithmMixin
+from bob.bio.base.pipelines.vanilla_biometrics.legacy import LegacyBiometricAlgorithm
+
+
+
+original_directory=rc['bob.db.mobio.directory']
+annotation_directory=rc['bob.db.mobio.annotation_directory']
+database = DatabaseConnectorAnnotated(bob.bio.face.database.mobio.MobioBioDatabase(
+	                         original_directory=original_directory,
+	                         annotation_directory=annotation_directory,
+	                         original_extension=".png"
+	                         ), 
+	                         protocol="mobile0-male")
+
+from sklearn.pipeline import Pipeline, make_pipeline
+from sklearn.decomposition import PCA
+
+from bob.pipelines.mixins import CheckpointMixin, SampleMixin
+from bob.bio.base.mixins import CheckpointSampleLinearize
+
+class CheckpointSamplePCA(CheckpointMixin, SampleMixin, PCA):
+    """
+    Enables SAMPLE and CHECKPOINTIN handling for https://scikit-learn.org/stable/modules/generated/sklearn.decomposition.PCA.html
+    """
+    pass
+
+
+
+#### PREPROCESSOR LEGACY ###
+
+# Using face crop
+CROPPED_IMAGE_HEIGHT = 80
+CROPPED_IMAGE_WIDTH = CROPPED_IMAGE_HEIGHT * 4 // 5
+
+## eye positions for frontal images
+RIGHT_EYE_POS = (CROPPED_IMAGE_HEIGHT // 5, CROPPED_IMAGE_WIDTH // 4 - 1)
+LEFT_EYE_POS = (CROPPED_IMAGE_HEIGHT // 5, CROPPED_IMAGE_WIDTH // 4 * 3)
+
+original_preprocessor = functools.partial(
+                  bob.bio.face.preprocessor.FaceCrop,
+                  cropped_image_size=(CROPPED_IMAGE_HEIGHT, CROPPED_IMAGE_WIDTH),
+                  cropped_positions={"leye": LEFT_EYE_POS, "reye": RIGHT_EYE_POS},
+               )
+
+
+from bob.pipelines.mixins import mix_me_up
+preprocessor = mix_me_up((CheckpointMixin, SampleMixin), LegacyProcessorMixin)
+
+from bob.pipelines.mixins import dask_it
+extractor = Pipeline(steps=[('0', preprocessor(callable=original_preprocessor, features_dir="./example/extractor0")),
+                            ('1',CheckpointSampleLinearize(features_dir="./example/extractor1")), 
+	                        ('2',CheckpointSamplePCA(features_dir="./example/extractor2", model_path="./example/pca.pkl"))])
+extractor = dask_it(extractor)
+
+from bob.bio.base.pipelines.vanilla_biometrics.biometric_algorithm import Distance, BiometricAlgorithmCheckpointMixin
+class CheckpointDistance(BiometricAlgorithmCheckpointMixin, Distance):  pass
+algorithm = CheckpointDistance(features_dir="./example/")
+#algorithm = Distance()
-- 
GitLab