diff --git a/bob/bio/vein/configurations/maximum_curvature.py b/bob/bio/vein/configurations/maximum_curvature.py index 3bee726bbcfb34dbce8468f0753971a1dcef3605..20054546e709ea21b0de43f105d01232a591ebaf 100644 --- a/bob/bio/vein/configurations/maximum_curvature.py +++ b/bob/bio/vein/configurations/maximum_curvature.py @@ -2,7 +2,7 @@ # vim: set fileencoding=utf-8 : # Tue 27 Sep 2016 16:48:32 CEST -'''Maximum Curvature and Miura Matching baseline +"""Maximum Curvature and Miura Matching baseline References: @@ -10,41 +10,68 @@ References: 2. [TV13]_ 3. [TVM14]_ -''' +""" -sub_directory = 'mc' -"""Sub-directory where results will be placed. +from tempfile import TemporaryDirectory +from pathlib import Path +import os -You may change this setting using the ``--sub-directory`` command-line option -or the attribute ``sub_directory`` in a configuration file loaded **after** -this resource. -""" +from bob.bio.base.transformers import PreprocessorTransformer +from bob.bio.base.transformers import ExtractorTransformer +from bob.bio.base.pipelines.vanilla_biometrics import ( + VanillaBiometricsPipeline, + BioAlgorithmLegacy, +) +from sklearn.pipeline import make_pipeline +from bob.pipelines import wrap -from ..preprocessor import NoCrop, TomesLeeMask, HuangNormalization, \ - NoFilter, Preprocessor +from bob.bio.vein.preprocessor import ( + NoCrop, + TomesLeeMask, + HuangNormalization, + NoFilter, + Preprocessor, +) +from bob.bio.vein.extractor import MaximumCurvature +from bob.bio.vein.algorithm import MiuraMatch + +"""Baseline updated with the wrapper for the pipelines package""" + +"""Sub-directory where temporary files are saved""" +sub_directory = 'rlt' +user_temp = Path("/idiap/") / "temp" / os.environ["USER"] +if user_temp.exists(): + # use /idiap/temp/<USER>/bob_bio_vein_tmp/<SUBDIRECTORY>/ + legacy_temp_dir = user_temp / "bob_bio_vein_tmp" / sub_directory +else: + # if /idiap/temp/<USER> does not exist, use /tmp/tmpxxxxxxxx + legacy_temp_dir = TemporaryDirectory().name -preprocessor = Preprocessor( - crop=NoCrop(), - mask=TomesLeeMask(), - normalize=HuangNormalization(), - filter=NoFilter(), - ) """Preprocessing using gray-level based finger cropping and no post-processing """ +preprocessor = PreprocessorTransformer( + Preprocessor( + crop=NoCrop(), + mask=TomesLeeMask(), + normalize=HuangNormalization(), + filter=NoFilter(), + ) +) -from ..extractor import MaximumCurvature -extractor = MaximumCurvature() """Features are the output of the maximum curvature algorithm, as described on [MNM05]_. Defaults taken from [TV13]_. """ +extractor = ExtractorTransformer(MaximumCurvature()) -# Notice the values of ch and cw are different than those from the -# repeated-line tracking baseline. -from ..algorithm import MiuraMatch -algorithm = MiuraMatch() """Miura-matching algorithm with specific settings for search displacement Defaults taken from [TV13]_. """ +biometric_algorithm = BioAlgorithmLegacy( + MiuraMatch(), base_dir=legacy_temp_dir +) + +transformer = make_pipeline(wrap(["sample"], preprocessor), wrap(["sample"], extractor)) +pipeline = VanillaBiometricsPipeline(transformer, biometric_algorithm) diff --git a/bob/bio/vein/configurations/repeated_line_tracking.py b/bob/bio/vein/configurations/repeated_line_tracking.py index 55702ef160d0fcccaaf75bf69af6ab50cac7189f..b88d0a832c91e5d9cdc991ed8b7d92638ea1301f 100644 --- a/bob/bio/vein/configurations/repeated_line_tracking.py +++ b/bob/bio/vein/configurations/repeated_line_tracking.py @@ -2,7 +2,7 @@ # vim: set fileencoding=utf-8 : # Tue 27 Sep 2016 16:48:08 CEST -'''Repeated-Line Tracking and Miura Matching baseline +"""Repeated-Line Tracking and Miura Matching baseline References: @@ -10,39 +10,65 @@ References: 2. [TV13]_ 3. [TVM14]_ -''' +""" +from tempfile import TemporaryDirectory +from pathlib import Path +import os -sub_directory = 'rlt' -"""Sub-directory where results will be placed. +from bob.bio.base.transformers import PreprocessorTransformer +from bob.bio.base.transformers import ExtractorTransformer +from bob.bio.base.pipelines.vanilla_biometrics import ( + VanillaBiometricsPipeline, + BioAlgorithmLegacy, +) +from sklearn.pipeline import make_pipeline +from bob.pipelines import wrap -You may change this setting using the ``--sub-directory`` command-line option -or the attribute ``sub_directory`` in a configuration file loaded **after** -this resource. -""" +from bob.bio.vein.preprocessor import ( + NoCrop, + TomesLeeMask, + HuangNormalization, + NoFilter, + Preprocessor, +) +from bob.bio.vein.extractor import RepeatedLineTracking +from bob.bio.vein.algorithm import MiuraMatch -from ..preprocessor import NoCrop, TomesLeeMask, HuangNormalization, \ - NoFilter, Preprocessor +"""Baseline updated with the wrapper for the pipelines package""" + +"""Sub-directory where temporary files are saved""" +sub_directory = 'rlt' +user_temp = Path("/idiap/") / "temp" / os.environ["USER"] +if user_temp.exists(): + # use /idiap/temp/<USER>/bob_bio_vein_tmp/<SUBDIRECTORY>/ + legacy_temp_dir = user_temp / "bob_bio_vein_tmp" / sub_directory +else: + # if /idiap/temp/<USER> does not exist, use /tmp/tmpxxxxxxxx + legacy_temp_dir = TemporaryDirectory().name -preprocessor = Preprocessor( - crop=NoCrop(), - mask=TomesLeeMask(), - normalize=HuangNormalization(), - filter=NoFilter(), - ) """Preprocessing using gray-level based finger cropping and no post-processing """ +preprocessor = PreprocessorTransformer( + Preprocessor( + crop=NoCrop(), + mask=TomesLeeMask(), + normalize=HuangNormalization(), + filter=NoFilter(), + ) +) -from ..extractor import RepeatedLineTracking - -extractor = RepeatedLineTracking() """Features are the output of repeated-line tracking, as described on [MNM04]_. Defaults taken from [TV13]_. """ +extractor = ExtractorTransformer(RepeatedLineTracking()) -from ..algorithm import MiuraMatch -algorithm = MiuraMatch(ch=65, cw=55) """Miura-matching algorithm with specific settings for search displacement Defaults taken from [TV13]_. """ +biometric_algorithm = BioAlgorithmLegacy( + MiuraMatch(ch=65, cw=55), base_dir=legacy_temp_dir +) +transformer = make_pipeline(wrap(["sample"], preprocessor), wrap(["sample"], extractor)) +pipeline = VanillaBiometricsPipeline(transformer, biometric_algorithm) diff --git a/bob/bio/vein/configurations/verafinger.py b/bob/bio/vein/configurations/verafinger.py index 7be25f8c1798585c76b10b904e7044fa9ad6fc3f..a62689692551b6d085a615947e7b96b2183e1ae2 100644 --- a/bob/bio/vein/configurations/verafinger.py +++ b/bob/bio/vein/configurations/verafinger.py @@ -19,7 +19,6 @@ from bob.bio.base.pipelines.vanilla_biometrics import DatabaseConnector _verafinger_directory = rc["bob.db.verafinger.directory"] """Value of ``~/.bobrc`` for this database""" - protocol = 'Nom' """The default protocol to use for tests @@ -34,14 +33,15 @@ test the vulnerability of a biometric recognition pipeline using the ``Nom`` protocol for enrollment and probe samples from presentation attacks. """ +"""Updated with the wrapper for the pipelines package""" database = DatabaseConnector(Database( - original_directory = _verafinger_directory, - original_extension = '.png', - protocol = protocol), + original_directory=_verafinger_directory, + original_extension='.png', + protocol=protocol), - annotation_type = None, - fixed_positions = None - ) + annotation_type=None, + fixed_positions=None +) """The :py:class:`bob.bio.base.database.BioDatabase` derivative with Verafinger database settings @@ -57,5 +57,3 @@ You must make sure to create ``${HOME}/.bob_bio_databases.txt`` setting this value to the place where you actually installed the Verafinger Database, as explained in the section :ref:`bob.bio.vein.baselines`. """ - - diff --git a/bob/bio/vein/configurations/wide_line_detector.py b/bob/bio/vein/configurations/wide_line_detector.py index 63ec6fd94beaf29288487f74ae3bb3dafa960a52..6341f126cbd35d82cf40fc6ae65353eb2dbcf485 100644 --- a/bob/bio/vein/configurations/wide_line_detector.py +++ b/bob/bio/vein/configurations/wide_line_detector.py @@ -11,6 +11,9 @@ References: 3. [TVM14]_ """ +from tempfile import TemporaryDirectory +from pathlib import Path +import os from bob.bio.base.transformers import PreprocessorTransformer from bob.bio.base.transformers import ExtractorTransformer @@ -29,6 +32,23 @@ from bob.bio.vein.preprocessor import ( Preprocessor, ) +from bob.bio.vein.extractor import WideLineDetector +from bob.bio.vein.algorithm import MiuraMatch + +"""Baseline updated with the wrapper for the pipelines package""" + +"""Sub-directory where temporary files are saved""" +sub_directory = 'wld' +user_temp = Path("/idiap/") / "temp" / os.environ["USER"] +if user_temp.exists(): + # use /idiap/temp/<USER>/bob_bio_vein_tmp/<SUBDIRECTORY>/ + legacy_temp_dir = user_temp / "bob_bio_vein_tmp" / sub_directory +else: + # if /idiap/temp/<USER> does not exist, use /tmp/tmpxxxxxxxx + legacy_temp_dir = TemporaryDirectory().name + +"""Preprocessing using gray-level based finger cropping and no post-processing +""" preprocessor = PreprocessorTransformer( Preprocessor( crop=NoCrop(), @@ -38,30 +58,23 @@ preprocessor = PreprocessorTransformer( ) ) +"""Features are the output of the maximum curvature algorithm, as described on +[HDLTL10]_. -"""Preprocessing using gray-level based finger cropping and no post-processing +Defaults taken from [TV13]_. """ +extractor = ExtractorTransformer(WideLineDetector()) -from bob.bio.vein.extractor import WideLineDetector -extractor = ExtractorTransformer(WideLineDetector()) -"""Features are the output of the maximum curvature algorithm, as described on -[HDLTL10]_. +"""Miura-matching algorithm with specific settings for search displacement Defaults taken from [TV13]_. """ - # Notice the values of ch and cw are different than those from the # repeated-line tracking **and** maximum curvature baselines. -from bob.bio.vein.algorithm import MiuraMatch - biometric_algorithm = BioAlgorithmLegacy( - MiuraMatch(ch=18, cw=28), base_dir="/idiap/temp/vbros/pipeline_test/verafinger" + MiuraMatch(ch=18, cw=28), base_dir=legacy_temp_dir ) -"""Miura-matching algorithm with specific settings for search displacement -Defaults taken from [TV13]_. -""" transformer = make_pipeline(wrap(["sample"], preprocessor), wrap(["sample"], extractor)) - pipeline = VanillaBiometricsPipeline(transformer, biometric_algorithm) diff --git a/setup.py b/setup.py index 05d616f7d68b22c4ac78dc0c760999e7658df0ac..041a39b3ece095441643e4b24d30df14ef270fa4 100644 --- a/setup.py +++ b/setup.py @@ -54,7 +54,9 @@ setup( ], 'bob.bio.pipeline': [ - 'wld = bob.bio.vein.configurations.wide_line_detector:pipeline' + 'wld = bob.bio.vein.configurations.wide_line_detector:pipeline', + 'mc = bob.bio.vein.configurations.maximum_curvature:pipeline', + 'rlt = bob.bio.vein.configurations.repeated_line_tracking:pipeline', ], 'console_scripts': [