From 7579be1748206ec0261e3f49a6d135bf60eca65f Mon Sep 17 00:00:00 2001
From: Tiago Freitas Pereira <tiagofrepereira@gmail.com>
Date: Wed, 10 Jun 2020 19:13:04 +0200
Subject: [PATCH] Added baselines as resources

---
 .../{facenet.py => facenet_sanderberg.py}     |  0
 bob/bio/face/test/test_baseline.py            | 33 +++-------
 setup.py                                      | 62 ++-----------------
 3 files changed, 13 insertions(+), 82 deletions(-)
 rename bob/bio/face/config/baseline/{facenet.py => facenet_sanderberg.py} (100%)

diff --git a/bob/bio/face/config/baseline/facenet.py b/bob/bio/face/config/baseline/facenet_sanderberg.py
similarity index 100%
rename from bob/bio/face/config/baseline/facenet.py
rename to bob/bio/face/config/baseline/facenet_sanderberg.py
diff --git a/bob/bio/face/test/test_baseline.py b/bob/bio/face/test/test_baseline.py
index c22226e7..f6ea8f58 100644
--- a/bob/bio/face/test/test_baseline.py
+++ b/bob/bio/face/test/test_baseline.py
@@ -2,7 +2,7 @@ from bob.extension.config import load
 import pkg_resources
 import numpy as np
 from bob.pipelines import Sample, SampleSet
-
+from bob.bio.base import load_resource
 
 def get_fake_sample(face_size=(160, 160), eyes={"leye": (46, 107), "reye": (46, 53)}):
 
@@ -12,10 +12,7 @@ def get_fake_sample(face_size=(160, 160), eyes={"leye": (46, 107), "reye": (46,
 
 
 def test_facenet_baseline():
-    config_name = pkg_resources.resource_filename(
-        "bob.bio.face", "config/baseline/facenet.py"
-    )
-    transformer = load([config_name]).transformer
+    transformer = load_resource("facenet_sanderberg", "baseline")
 
     fake_sample = get_fake_sample()
 
@@ -25,10 +22,7 @@ def test_facenet_baseline():
 
 
 def test_inception_resnetv2_msceleb():
-    config_name = pkg_resources.resource_filename(
-        "bob.bio.face", "config/baseline/inception_resnetv2_msceleb.py"
-    )
-    transformer = load([config_name]).transformer
+    transformer = load_resource("inception_resnetv2_msceleb", "baseline")
 
     fake_sample = get_fake_sample()
 
@@ -38,10 +32,7 @@ def test_inception_resnetv2_msceleb():
 
 
 def test_inception_resnetv2_casiawebface():
-    config_name = pkg_resources.resource_filename(
-        "bob.bio.face", "config/baseline/inception_resnetv2_casiawebface.py"
-    )
-    transformer = load([config_name]).transformer
+    transformer = load_resource("inception_resnetv2_casiawebface", "baseline")
 
     fake_sample = get_fake_sample()
 
@@ -51,10 +42,7 @@ def test_inception_resnetv2_casiawebface():
 
 
 def test_inception_resnetv1_msceleb():
-    config_name = pkg_resources.resource_filename(
-        "bob.bio.face", "config/baseline/inception_resnetv1_msceleb.py"
-    )
-    transformer = load([config_name]).transformer
+    transformer = load_resource("inception_resnetv1_msceleb", "baseline")
 
     fake_sample = get_fake_sample()
 
@@ -64,10 +52,7 @@ def test_inception_resnetv1_msceleb():
 
 
 def test_inception_resnetv1_casiawebface():
-    config_name = pkg_resources.resource_filename(
-        "bob.bio.face", "config/baseline/inception_resnetv1_casiawebface.py"
-    )
-    transformer = load([config_name]).transformer
+    transformer = load_resource("inception_resnetv1_casiawebface", "baseline")
 
     fake_sample = get_fake_sample()
 
@@ -79,11 +64,7 @@ def test_inception_resnetv1_casiawebface():
 def test_arcface_insight_tf():
     import tensorflow as tf
     tf.compat.v1.reset_default_graph()
-    
-    config_name = pkg_resources.resource_filename(
-        "bob.bio.face", "config/baseline/arcface_insight_tf.py"
-    )
-    transformer = load([config_name]).transformer
+    transformer = load_resource("arcface_insight_tf", "baseline")
 
     fake_sample = get_fake_sample()
 
diff --git a/setup.py b/setup.py
index a1bc1893..d6c10dca 100644
--- a/setup.py
+++ b/setup.py
@@ -103,8 +103,6 @@ setup(
 
         # scripts should be declared using this entry:
         'console_scripts': [
-            'baselines.py      = bob.bio.face.script.baselines:main',
-            'display_face_annotations.py = bob.bio.face.script.display_face_annotations:main',            
         ],
 
         'bob.bio.database': [
@@ -143,62 +141,14 @@ setup(
             'mtcnn                    = bob.bio.face.config.annotator.mtcnn:annotator',
         ],
 
-        'bob.bio.preprocessor': [
-            'base              = bob.bio.face.config.preprocessor.base:preprocessor',  # simple color conversion
-            'face-crop-eyes    = bob.bio.face.config.preprocessor.face_crop_eyes:preprocessor',  # face crop
-            'landmark-detect   = bob.bio.face.config.preprocessor.face_detect:preprocessor',
-            # face detection + landmark detection + cropping
-            'face-detect       = bob.bio.face.config.preprocessor.face_detect:preprocessor_no_eyes',
-            # face detection + cropping
-
-            'inorm-lbp-crop    = bob.bio.face.config.preprocessor.inorm_lbp:preprocessor',  # face crop + inorm-lbp
-            'tan-triggs-crop   = bob.bio.face.config.preprocessor.tan_triggs:preprocessor',  # face crop + Tan&Triggs
-            'histogram-crop    = bob.bio.face.config.preprocessor.histogram_equalization:preprocessor',
-            # face crop + histogram equalization
-            'self-quotient-crop= bob.bio.face.config.preprocessor.self_quotient_image:preprocessor',
-            # face crop + self quotient image
-
-            'inorm-lbp-landmark = bob.bio.face.config.preprocessor.inorm_lbp:preprocessor_landmark',
-            # face detection + landmark detection + cropping + inorm-lbp
-            'tan-triggs-landmark = bob.bio.face.config.preprocessor.tan_triggs:preprocessor_landmark',
-            # face detection + landmark detection + cropping + Tan&Triggs
-            'histogram-landmark = bob.bio.face.config.preprocessor.histogram_equalization:preprocessor_landmark',
-            # face detection + landmark detection + cropping + histogram equalization
-            'self-quotient-landmark = bob.bio.face.config.preprocessor.self_quotient_image:preprocessor_landmark',
-            # face detection + landmark detection + cropping + self quotient image
-
-            'inorm-lbp         = bob.bio.face.config.preprocessor.inorm_lbp:preprocessor_no_crop',
-            # inorm-lbp w/o face-crop
-            'tan-triggs        = bob.bio.face.config.preprocessor.tan_triggs:preprocessor_no_crop',
-            # Tan&Triggs w/o face-crop
-            'histogram         = bob.bio.face.config.preprocessor.histogram_equalization:preprocessor_no_crop',
-            # histogram equalization w/o face-crop
-            'self-quotient     = bob.bio.face.config.preprocessor.self_quotient_image:preprocessor_no_crop',
-            # self quotient image w/o face-crop
-        ],
-
-        'bob.bio.extractor': [
-            'dct-blocks        = bob.bio.face.config.extractor.dct_blocks:extractor',  # DCT blocks
-            'grid-graph        = bob.bio.face.config.extractor.grid_graph:extractor',  # Grid graph
-            'lgbphs            = bob.bio.face.config.extractor.lgbphs:extractor',  # LGBPHS
-        ],
-
-        'bob.bio.algorithm': [
-            'gabor-jet         = bob.bio.face.config.algorithm.gabor_jet:algorithm',  # Gabor jet comparison
-            'histogram         = bob.bio.face.config.algorithm.histogram:algorithm',  # LGBPHS histograms
-            'bic-jets          = bob.bio.face.config.algorithm.bic_jets:algorithm',  # BIC on gabor jets
-        ],
-
         #baselines
         'bob.bio.baseline':[
-          'lda = bob.bio.face.baseline.baseline:lda',
-          'plda = bob.bio.face.baseline.baseline:plda',
-          'gabor_graph = bob.bio.face.baseline.baseline:gabor_graph',
-          'lgbphs = bob.bio.face.baseline.baseline:lgbphs',
-          'gmm = bob.bio.face.baseline.baseline:gmm',
-          'isv = bob.bio.face.baseline.baseline:isv',
-          'ivector = bob.bio.face.baseline.baseline:ivector',
-          'bic = bob.bio.face.baseline.baseline:bic',
+          'facenet_sanderberg = bob.bio.face.config.baseline.facenet_sanderberg:transformer',
+          'inception_resnetv1_casiawebface = bob.bio.face.config.baseline.inception_resnetv1_casiawebface:transformer',
+          'inception_resnetv2_casiawebface = bob.bio.face.config.baseline.inception_resnetv2_casiawebface:transformer',
+          'inception_resnetv1_msceleb = bob.bio.face.config.baseline.inception_resnetv1_msceleb:transformer',
+          'inception_resnetv2_msceleb = bob.bio.face.config.baseline.inception_resnetv2_msceleb:transformer',
+          'arcface_insight_tf = bob.bio.face.config.baseline.arcface_insight_tf:transformer',
         ],
 
     },
-- 
GitLab