diff --git a/bob/pad/face/config/aggregated_db.py b/bob/pad/face/config/aggregated_db.py deleted file mode 100644 index fa9d93a63e6775838229962aaa520a662b36a23a..0000000000000000000000000000000000000000 --- a/bob/pad/face/config/aggregated_db.py +++ /dev/null @@ -1,65 +0,0 @@ -#!/usr/bin/env python -"""Aggregated Db is a database for face PAD experiments. -This database aggregates the data from 3 publicly available data-sets: -`REPLAYATTACK`_, `REPLAY-MOBILE`_ and `MSU MFSD`_. -You can download the data for the above databases by following the corresponding -links. - -The reference citation for the `REPLAYATTACK`_ is [CAM12]_. -The reference citation for the `REPLAY-MOBILE`_ is [CBVM16]_. -The reference citation for the `MSU MFSD`_ is [WHJ15]_. - -.. include:: links.rst -""" - -from bob.pad.face.database import AggregatedDbPadDatabase - -# Directory where the data files are stored. -# This directory is given in the .bob_bio_databases.txt file located in your home directory -ORIGINAL_DIRECTORY = "[YOUR_AGGREGATED_DB_DIRECTORIES]" -"""Value of ``~/.bob_bio_databases.txt`` for this database""" - -ORIGINAL_EXTENSION = ".mov" # extension of the data files - -database = AggregatedDbPadDatabase( - protocol='grandtest', - original_directory=ORIGINAL_DIRECTORY, - original_extension=ORIGINAL_EXTENSION, - training_depends_on_protocol=True, -) -"""The :py:class:`bob.pad.base.database.PadDatabase` derivative with Aggregated Db -database settings. - -.. warning:: - - This class only provides a programmatic interface to load data in an orderly - manner, respecting usage protocols. It does **not** contain the raw - data files. You should procure those yourself. - -Notice that ``original_directory`` is set to ``[YOUR_AGGREGATED_DB_DIRECTORIES]``. -You must make sure to create ``${HOME}/.bob_bio_databases.txt`` file setting this -value to the places where you actually installed the Replay-Attack, Replay-Mobile -and MSU MFSD Databases. In particular, the paths pointing to these 3 databases -must be separated with a space. See the following note with an example of -``[YOUR_AGGREGATED_DB_DIRECTORIES]`` entry in the ``${HOME}/.bob_bio_databases.txt`` file. - -.. note:: - - [YOUR_AGGREGATED_DB_DIRECTORIES] = <PATH_TO_REPLAY_ATTACK> <PATH_TO_REPLAY_MOBILE> <PATH_TO_MSU_MFSD> -""" - -protocol = 'grandtest' -"""The default protocol to use for reproducing the baselines. - -You may modify this at runtime by specifying the option ``--protocol`` on the -command-line of ``spoof.py`` or using the keyword ``protocol`` on a -configuration file that is loaded **after** this configuration resource. -""" - -groups = ["train", "dev", "eval"] -"""The default groups to use for reproducing the baselines. - -You may modify this at runtime by specifying the option ``--groups`` on the -command-line of ``spoof.py`` or using the keyword ``groups`` on a -configuration file that is loaded **after** this configuration resource. -""" diff --git a/bob/pad/face/config/frame_diff_svm_aggregated_db.py b/bob/pad/face/config/frame_diff_svm_aggregated_db.py deleted file mode 100644 index bfc018637f8a5dbad94433651879dbd9a56ac5b2..0000000000000000000000000000000000000000 --- a/bob/pad/face/config/frame_diff_svm_aggregated_db.py +++ /dev/null @@ -1,95 +0,0 @@ -#!/usr/bin/env python2 -# -*- coding: utf-8 -*- -""" -This file contains configurations to run Frame Differences and SVM based face PAD baseline. -The settings of the preprocessor and extractor are tuned for the Replay-attack database. -In the SVM algorithm the amount of training data is reduced speeding-up the training for -large data sets, such as Aggregated PAD database. -The IQM features used in this algorithm/resource are introduced in the following papers: [WHJ15]_ and [CBVM16]_. -""" - -#======================================================================================= -sub_directory = 'frame_diff_svm' -""" -Sub-directory where results will be placed. - -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. -""" - -#======================================================================================= -# define preprocessor: - -from ..preprocessor import FrameDifference - -NUMBER_OF_FRAMES = None # process all frames -MIN_FACE_SIZE = 50 # Minimal size of the face to consider - -preprocessor = FrameDifference( - number_of_frames=NUMBER_OF_FRAMES, - min_face_size=MIN_FACE_SIZE) -""" -In the preprocessing stage the frame differences are computed for both facial and non-facial/background -regions. In this case all frames of the input video are considered, which is defined by -``number_of_frames = None``. The frames containing faces of the size below ``min_face_size = 50`` threshold -are discarded. Both RGB and gray-scale videos are acceptable by the preprocessor. -The preprocessing idea is introduced in [AM11]_. -""" - -#======================================================================================= -# define extractor: - -from ..extractor import FrameDiffFeatures - -WINDOW_SIZE = 20 -OVERLAP = 0 - -extractor = FrameDiffFeatures(window_size=WINDOW_SIZE, overlap=OVERLAP) -""" -In the feature extraction stage 5 features are extracted for all non-overlapping windows in -the Frame Difference input signals. Five features are computed for each of windows in the -facial face regions, the same is done for non-facial regions. The non-overlapping option -is controlled by ``overlap = 0``. The length of the window is defined by ``window_size`` -argument. -The features are introduced in the following paper: [AM11]_. -""" - -#======================================================================================= -# define algorithm: - -from bob.pad.base.algorithm import SVM - -MACHINE_TYPE = 'C_SVC' -KERNEL_TYPE = 'RBF' -N_SAMPLES = 10000 -TRAINER_GRID_SEARCH_PARAMS = { - 'cost': [2**P for P in range(-3, 14, 2)], - 'gamma': [2**P for P in range(-15, 0, 2)] -} -MEAN_STD_NORM_FLAG = True # enable mean-std normalization -FRAME_LEVEL_SCORES_FLAG = True # one score per frame(!) in this case -SAVE_DEBUG_DATA_FLAG = True # save the data, which might be useful for debugging -REDUCED_TRAIN_DATA_FLAG = True # reduce the amount of training data in the final training stage -N_TRAIN_SAMPLES = 50000 # number of training samples per class in the final SVM training stage - -algorithm = SVM( - machine_type=MACHINE_TYPE, - kernel_type=KERNEL_TYPE, - n_samples=N_SAMPLES, - trainer_grid_search_params=TRAINER_GRID_SEARCH_PARAMS, - mean_std_norm_flag=MEAN_STD_NORM_FLAG, - frame_level_scores_flag=FRAME_LEVEL_SCORES_FLAG, - save_debug_data_flag=SAVE_DEBUG_DATA_FLAG, - reduced_train_data_flag=REDUCED_TRAIN_DATA_FLAG, - n_train_samples=N_TRAIN_SAMPLES) -""" -The SVM algorithm with RBF kernel is used to classify the data into *real* and *attack* classes. -One score is produced for each frame of the input video, ``frame_level_scores_flag = True``. -The grid search of SVM parameters is used to select the successful settings. -The grid search is done on the subset of training data. -The size of this subset is defined by ``n_samples`` parameter. -The final training of the SVM is done on the subset of training data ``reduced_train_data_flag = True``. -The size of the subset for the final training stage is defined by the ``n_train_samples`` argument. -The data is also mean-std normalized, ``mean_std_norm_flag = True``. -""" diff --git a/bob/pad/face/config/lbp_svm_aggregated_db.py b/bob/pad/face/config/lbp_svm_aggregated_db.py deleted file mode 100644 index 27313a4cc8f889bd997f9571034915f3d2846c8b..0000000000000000000000000000000000000000 --- a/bob/pad/face/config/lbp_svm_aggregated_db.py +++ /dev/null @@ -1,119 +0,0 @@ -#!/usr/bin/env python2 -# -*- coding: utf-8 -*- -""" -This file contains configurations to run LBP and SVM based face PAD baseline. -The settings of the preprocessor and extractor are tuned for the Replay-attack database. -In the SVM algorithm the amount of training data is reduced speeding-up the training for -large data sets, such as Aggregated PAD database. -The idea of the algorithm is introduced in the following paper: [CAM12]_. -However some settings are different from the ones introduced in the paper. -""" - -#======================================================================================= -sub_directory = 'lbp_svm_aggregated_db' -""" -Sub-directory where results will be placed. - -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. -""" - -#======================================================================================= -# define preprocessor: - -from ..preprocessor import FaceCropAlign - -from bob.bio.video.preprocessor import Wrapper - -from bob.bio.video.utils import FrameSelector - -FACE_SIZE = 64 # The size of the resulting face -RGB_OUTPUT_FLAG = False # Gray-scale output -USE_FACE_ALIGNMENT = False # use annotations -MAX_IMAGE_SIZE = None # no limiting here -FACE_DETECTION_METHOD = None # use annotations -MIN_FACE_SIZE = 50 # skip small faces - -_image_preprocessor = FaceCropAlign(face_size = FACE_SIZE, - rgb_output_flag = RGB_OUTPUT_FLAG, - use_face_alignment = USE_FACE_ALIGNMENT, - max_image_size = MAX_IMAGE_SIZE, - face_detection_method = FACE_DETECTION_METHOD, - min_face_size = MIN_FACE_SIZE) - -_frame_selector = FrameSelector(selection_style = "all") - -preprocessor = Wrapper(preprocessor = _image_preprocessor, - frame_selector = _frame_selector) -""" -In the preprocessing stage the face is cropped in each frame of the input video given facial annotations. -The size of the face is normalized to ``FACE_SIZE`` dimensions. The faces with the size -below ``MIN_FACE_SIZE`` threshold are discarded. The preprocessor is similar to the one introduced in -[CAM12]_, which is defined by ``FACE_DETECTION_METHOD = None``. -""" - -#======================================================================================= -# define extractor: - -from ..extractor import LBPHistogram - -from bob.bio.video.extractor import Wrapper - -LBPTYPE = 'uniform' -ELBPTYPE = 'regular' -RAD = 1 -NEIGHBORS = 8 -CIRC = False -DTYPE = None - -extractor = Wrapper(LBPHistogram( - lbptype=LBPTYPE, - elbptype=ELBPTYPE, - rad=RAD, - neighbors=NEIGHBORS, - circ=CIRC, - dtype=DTYPE)) -""" -In the feature extraction stage the LBP histograms are extracted from each frame of the preprocessed video. -The parameters are similar to the ones introduced in [CAM12]_. -""" - -#======================================================================================= -# define algorithm: - -from bob.pad.base.algorithm import SVM - -MACHINE_TYPE = 'C_SVC' -KERNEL_TYPE = 'RBF' -N_SAMPLES = 10000 -TRAINER_GRID_SEARCH_PARAMS = { - 'cost': [2**P for P in range(-3, 14, 2)], - 'gamma': [2**P for P in range(-15, 0, 2)] -} -MEAN_STD_NORM_FLAG = True # enable mean-std normalization -FRAME_LEVEL_SCORES_FLAG = True # one score per frame(!) in this case -SAVE_DEBUG_DATA_FLAG = True # save the data, which might be useful for debugging -REDUCED_TRAIN_DATA_FLAG = True # reduce the amount of training data in the final training stage -N_TRAIN_SAMPLES = 50000 # number of training samples per class in the final SVM training stage - -algorithm = SVM( - machine_type=MACHINE_TYPE, - kernel_type=KERNEL_TYPE, - n_samples=N_SAMPLES, - trainer_grid_search_params=TRAINER_GRID_SEARCH_PARAMS, - mean_std_norm_flag=MEAN_STD_NORM_FLAG, - frame_level_scores_flag=FRAME_LEVEL_SCORES_FLAG, - save_debug_data_flag=SAVE_DEBUG_DATA_FLAG, - reduced_train_data_flag=REDUCED_TRAIN_DATA_FLAG, - n_train_samples=N_TRAIN_SAMPLES) -""" -The SVM algorithm with RBF kernel is used to classify the data into *real* and *attack* classes. -One score is produced for each frame of the input video, ``frame_level_scores_flag = True``. -The grid search of SVM parameters is used to select the successful settings. -The grid search is done on the subset of training data. -The size of this subset is defined by ``n_samples`` parameter. -The final training of the SVM is done on the subset of training data ``reduced_train_data_flag = True``. -The size of the subset for the final training stage is defined by the ``n_train_samples`` argument. -The data is also mean-std normalized, ``mean_std_norm_flag = True``. -""" diff --git a/bob/pad/face/config/maskattack.py b/bob/pad/face/config/maskattack.py index 5f5b96803ee949bd17304c7b468a877c89072bbc..173522bcc6cb8c938ee717c9a833d03e43d862b1 100644 --- a/bob/pad/face/config/maskattack.py +++ b/bob/pad/face/config/maskattack.py @@ -1,20 +1,3 @@ -#!/usr/bin/env python -"""`MSU MFSD`_ is a database for face PAD experiments. - -Database created at MSU, for face-PAD experiments. The public version of the database contains -280 videos corresponding to 35 clients. The videos are grouped as 'genuine' and 'attack'. -The attack videos have been constructed from the genuine ones, -and consist of three kinds: print, iPad (video-replay), and iPhone (video-replay). -Face-locations are also provided for each frame of each video, but some (6 videos) face-locations are not reliable, -because the videos are not correctly oriented. -The reference citation is [WHJ15]_. - -You can download the raw data of the `MSU MFSD`_ database by following -the link. - -.. include:: links.rst -""" - from bob.pad.face.database import MaskAttackPadDatabase # Directory where the data files are stored. @@ -29,17 +12,3 @@ database = MaskAttackPadDatabase( original_directory=original_directory, original_extension=original_extension, ) -"""The :py:class:`bob.pad.base.database.PadDatabase` derivative with MSU MFSD -database settings. - -.. warning:: - - This class only provides a programmatic interface to load data in an orderly - manner, respecting usage protocols. It does **not** contain the raw - data files. You should procure those yourself. - -Notice that ``original_directory`` is set to ``[YOUR_MSU_MFSD_DIRECTORY]``. -You must make sure to create ``${HOME}/.bob_bio_databases.txt`` setting this -value to the place where you actually installed the Replay-Mobile Database, as -explained in the section :ref:`bob.pad.face.baselines`. -""" diff --git a/bob/pad/face/config/msu_mfsd.py b/bob/pad/face/config/msu_mfsd.py deleted file mode 100644 index 7b91401aa70dca9be8529ecad8ce3433b144dec0..0000000000000000000000000000000000000000 --- a/bob/pad/face/config/msu_mfsd.py +++ /dev/null @@ -1,62 +0,0 @@ -#!/usr/bin/env python -"""`MSU MFSD`_ is a database for face PAD experiments. - -Database created at MSU, for face-PAD experiments. The public version of the database contains -280 videos corresponding to 35 clients. The videos are grouped as 'genuine' and 'attack'. -The attack videos have been constructed from the genuine ones, -and consist of three kinds: print, iPad (video-replay), and iPhone (video-replay). -Face-locations are also provided for each frame of each video, but some (6 videos) face-locations are not reliable, -because the videos are not correctly oriented. -The reference citation is [WHJ15]_. - -You can download the raw data of the `MSU MFSD`_ database by following -the link. - -.. include:: links.rst -""" - -from bob.pad.face.database import MsuMfsdPadDatabase - -# Directory where the data files are stored. -# This directory is given in the .bob_bio_databases.txt file located in your home directory -ORIGINAL_DIRECTORY = "[YOUR_MSU_MFSD_DIRECTORY]" -"""Value of ``~/.bob_bio_databases.txt`` for this database""" - -ORIGINAL_EXTENSION = "none" # extension is not used to load the data in the HLDI of this database - -database = MsuMfsdPadDatabase( - protocol='grandtest', - original_directory=ORIGINAL_DIRECTORY, - original_extension=ORIGINAL_EXTENSION, - training_depends_on_protocol=True, -) -"""The :py:class:`bob.pad.base.database.PadDatabase` derivative with MSU MFSD -database settings. - -.. warning:: - - This class only provides a programmatic interface to load data in an orderly - manner, respecting usage protocols. It does **not** contain the raw - data files. You should procure those yourself. - -Notice that ``original_directory`` is set to ``[YOUR_MSU_MFSD_DIRECTORY]``. -You must make sure to create ``${HOME}/.bob_bio_databases.txt`` setting this -value to the place where you actually installed the Replay-Mobile Database, as -explained in the section :ref:`bob.pad.face.baselines`. -""" - -protocol = 'grandtest' -"""The default protocol to use for reproducing the baselines. - -You may modify this at runtime by specifying the option ``--protocol`` on the -command-line of ``spoof.py`` or using the keyword ``protocol`` on a -configuration file that is loaded **after** this configuration resource. -""" - -groups = ["train", "dev", "eval"] -"""The default groups to use for reproducing the baselines. - -You may modify this at runtime by specifying the option ``--groups`` on the -command-line of ``spoof.py`` or using the keyword ``groups`` on a -configuration file that is loaded **after** this configuration resource. -""" diff --git a/bob/pad/face/config/qm_one_class_svm_aggregated_db.py b/bob/pad/face/config/qm_one_class_svm_aggregated_db.py deleted file mode 100644 index 3f010944feea8d5ebeb0c0cd05345d70aad65efd..0000000000000000000000000000000000000000 --- a/bob/pad/face/config/qm_one_class_svm_aggregated_db.py +++ /dev/null @@ -1,109 +0,0 @@ -#!/usr/bin/env python2 -# -*- coding: utf-8 -*- -""" -This file contains configurations to run Image Quality Measures (IQM) and one-class SVM based face PAD algorithm. -The settings of the preprocessor and extractor are tuned for the Replay-attack database. -In the SVM algorithm the amount of training data is reduced speeding-up the training for -large data sets, such as Aggregated PAD database. -The IQM features used in this algorithm/resource are introduced in the following papers: [WHJ15]_ and [CBVM16]_. -""" - -#======================================================================================= -sub_directory = 'qm_one_class_svm_aggregated_db' -""" -Sub-directory where results will be placed. - -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. -""" - -#======================================================================================= -# define preprocessor: - -from ..preprocessor import FaceCropAlign - -from bob.bio.video.preprocessor import Wrapper - -from bob.bio.video.utils import FrameSelector - -FACE_SIZE = 64 # The size of the resulting face -RGB_OUTPUT_FLAG = True # RGB output -USE_FACE_ALIGNMENT = False # use annotations -MAX_IMAGE_SIZE = None # no limiting here -FACE_DETECTION_METHOD = None # use annotations -MIN_FACE_SIZE = 50 # skip small faces - -_image_preprocessor = FaceCropAlign(face_size = FACE_SIZE, - rgb_output_flag = RGB_OUTPUT_FLAG, - use_face_alignment = USE_FACE_ALIGNMENT, - max_image_size = MAX_IMAGE_SIZE, - face_detection_method = FACE_DETECTION_METHOD, - min_face_size = MIN_FACE_SIZE) - -_frame_selector = FrameSelector(selection_style = "all") - -preprocessor = Wrapper(preprocessor = _image_preprocessor, - frame_selector = _frame_selector) -""" -In the preprocessing stage the face is cropped in each frame of the input video given facial annotations. -The size of the face is normalized to ``FACE_SIZE`` dimensions. The faces of the size -below ``MIN_FACE_SIZE`` threshold are discarded. The preprocessor is similar to the one introduced in -[CAM12]_, which is defined by ``FACE_DETECTION_METHOD = None``. The preprocessed frame is the RGB -facial image, which is defined by ``RGB_OUTPUT_FLAG = True``. -""" - -#======================================================================================= -# define extractor: - -from ..extractor import ImageQualityMeasure - -from bob.bio.video.extractor import Wrapper - -GALBALLY = True -MSU = True -DTYPE = None - -extractor = Wrapper(ImageQualityMeasure(galbally=GALBALLY, msu=MSU, dtype=DTYPE)) -""" -In the feature extraction stage the Image Quality Measures are extracted from each frame of the preprocessed RGB video. -The features to be computed are introduced in the following papers: [WHJ15]_ and [CBVM16]_. -""" - -#======================================================================================= -# define algorithm: - -from bob.pad.base.algorithm import SVM - -MACHINE_TYPE = 'ONE_CLASS' -KERNEL_TYPE = 'RBF' -N_SAMPLES = 50000 -TRAINER_GRID_SEARCH_PARAMS = { - 'nu': [0.001, 0.01, 0.05, 0.1], - 'gamma': [0.01, 0.1, 1, 10] -} -MEAN_STD_NORM_FLAG = True # enable mean-std normalization -FRAME_LEVEL_SCORES_FLAG = True # one score per frame(!) in this case -SAVE_DEBUG_DATA_FLAG = True # save the data, which might be useful for debugging -REDUCED_TRAIN_DATA_FLAG = False # DO NOT reduce the amount of training data in the final training stage -N_TRAIN_SAMPLES = 50000 # number of training samples per class in the final SVM training stage (NOT considered, because REDUCED_TRAIN_DATA_FLAG = False) - -algorithm = SVM( - machine_type=MACHINE_TYPE, - kernel_type=KERNEL_TYPE, - n_samples=N_SAMPLES, - trainer_grid_search_params=TRAINER_GRID_SEARCH_PARAMS, - mean_std_norm_flag=MEAN_STD_NORM_FLAG, - frame_level_scores_flag=FRAME_LEVEL_SCORES_FLAG, - save_debug_data_flag=SAVE_DEBUG_DATA_FLAG, - reduced_train_data_flag=REDUCED_TRAIN_DATA_FLAG, - n_train_samples=N_TRAIN_SAMPLES) -""" -The one-class SVM algorithm with RBF kernel is used to classify the data into *real* and *attack* classes. -One score is produced for each frame of the input video, ``frame_level_scores_flag = True``. -The grid search of SVM parameters is used to select the successful settings. -The grid search is done on the subset of training data. -The size of this subset is defined by ``n_samples`` parameter. -The final training of the SVM is done on all training data ``reduced_train_data_flag = False``. -The data is also mean-std normalized, ``mean_std_norm_flag = True``. -""" diff --git a/bob/pad/face/config/qm_one_class_svm_cascade_aggregated_db.py b/bob/pad/face/config/qm_one_class_svm_cascade_aggregated_db.py deleted file mode 100644 index f0f04b21dc343ac5bf958012b019120bfe029b61..0000000000000000000000000000000000000000 --- a/bob/pad/face/config/qm_one_class_svm_cascade_aggregated_db.py +++ /dev/null @@ -1,98 +0,0 @@ -#!/usr/bin/env python2 -# -*- coding: utf-8 -*- -""" -This file contains configurations to run Image Quality Measures (IQM) and SVM based face PAD baseline. -The settings of the preprocessor and extractor are tuned for the Replay-attack database. -In the SVM algorithm the amount of training data is reduced speeding-up the training for -large data sets, such as Aggregated PAD database. -The IQM features used in this algorithm/resource are introduced in the following papers: [WHJ15]_ and [CBVM16]_. -""" - -#======================================================================================= -sub_directory = 'qm_svm_aggregated_db' -""" -Sub-directory where results will be placed. - -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. -""" - -#======================================================================================= -# define preprocessor: - -from ..preprocessor import FaceCropAlign - -from bob.bio.video.preprocessor import Wrapper - -from bob.bio.video.utils import FrameSelector - -FACE_SIZE = 64 # The size of the resulting face -RGB_OUTPUT_FLAG = True # RGB output -USE_FACE_ALIGNMENT = False # use annotations -MAX_IMAGE_SIZE = None # no limiting here -FACE_DETECTION_METHOD = None # use annotations -MIN_FACE_SIZE = 50 # skip small faces - -_image_preprocessor = FaceCropAlign(face_size = FACE_SIZE, - rgb_output_flag = RGB_OUTPUT_FLAG, - use_face_alignment = USE_FACE_ALIGNMENT, - max_image_size = MAX_IMAGE_SIZE, - face_detection_method = FACE_DETECTION_METHOD, - min_face_size = MIN_FACE_SIZE) - -_frame_selector = FrameSelector(selection_style = "all") - -preprocessor = Wrapper(preprocessor = _image_preprocessor, - frame_selector = _frame_selector) -""" -In the preprocessing stage the face is cropped in each frame of the input video given facial annotations. -The size of the face is normalized to ``FACE_SIZE`` dimensions. The faces of the size -below ``MIN_FACE_SIZE`` threshold are discarded. The preprocessor is similar to the one introduced in -[CAM12]_, which is defined by ``FACE_DETECTION_METHOD = None``. The preprocessed frame is the RGB -facial image, which is defined by ``RGB_OUTPUT_FLAG = True``. -""" - -#======================================================================================= -# define extractor: - -from ..extractor import ImageQualityMeasure - -from bob.bio.video.extractor import Wrapper - -GALBALLY = True -MSU = True -DTYPE = None - -extractor = Wrapper(ImageQualityMeasure(galbally=GALBALLY, msu=MSU, dtype=DTYPE)) -""" -In the feature extraction stage the Image Quality Measures are extracted from each frame of the preprocessed RGB video. -The features to be computed are introduced in the following papers: [WHJ15]_ and [CBVM16]_. -""" - -#======================================================================================= -# define algorithm: - -from bob.pad.base.algorithm import SVMCascadePCA - -MACHINE_TYPE = 'ONE_CLASS' -KERNEL_TYPE = 'RBF' -SVM_KWARGS = {'nu': 0.001, 'gamma': 0.5} -N = 2 -POS_SCORES_SLOPE = 0.01 -FRAME_LEVEL_SCORES_FLAG = True - -algorithm = SVMCascadePCA( - machine_type=MACHINE_TYPE, - kernel_type=KERNEL_TYPE, - svm_kwargs=SVM_KWARGS, - N=N, - pos_scores_slope=POS_SCORES_SLOPE, - frame_level_scores_flag=FRAME_LEVEL_SCORES_FLAG) -""" -The cascade of one-class SVMs with RBF kernel is used to classify the data into *real* and *attack* classes. -One score is produced for each frame of the input video, ``frame_level_scores_flag = True``. -A single SVM in the cascade is trained using two features ``N = 2``. -The positive scores produced by the cascade are reduced by multiplying them with a constant -``pos_scores_slope = 0.01``. -""" diff --git a/bob/pad/face/config/qm_svm_aggregated_db.py b/bob/pad/face/config/qm_svm_aggregated_db.py deleted file mode 100644 index 8fafbbd5f277116557f4ec22517acb9832e6751b..0000000000000000000000000000000000000000 --- a/bob/pad/face/config/qm_svm_aggregated_db.py +++ /dev/null @@ -1,110 +0,0 @@ -#!/usr/bin/env python2 -# -*- coding: utf-8 -*- -""" -This file contains configurations to run Image Quality Measures (IQM) and SVM based face PAD baseline. -The settings of the preprocessor and extractor are tuned for the Replay-attack database. -In the SVM algorithm the amount of training data is reduced speeding-up the training for -large data sets, such as Aggregated PAD database. -The IQM features used in this algorithm/resource are introduced in the following papers: [WHJ15]_ and [CBVM16]_. -""" - -#======================================================================================= -sub_directory = 'qm_svm_aggregated_db' -""" -Sub-directory where results will be placed. - -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. -""" - -#======================================================================================= -# define preprocessor: - -from ..preprocessor import FaceCropAlign - -from bob.bio.video.preprocessor import Wrapper - -from bob.bio.video.utils import FrameSelector - -FACE_SIZE = 64 # The size of the resulting face -RGB_OUTPUT_FLAG = True # RGB output -USE_FACE_ALIGNMENT = False # use annotations -MAX_IMAGE_SIZE = None # no limiting here -FACE_DETECTION_METHOD = None # use annotations -MIN_FACE_SIZE = 50 # skip small faces - -_image_preprocessor = FaceCropAlign(face_size = FACE_SIZE, - rgb_output_flag = RGB_OUTPUT_FLAG, - use_face_alignment = USE_FACE_ALIGNMENT, - max_image_size = MAX_IMAGE_SIZE, - face_detection_method = FACE_DETECTION_METHOD, - min_face_size = MIN_FACE_SIZE) - -_frame_selector = FrameSelector(selection_style = "all") - -preprocessor = Wrapper(preprocessor = _image_preprocessor, - frame_selector = _frame_selector) -""" -In the preprocessing stage the face is cropped in each frame of the input video given facial annotations. -The size of the face is normalized to ``FACE_SIZE`` dimensions. The faces of the size -below ``MIN_FACE_SIZE`` threshold are discarded. The preprocessor is similar to the one introduced in -[CAM12]_, which is defined by ``FACE_DETECTION_METHOD = None``. The preprocessed frame is the RGB -facial image, which is defined by ``RGB_OUTPUT_FLAG = True``. -""" - -#======================================================================================= -# define extractor: - -from ..extractor import ImageQualityMeasure - -from bob.bio.video.extractor import Wrapper - -GALBALLY = True -MSU = True -DTYPE = None - -extractor = Wrapper(ImageQualityMeasure(galbally=GALBALLY, msu=MSU, dtype=DTYPE)) -""" -In the feature extraction stage the Image Quality Measures are extracted from each frame of the preprocessed RGB video. -The features to be computed are introduced in the following papers: [WHJ15]_ and [CBVM16]_. -""" - -#======================================================================================= -# define algorithm: - -from bob.pad.base.algorithm import SVM - -MACHINE_TYPE = 'C_SVC' -KERNEL_TYPE = 'RBF' -N_SAMPLES = 10000 -TRAINER_GRID_SEARCH_PARAMS = { - 'cost': [2**P for P in range(-3, 14, 2)], - 'gamma': [2**P for P in range(-15, 0, 2)] -} -MEAN_STD_NORM_FLAG = True # enable mean-std normalization -FRAME_LEVEL_SCORES_FLAG = True # one score per frame(!) in this case -SAVE_DEBUG_DATA_FLAG = True # save the data, which might be useful for debugging -REDUCED_TRAIN_DATA_FLAG = True # reduce the amount of training data in the final training stage -N_TRAIN_SAMPLES = 50000 # number of training samples per class in the final SVM training stage - -algorithm = SVM( - machine_type=MACHINE_TYPE, - kernel_type=KERNEL_TYPE, - n_samples=N_SAMPLES, - trainer_grid_search_params=TRAINER_GRID_SEARCH_PARAMS, - mean_std_norm_flag=MEAN_STD_NORM_FLAG, - frame_level_scores_flag=FRAME_LEVEL_SCORES_FLAG, - save_debug_data_flag=SAVE_DEBUG_DATA_FLAG, - reduced_train_data_flag=REDUCED_TRAIN_DATA_FLAG, - n_train_samples=N_TRAIN_SAMPLES) -""" -The SVM algorithm with RBF kernel is used to classify the data into *real* and *attack* classes. -One score is produced for each frame of the input video, ``frame_level_scores_flag = True``. -The grid search of SVM parameters is used to select the successful settings. -The grid search is done on the subset of training data. -The size of this subset is defined by ``n_samples`` parameter. -The final training of the SVM is done on the subset of training data ``reduced_train_data_flag = True``. -The size of the subset for the final training stage is defined by the ``n_train_samples`` argument. -The data is also mean-std normalized, ``mean_std_norm_flag = True``. -""" diff --git a/bob/pad/face/database/__init__.py b/bob/pad/face/database/__init__.py index db9961d0bd8f5d040feec580293c21348af4b2d9..63f053760b5a551ef3d732c63270109fd1e97e54 100644 --- a/bob/pad/face/database/__init__.py +++ b/bob/pad/face/database/__init__.py @@ -1,8 +1,6 @@ from .database import VideoPadFile from .replay import ReplayPadDatabase from .replay_mobile import ReplayMobilePadDatabase -from .msu_mfsd import MsuMfsdPadDatabase -from .aggregated_db import AggregatedDbPadDatabase from .mifs import MIFSPadDatabase from .batl import BatlPadDatabase from .celeb_a import CELEBAPadDatabase @@ -32,8 +30,6 @@ __appropriate__( VideoPadFile, ReplayPadDatabase, ReplayMobilePadDatabase, - MsuMfsdPadDatabase, - AggregatedDbPadDatabase, MIFSPadDatabase, BatlPadDatabase, CELEBAPadDatabase, diff --git a/bob/pad/face/database/aggregated_db.py b/bob/pad/face/database/aggregated_db.py deleted file mode 100644 index 6a30de5e72864cbc6d00590e3f927eb286ae4187..0000000000000000000000000000000000000000 --- a/bob/pad/face/database/aggregated_db.py +++ /dev/null @@ -1,1014 +0,0 @@ -#!/usr/bin/env python2 -# -*- coding: utf-8 -*- - -# ============================================================================= -from bob.pad.face.database import VideoPadFile - -from bob.pad.base.database import PadDatabase - -# Import HLDI for the databases to aggregate: -from bob.pad.face.database import replay as replay_hldi - -from bob.pad.face.database import replay_mobile as replay_mobile_hldi - -from bob.pad.face.database import msu_mfsd as msu_mfsd_hldi - -from bob.bio.video.database.mobio import MobioBioFile - -from bob.bio.video import FrameSelector, FrameContainer - -import numpy as np - -# ============================================================================= -class AggregatedDbPadFile(VideoPadFile): - """ - A high level implementation of the File class for the Aggregated Database - uniting 4 databases: REPLAY-ATTACK, REPLAY-MOBILE, MSU MFSD and Mobio. - """ - - def __init__(self, f): - """ - **Parameters:** - - ``f`` : :py:class:`object` - An instance of the File class defined in the low level db interface - of Replay-Attack, or Replay-Mobile, or MSU MFSD, or Mobio database, - respectively: - in the bob.db.replay.models.py file or - in the bob.db.replaymobile.models.py file or - in the bob.db.msu_mfsd_mod.models.py file or - in the bob.db.mobio.models.py file. - """ - - self.f = f - # this f is actually an instance of the File class that is defined in - # bob.db.<database_name>.models and the PadFile class here needs - # client_id, path, attack_type, file_id for initialization. We have to - # convert information here and provide them to PadFile. attack_type is a - # little tricky to get here. Based on the documentation of PadFile: - # In cased of a spoofed data, this parameter should indicate what kind of spoofed attack it is. - # The default None value is interpreted that the PadFile is a genuine or real sample. - - import bob.db.mobio - - if isinstance(f, bob.db.mobio.models.File - ): # MOBIO files doen't have is_real() method - - attack_type = None - - else: - - if f.is_real(): - attack_type = None - else: - attack_type = 'attack' - # attack_type is a string and I decided to make it like this for this - # particular database. You can do whatever you want for your own database. - - file_path = self.encode_file_path(f) - - file_id = self.encode_file_id(f) - - super(AggregatedDbPadFile, self).__init__( - client_id=f.client_id, - path=file_path, - attack_type=attack_type, - file_id=file_id) - - # ========================================================================= - def encode_file_id(self, f, n=2000): - """ - Return a modified version of the ``f.id`` ensuring uniqueness of the ids - across all databases. - - **Parameters:** - - ``f`` : :py:class:`object` - An instance of the File class defined in the low level db interface - of Replay-Attack, or Replay-Mobile, or MSU MFSD, or Mobio database, - respectively: - in the bob.db.replay.models.py file or - in the bob.db.replaymobile.models.py file or - in the bob.db.msu_mfsd_mod.models.py file or - in the bob.db.mobio.models.py file. - - ``n`` : :py:class:`int` - An offset to be added to the file id for different databases is defined - as follows: offset = k*n, where k is the database number, - k = 0,1,2 in our case. Default: 2000. - - **Returns:** - - ``file_id`` : :py:class:`int` - A modified version of the file id, which is now unigue accross - all databases. - """ - - import bob.db.replay - import bob.db.replaymobile - import bob.db.msu_mfsd_mod - import bob.db.mobio - - if isinstance( - f, bob.db.replay.models.File - ): # check if instance of File class of LLDI of Replay-Attack - - file_id = f.id - - if isinstance( - f, bob.db.replaymobile.models.File - ): # check if instance of File class of LLDI of Replay-Mobile - - file_id = np.int(f.id + n) - - if isinstance(f, bob.db.msu_mfsd_mod.models.File - ): # check if instance of File class of LLDI of MSU MFSD - - file_id = np.int(f.id + 2 * n) - - if isinstance(f, bob.db.mobio.models.File - ): # check if instance of File class of LLDI of Mobio - - file_id = np.int(f.id + 3 * n) - - return file_id - - # ========================================================================= - def encode_file_path(self, f): - """ - Append the name of the database to the end of the file path separated - with "_". - - **Parameters:** - - ``f`` : :py:class:`object` - An instance of the File class defined in the low level db interface - of Replay-Attack, or Replay-Mobile, or MSU MFSD, or Mobio database, - respectively: - in the bob.db.replay.models.py file or - in the bob.db.replaymobile.models.py file or - in the bob.db.msu_mfsd_mod.models.py file or - in the bob.db.mobio.models.py file. - - **Returns:** - - ``file_path`` : :py:class:`str` - Modified path to the file, with database name appended to the end - separated with "_". - """ - - import bob.db.replay - import bob.db.replaymobile - import bob.db.msu_mfsd_mod - import bob.db.mobio - - if isinstance( - f, bob.db.replay.models.File - ): # check if instance of File class of LLDI of Replay-Attack - - file_path = '_'.join([f.path, 'replay']) - - if isinstance( - f, bob.db.replaymobile.models.File - ): # check if instance of File class of LLDI of Replay-Mobile - - file_path = '_'.join([f.path, 'replaymobile']) - - if isinstance(f, bob.db.msu_mfsd_mod.models.File - ): # check if instance of File class of LLDI of MSU MFSD - - file_path = '_'.join([f.path, 'msu_mfsd_mod']) - - if isinstance(f, bob.db.mobio.models.File - ): # check if instance of File class of LLDI of Mobio - - file_path = '_'.join([f.path, 'mobio']) - - return file_path - - # ========================================================================= - def load(self, directory=None, extension='.mov', - frame_selector=FrameSelector(selection_style='all')): - """ - Overridden version of the load method defined in the ``VideoPadFile``. - - **Parameters:** - - ``directory`` : :py:class:`str` - String containing the paths to all databases used in this aggregated - database. The paths are separated with a space. - - ``extension`` : :py:class:`str` - Extension of the video files in the REPLAY-ATTACK and REPLAY-MOBILE - databases. The extension of files in MSU MFSD is not taken into account - in the HighLevel DB Interface of MSU MFSD. Default: '.mov'. - - **Returns:** - - ``video_data`` : FrameContainer - Video data stored in the FrameContainer, see ``bob.bio.video.utils.FrameContainer`` - for further details. - """ - - import bob.db.replay - import bob.db.replaymobile - import bob.db.msu_mfsd_mod - import bob.db.mobio - - directories = directory.split(" ") - - if isinstance( - self.f, bob.db.replay.models.File - ): # check if instance of File class of LLDI of Replay-Attack - - db_pad_file = replay_hldi.ReplayPadFile( - self.f) # replay_hldi is HLDI of Replay-Attack - - directory = directories[0] - - if isinstance( - self.f, bob.db.replaymobile.models.File - ): # check if instance of File class of LLDI of Replay-Mobile - - db_pad_file = replay_mobile_hldi.ReplayMobilePadFile( - self.f) # replay_mobile_hldi is HLDI of Replay-Mobile - - directory = directories[1] - - if isinstance(self.f, bob.db.msu_mfsd_mod.models.File - ): # check if instance of File class of LLDI of MSU MFSD - - db_pad_file = msu_mfsd_hldi.MsuMfsdPadFile( - self.f) # msu_mfsd_hldi is HLDI of MSU MFSD - - directory = directories[2] - - if isinstance(self.f, bob.db.mobio.models.File - ): # check if instance of File class of LLDI of Mobio - - db_pad_file = MobioBioFile( - self.f) # msu_mfsd_hldi is HLDI of MSU MFSD - - directory = directories[3] - - if isinstance(db_pad_file, bob.bio.video.database.mobio.MobioBioFile): - - video_data = db_pad_file.load( - directory=directory, - extension='.mp4', - frame_selector=frame_selector) - - else: - - video_data = db_pad_file.load( - directory=directory, - extension=extension, - frame_selector=frame_selector) - - return video_data # video data - - -# ============================================================================= -class AggregatedDbPadDatabase(PadDatabase): - """ - A high level implementation of the Database class for the Aggregated Database - uniting 3 databases: REPLAY-ATTACK, REPLAY-MOBILE and MSU MFSD. Currently this - database supports 5 protocols, which are listed in the ``available_protocols`` - argument of this class. - - Available protocols are: - - 1. "grandtest" - this protocol is using all the data available in the - databases Replay-Attack, Replay-Mobile, MSU MFSD. - - 2. "photo-photo-video" - this protocol is used to test the system on - unseen types of attacks. In this case the attacks are splitted - as follows: - 'train' set - only **photo** attacks are used for training, - 'dev' set - only **photo** attacks are used for threshold tuning, - 'eval' set - only **video** attacks are used in final evaluation. - In this case the final performance is estimated on previously - unseen **video** attacks. - - 3. "video-video-photo" - this protocol is used to test the system on - unseen types of attacks. In this case the attacks are splitted - as follows: - 'train' set - only **video** attacks are used for training, - 'dev' set - only **video** attacks are used for threshold tuning, - 'eval' set - only **photo** attacks are used in final evaluation. - In this case the final performance is estimated on previously - unseen **photo** attacks. - - 4. "grandtest-mobio" - this protocol is using all the data available in the - databases Replay-Attack, Replay-Mobile, MSU MFSD plus some additional data - from MOBIO dataset is used in the training set. - - 5. "grandtest-train-eval" - this protocol is using all the data available - in the databases Replay-Attack, Replay-Mobile, MSU MFSD. Only two gropus - 'train' and 'eval' are available in this protocol. The 'dev' set is - concatenated to the training data. When requesting 'dev' set, the - data of the 'eval' set is returned. - - 6. "grandtest-train-eval-<num_train_samples>" - - this protocol is using all the data available in the databases - Replay-Attack, Replay-Mobile, MSU MFSD. Only two gropus - 'train' and 'eval' are available in this protocol. The 'dev' set is - concatenated to the training data. When requesting 'dev' set, the - data of the 'eval' set is returned. - MOREOVER, in this protocol you can specify the number of training samples - <num_train_samples>, which will be uniformly selected for each database - (Replay-Attack, Replay-Mobile, MSU MFSD) used in the Aggregated DB. - For example, in the protocol "grandtest-train-eval-5", 5 training samples - will be selected for Replay-Attack, 5 for Replay-Mobile, and 5 for - MSU MFSD. The total number of training samples is 15 in this case. - """ - - def __init__( - self, - protocol='grandtest', # grandtest is the default protocol for this database - original_directory=None, - original_extension=None, - **kwargs): - """ - **Parameters:** - - ``protocol`` : :py:class:`str` or ``None`` - The name of the protocol that defines the default experimental setup - for this database. Default: 'grandtest'. - - ``original_directory`` : :py:class:`str` - String containing the paths to all databases used in this aggregated - database. The paths are separated with a space. Default: None. - - ``original_extension`` : :py:class:`str` - Extension of the video files in the REPLAY-ATTACK and REPLAY-MOBILE - databases. The extension of files in MSU MFSD is not taken into account - in the HighLevel DB Interface of MSU MFSD. Default: None. - - ``kwargs`` - The arguments of the :py:class:`bob.bio.base.database.BioDatabase` - base class constructor. - """ - - # Import LLDI for all databases: - import bob.db.replay - import bob.db.replaymobile - import bob.db.msu_mfsd_mod - import bob.db.mobio - - self.replay_db = bob.db.replay.Database() - self.replaymobile_db = bob.db.replaymobile.Database() - self.msu_mfsd_db = bob.db.msu_mfsd_mod.Database() - self.mobio = bob.db.mobio.Database() - - # Since the high level API expects different group names than what the low - # level API offers, you need to convert them when necessary - self.low_level_group_names = ( - 'train', 'devel', - 'test') # group names in the low-level database interface - self.high_level_group_names = ( - 'train', 'dev', - 'eval') # names are expected to be like that in objects() function - - # A list of available protocols: - self.available_protocols = [ - 'grandtest', 'photo-photo-video', 'video-video-photo', - 'grandtest-mobio', 'grandtest-train-eval', - 'grandtest-train-eval-<num_train_samples>'] - - # Always use super to call parent class methods. - super(AggregatedDbPadDatabase, self).__init__( - name='aggregated_db', - protocol=protocol, - original_directory=original_directory, - original_extension=original_extension, - **kwargs) - - # ========================================================================= - def get_mobio_files_given_single_group(self, groups=None, purposes=None): - """ - Get a list of files for the MOBIO database. All files are bona-fide - samples and used only for training. Thus, a non-empty list is returned - only when groups='train' and purposes='real'. - Only one file per client is selected. The files collected in Idiap are - excluded from training set to make sure identities in 'train' set don't - overlap with 'devel' and 'test' sets. - - **Parameters:** - - ``groups`` : :py:class:`str` - The group of which the clients should be returned. - One element of ('train', 'devel', 'test'). - - ``purposes`` : :py:class:`str` - OR a list of strings. - The purposes for which File objects should be retrieved. - Usually it is either 'real' or 'attack'. - - **Returns:** - - ``mobio_files`` : [File] - A list of files, as defined in the low level interface of the MOBIO - database. - """ - - mobio_files = [] - - if (groups is not None) and ('train' in groups) and ( - purposes is not None) and ('real' in purposes): - - files_mobio = self.mobio.all_files() - - metadata = [] - - for f in files_mobio: - - metadata.append((f.client_id)) - - metadata_set = list( - set(metadata)) # metadata_set is a list of unique client ids - - for f in files_mobio: - - metadata = (f.client_id) - - if metadata in metadata_set: # only one video per client id is selected - - metadata_set.remove(metadata) - - if "idiap" not in f.path: - # videos collected at idiap are excluded to make sure identities in train set dont overlap with dev and test sets. - mobio_files.append(f) - - return mobio_files - - # ========================================================================= - def uniform_select_list_elements(self, data, n_samples): - """ - Uniformly select N elements from the input data list. - - **Parameters:** - - ``data`` : [] - Input list to select elements from. - - ``n_samples`` : :py:class:`int` - The number of samples to be selected uniformly from the input list. - - **Returns:** - - ``selected_data`` : [] - Selected subset of elements. - """ - - if len(data) <= n_samples: - - selected_data = data - - else: - - uniform_step = len(data) / np.float(n_samples + 1) - - idxs = [int(np.round(uniform_step * (x + 1))) - for x in range(n_samples)] - - selected_data = [data[idx] for idx in idxs] - - return selected_data - - # ========================================================================= - def get_files_given_single_group(self, - groups=None, - protocol=None, - purposes=None, - model_ids=None, - **kwargs): - """ - This function returns 4 lists of files for Raplay-Attack, Replay-Mobile, - MSU MFSD and MOBIO databases, which fulfill the given restrictions. This - function for the groups parameter accepts a single string ONLY, which - determines the low level name of the group, see ``low_level_group_names`` - argument of this class for available options. - - **Parameters:** - - ``groups`` : :py:class:`str` - The group of which the clients should be returned. - One element of ('train', 'devel', 'test'). - - ``protocol`` : :py:class:`str` - The protocol for which the clients should be retrieved. - Available options are defined in the ``available_protocols`` argument - of the class. So far the following protocols are available: - - 1. "grandtest" - this protocol is using all the data available in the - databases Replay-Attack, Replay-Mobile, MSU MFSD. - - 2. "photo-photo-video" - this protocol is used to test the system on - unseen types of attacks. In this case the attacks are splitted - as follows: - 'train' set - only **photo** attacks are used for training, - 'dev' set - only **photo** attacks are used for threshold tuning, - 'eval' set - only **video** attacks are used in final evaluation. - In this case the final performance is estimated on previously - unseen **video** attacks. - - 3. "video-video-photo" - this protocol is used to test the system on - unseen types of attacks. In this case the attacks are splitted - as follows: - 'train' set - only **video** attacks are used for training, - 'dev' set - only **video** attacks are used for threshold tuning, - 'eval' set - only **photo** attacks are used in final evaluation. - In this case the final performance is estimated on previously - unseen **photo** attacks. - - 4. "grandtest-mobio" - this protocol is using all the data available in the - databases Replay-Attack, Replay-Mobile, MSU MFSD plus some additional data - from MOBIO dataset is used in the training set. - - 5. "grandtest-train-eval" - this protocol is using all the data available - in the databases Replay-Attack, Replay-Mobile, MSU MFSD. Only two gropus - 'train' and 'test' are available in this protocol. The 'devel' set is - concatenated to the training data. When requesting 'devel' set, the - data of the 'test' set is returned. - - 6. "grandtest-train-eval-<num_train_samples>" - - this protocol is using all the data available in the databases - Replay-Attack, Replay-Mobile, MSU MFSD. Only two gropus - 'train' and 'eval' are available in this protocol. The 'dev' set is - concatenated to the training data. When requesting 'dev' set, the - data of the 'eval' set is returned. - MOREOVER, in this protocol you can specify the number of training samples - <num_train_samples>, which will be uniformly selected for each database - (Replay-Attack, Replay-Mobile, MSU MFSD) used in the Aggregated DB. - For example, in the protocol "grandtest-train-eval-5", 5 training samples - will be selected for Replay-Attack, 5 for Replay-Mobile, and 5 for - MSU MFSD. The total number of training samples is 15 in this case. - - ``purposes`` : :py:class:`str` - OR a list of strings. - The purposes for which File objects should be retrieved. - Usually it is either 'real' or 'attack'. - - ``model_ids`` - This parameter is not supported in PAD databases yet - - **Returns:** - - ``replay_files`` : [File] - A list of files corresponding to Replay-Attack database. - - ``replaymobile_files`` : [File] - A list of files corresponding to Replay-Mobile database. - - ``msu_mfsd_files`` : [File] - A list of files corresponding to MSU MFSD database. - - ``mobio_files`` : [File] - A list of files corresponding to MOBIO database or an empty list. - """ - - if protocol == 'grandtest' or protocol is None or groups is None: - - replay_files = self.replay_db.objects( - protocol=protocol, groups=groups, cls=purposes, **kwargs) - - replaymobile_files = self.replaymobile_db.objects( - protocol=protocol, groups=groups, cls=purposes, **kwargs) - - msu_mfsd_files = self.msu_mfsd_db.objects( - group=groups, cls=purposes, **kwargs) - - if protocol == 'photo-photo-video': - - # the group names are low-level here: ('train', 'devel', 'test') - if groups == 'train' or groups == 'devel': - - replay_files = self.replay_db.objects( - protocol='photo', groups=groups, cls=purposes, **kwargs) - - replaymobile_files = self.replaymobile_db.objects( - protocol='grandtest', - groups=groups, - cls=purposes, - sample_type='photo', - **kwargs) - - msu_mfsd_files = self.msu_mfsd_db.objects( - group=groups, - cls=purposes, - instrument=('print', ''), - **kwargs) - - if groups == 'test': - - replay_files = self.replay_db.objects( - protocol='video', groups=groups, cls=purposes, **kwargs) - - replaymobile_files = self.replaymobile_db.objects( - protocol='grandtest', - groups=groups, - cls=purposes, - sample_type='video', - **kwargs) - - msu_mfsd_files = self.msu_mfsd_db.objects( - group=groups, - cls=purposes, - instrument=('video_hd', 'video_mobile', ''), - **kwargs) - - if protocol == 'video-video-photo': - - # the group names are low-level here: ('train', 'devel', 'test') - if groups == 'train' or groups == 'devel': - - replay_files = self.replay_db.objects( - protocol='video', groups=groups, cls=purposes, **kwargs) - - replaymobile_files = self.replaymobile_db.objects( - protocol='grandtest', - groups=groups, - cls=purposes, - sample_type='video', - **kwargs) - - msu_mfsd_files = self.msu_mfsd_db.objects( - group=groups, - cls=purposes, - instrument=('video_hd', 'video_mobile', ''), - **kwargs) - - if groups == 'test': - - replay_files = self.replay_db.objects( - protocol='photo', groups=groups, cls=purposes, **kwargs) - - replaymobile_files = self.replaymobile_db.objects( - protocol='grandtest', - groups=groups, - cls=purposes, - sample_type='photo', - **kwargs) - - msu_mfsd_files = self.msu_mfsd_db.objects( - group=groups, - cls=purposes, - instrument=('print', ''), - **kwargs) - - mobio_files = [] - - if protocol == 'grandtest-mobio': - - replay_files = self.replay_db.objects( - protocol='grandtest', groups=groups, cls=purposes, **kwargs) - - replaymobile_files = self.replaymobile_db.objects( - protocol='grandtest', groups=groups, cls=purposes, **kwargs) - - msu_mfsd_files = self.msu_mfsd_db.objects( - group=groups, cls=purposes, **kwargs) - - mobio_files = self.get_mobio_files_given_single_group( - groups=groups, purposes=purposes) - - if protocol is not None: - - if 'grandtest-train-eval' in protocol: - - if groups == 'train': - - replay_files = self.replay_db.objects( - protocol='grandtest', - groups=['train', 'devel'], - cls=purposes, - **kwargs) - - replaymobile_files = self.replaymobile_db.objects( - protocol='grandtest', - groups=['train', 'devel'], - cls=purposes, - **kwargs) - - msu_mfsd_files = self.msu_mfsd_db.objects( - group=['train', 'devel'], cls=purposes, **kwargs) - - if len(protocol) > len('grandtest-train-eval'): - - num_train_samples = [ - int(s) for s in protocol.split("-") if s.isdigit()][-1] - - replay_files = self.uniform_select_list_elements( - data=replay_files, n_samples=num_train_samples) - replaymobile_files = self.uniform_select_list_elements( - data=replaymobile_files, n_samples=num_train_samples) - msu_mfsd_files = self.uniform_select_list_elements( - data=msu_mfsd_files, n_samples=num_train_samples) - - if groups in ['devel', 'test']: - - replay_files = self.replay_db.objects( - protocol='grandtest', - groups='test', - cls=purposes, - **kwargs) - - replaymobile_files = self.replaymobile_db.objects( - protocol='grandtest', - groups='test', - cls=purposes, - **kwargs) - - msu_mfsd_files = self.msu_mfsd_db.objects( - group='test', cls=purposes, **kwargs) - - return replay_files, replaymobile_files, msu_mfsd_files, mobio_files - - # ========================================================================= - def get_files_given_groups(self, - groups=None, - protocol=None, - purposes=None, - model_ids=None, - **kwargs): - """ - This function returns 4 lists of files for Raplay-Attack, Replay-Mobile, - MSU MFSD and MOBIO databases, which fulfill the given restrictions. This - function for the groups parameter accepts a single string OR a list - of strings with multiple groups. Group names are low level, see - ``low_level_group_names`` argument of the class for available options. - - Keyword parameters: - - ``groups`` : :py:class:`str` - OR a list of strings. - The groups of which the clients should be returned. - Usually, groups are one or more elements of ('train', 'devel', 'test'). - - ``protocol`` : :py:class:`str` - The protocol for which the clients should be retrieved. - Available options are defined in the ``available_protocols`` argument - of the class. So far the following protocols are available: - - 1. "grandtest" - this protocol is using all the data available in the - databases Replay-Attack, Replay-Mobile, MSU MFSD. - - 2. "photo-photo-video" - this protocol is used to test the system on - unseen types of attacks. In this case the attacks are splitted - as follows: - 'train' set - only **photo** attacks are used for training, - 'dev' set - only **photo** attacks are used for threshold tuning, - 'eval' set - only **video** attacks are used in final evaluation. - In this case the final performance is estimated on previously - unseen **video** attacks. - - 3. "video-video-photo" - this protocol is used to test the system on - unseen types of attacks. In this case the attacks are splitted - as follows: - 'train' set - only **video** attacks are used for training, - 'dev' set - only **video** attacks are used for threshold tuning, - 'eval' set - only **photo** attacks are used in final evaluation. - In this case the final performance is estimated on previously - unseen **photo** attacks. - - 4. "grandtest-mobio" - this protocol is using all the data available in the - databases Replay-Attack, Replay-Mobile, MSU MFSD plus some additional data - from MOBIO dataset is used in the training set. - - 5. "grandtest-train-eval" - this protocol is using all the data available - in the databases Replay-Attack, Replay-Mobile, MSU MFSD. Only two gropus - 'train' and 'test' are available in this protocol. The 'devel' set is - concatenated to the training data. When requesting 'devel' set, the - data of the 'test' set is returned. - - 6. "grandtest-train-eval-<num_train_samples>" - - this protocol is using all the data available in the databases - Replay-Attack, Replay-Mobile, MSU MFSD. Only two gropus - 'train' and 'eval' are available in this protocol. The 'dev' set is - concatenated to the training data. When requesting 'dev' set, the - data of the 'eval' set is returned. - MOREOVER, in this protocol you can specify the number of training samples - <num_train_samples>, which will be uniformly selected for each database - (Replay-Attack, Replay-Mobile, MSU MFSD) used in the Aggregated DB. - For example, in the protocol "grandtest-train-eval-5", 5 training samples - will be selected for Replay-Attack, 5 for Replay-Mobile, and 5 for - MSU MFSD. The total number of training samples is 15 in this case. - - ``purposes`` : :py:class:`str` - OR a list of strings. - The purposes for which File objects should be retrieved. - Usually it is either 'real' or 'attack'. - - ``model_ids`` - This parameter is not supported in PAD databases yet - - **Returns:** - - ``replay_files`` : [File] - A list of files corresponding to Replay-Attack database. - - ``replaymobile_files`` : [File] - A list of files corresponding to Replay-Mobile database. - - ``msu_mfsd_files`` : [File] - A list of files corresponding to MSU MFSD database. - - ``mobio_files`` : [File] - A list of files corresponding to MOBIO database or an empty list. - """ - - if isinstance(groups, - str) or groups is None: # if a single group is given - - groups = [groups] - - replay_files = [] - - replaymobile_files = [] - - msu_mfsd_files = [] - - mobio_files = [] - - for group in groups: - - files = self.get_files_given_single_group( - groups=group, - protocol=protocol, - purposes=purposes, - model_ids=model_ids, - **kwargs) - - replay_files += files[0] - - replaymobile_files += files[1] - - msu_mfsd_files += files[2] - - mobio_files += files[3] - - return replay_files, replaymobile_files, msu_mfsd_files, mobio_files - - # ========================================================================= - def objects(self, - groups=None, - protocol=None, - purposes=None, - model_ids=None, - **kwargs): - """ - This function returns a list of AggregatedDbPadFile objects, which fulfill the given restrictions. - - Keyword parameters: - - ``groups`` : :py:class:`str` - OR a list of strings. - The groups of which the clients should be returned. - Usually, groups are one or more elements of ('train', 'dev', 'eval') - - ``protocol`` : :py:class:`str` - The protocol for which the clients should be retrieved. - Available options are defined in the ``available_protocols`` argument - of the class. So far the following protocols are available: - - 1. "grandtest" - this protocol is using all the data available in the - databases Replay-Attack, Replay-Mobile, MSU MFSD. - - 2. "photo-photo-video" - this protocol is used to test the system on - unseen types of attacks. In this case the attacks are splitted - as follows: - 'train' set - only **photo** attacks are used for training, - 'dev' set - only **photo** attacks are used for threshold tuning, - 'eval' set - only **video** attacks are used in final evaluation. - In this case the final performance is estimated on previously - unseen **video** attacks. - - 3. "video-video-photo" - this protocol is used to test the system on - unseen types of attacks. In this case the attacks are splitted - as follows: - 'train' set - only **video** attacks are used for training, - 'dev' set - only **video** attacks are used for threshold tuning, - 'eval' set - only **photo** attacks are used in final evaluation. - In this case the final performance is estimated on previously - unseen **photo** attacks. - - 4. "grandtest-mobio" - this protocol is using all the data available in the - databases Replay-Attack, Replay-Mobile, MSU MFSD plus some additional data - from MOBIO dataset is used in the training set. - - 5. "grandtest-train-eval" - this protocol is using all the data available - in the databases Replay-Attack, Replay-Mobile, MSU MFSD. Only two gropus - 'train' and 'eval' are available in this protocol. The 'dev' set is - concatenated to the training data. When requesting 'dev' set, the - data of the 'eval' set is returned. - - 6. "grandtest-train-eval-<num_train_samples>" - - this protocol is using all the data available in the databases - Replay-Attack, Replay-Mobile, MSU MFSD. Only two gropus - 'train' and 'eval' are available in this protocol. The 'dev' set is - concatenated to the training data. When requesting 'dev' set, the - data of the 'eval' set is returned. - MOREOVER, in this protocol you can specify the number of training samples - <num_train_samples>, which will be uniformly selected for each database - (Replay-Attack, Replay-Mobile, MSU MFSD) used in the Aggregated DB. - For example, in the protocol "grandtest-train-eval-5", 5 training samples - will be selected for Replay-Attack, 5 for Replay-Mobile, and 5 for - MSU MFSD. The total number of training samples is 15 in this case. - - ``purposes`` : :py:class:`str` - OR a list of strings. - The purposes for which File objects should be retrieved. - Usually it is either 'real' or 'attack'. - - ``model_ids`` - This parameter is not supported in PAD databases yet - - **Returns:** - - ``files`` : [AggregatedDbPadFile] - A list of AggregatedDbPadFile objects. - """ - - # Convert group names to low-level group names here. - groups = self.convert_names_to_lowlevel( - groups, self.low_level_group_names, self.high_level_group_names) - # Since this database was designed for PAD experiments, nothing special - # needs to be done here. - - replay_files, replaymobile_files, msu_mfsd_files, mobio_files = self.get_files_given_groups( - groups=groups, - protocol=protocol, - purposes=purposes, - model_ids=model_ids, - **kwargs) - - files = replay_files + replaymobile_files + msu_mfsd_files + \ - mobio_files # append all files to a single list - - files = [AggregatedDbPadFile(f) for f in files] - - return files - - # ========================================================================= - def annotations(self, f): - """ - Return annotations for a given file object ``f``, which is an instance - of ``AggregatedDbPadFile`` defined in the HLDI of the Aggregated DB. - The ``load()`` method of ``AggregatedDbPadFile`` class (see above) - returns a video, therefore this method returns bounding-box annotations - for each video frame. The annotations are returned as dictionary of - dictionaries. - - **Parameters:** - - ``f`` : :py:class:`object` - An instance of ``AggregatedDbPadFile`` defined above. - - **Returns:** - - ``annotations`` : :py:class:`dict` - A dictionary containing the annotations for each frame in the video. - Dictionary structure: ``annotations = {'1': frame1_dict, '2': frame1_dict, ...}``. - Where ``frameN_dict = {'topleft': (row, col), 'bottomright': (row, col)}`` - is the dictionary defining the coordinates of the face bounding box in frame N. - - """ - - import bob.db.replay - import bob.db.replaymobile - import bob.db.msu_mfsd_mod - - directories = self.original_directory.split(" ") - - if isinstance( - f.f, bob.db.replay.models.File - ): # check if instance of File class of LLDI of Replay-Attack - - hldi_db = replay_hldi.ReplayPadDatabase( - original_directory=directories[0]) - - if isinstance( - f.f, bob.db.replaymobile.models.File - ): # check if instance of File class of LLDI of Replay-Mobile - - hldi_db = replay_mobile_hldi.ReplayMobilePadDatabase( - original_directory=directories[1]) - - if isinstance(f.f, bob.db.msu_mfsd_mod.models.File - ): # check if instance of File class of LLDI of MSU MFSD - - hldi_db = msu_mfsd_hldi.MsuMfsdPadDatabase( - original_directory=directories[2]) - - if self.protocol == "grandtest-mobio" or isinstance( - f.f, bob.db.mobio.models.File - ): # annotations are not available for this protocol - - annotations = {} - - else: - - annotations = hldi_db.annotations(f) - - return annotations diff --git a/bob/pad/face/database/msu_mfsd.py b/bob/pad/face/database/msu_mfsd.py deleted file mode 100644 index 59e055a8dad5d6c00e4f43df64cee32ae6856580..0000000000000000000000000000000000000000 --- a/bob/pad/face/database/msu_mfsd.py +++ /dev/null @@ -1,236 +0,0 @@ -#!/usr/bin/env python2 -# -*- coding: utf-8 -*- - -from bob.bio.video import FrameSelector, FrameContainer -from bob.pad.face.database import VideoPadFile # Used in MsuMfsdPadFile class -from bob.pad.base.database import PadDatabase -from bob.extension import rc -import os -import numpy as np - - -class MsuMfsdPadFile(VideoPadFile): - """ - A high level implementation of the File class for the MSU MFSD database. - """ - - def __init__(self, f): - """ - **Parameters:** - - ``f`` : :py:class:`object` - An instance of the File class defined in the low level db interface - of the MSU MFSD database, in the bob.db.msu_mfsd_mod.models.py file. - """ - - self.f = f - # this f is actually an instance of the File class that is defined in - # bob.db.msu_mfsd_mod.models and the PadFile class here needs - # client_id, path, attack_type, file_id for initialization. We have to - # convert information here and provide them to PadFile. attack_type is a - # little tricky to get here. Based on the documentation of PadFile: - # In cased of a spoofed data, this parameter should indicate what kind of spoofed attack it is. - # The default None value is interpreted that the PadFile is a genuine or real sample. - if f.is_real(): - attack_type = None - else: - attack_type = "attack" - # attack_type is a string and I decided to make it like this for this - # particular database. You can do whatever you want for your own database. - - super(MsuMfsdPadFile, self).__init__( - client_id=f.client_id, path=f.path, attack_type=attack_type, file_id=f.id - ) - - def load( - self, - directory=None, - extension=None, - frame_selector=FrameSelector(selection_style="all"), - ): - """ - Overridden version of the load method defined in the ``VideoPadFile``. - - **Parameters:** - - ``directory`` : :py:class:`str` - String containing the path to the MSU MFSD database. - Default: None - - ``extension`` : :py:class:`str` - Extension of the video files in the MSU MFSD database. - Note: ``extension`` value is not used in the code of this method. - Default: None - - ``frame_selector`` : ``FrameSelector`` - The frame selector to use. - - **Returns:** - - ``video_data`` : FrameContainer - Video data stored in the FrameContainer, see ``bob.bio.video.utils.FrameContainer`` - for further details. - """ - - _, extension = os.path.splitext(self.f.videofile()) # get file extension - - video_data_array = self.f.load(directory=directory, extension=extension) - return frame_selector(video_data_array) - - -class MsuMfsdPadDatabase(PadDatabase): - """ - A high level implementation of the Database class for the MSU MFSD database. - """ - - def __init__( - self, - protocol="grandtest", # grandtest is the default protocol for this database - original_directory=None, - original_extension=None, - annotation_directory=None, - annotation_extension='.json', - annotation_type='json', - **kwargs - ): - """ - **Parameters:** - - ``protocol`` : :py:class:`str` or ``None`` - The name of the protocol that defines the default experimental setup for this database. - - ``original_directory`` : :py:class:`str` - The directory where the original data of the database are stored. - - ``original_extension`` : :py:class:`str` - The file name extension of the original data. - - ``kwargs`` - The arguments of the :py:class:`bob.bio.base.database.BioDatabase` base class constructor. - """ - - from bob.db.msu_mfsd_mod import Database as LowLevelDatabase - - self.db = LowLevelDatabase() - - # Since the high level API expects different group names than what the low - # level API offers, you need to convert them when necessary - self.low_level_group_names = ( - "train", - "devel", - "test", - ) # group names in the low-level database interface - self.high_level_group_names = ( - "train", - "dev", - "eval", - ) # names are expected to be like that in objects() function - - # Always use super to call parent class methods. - super(MsuMfsdPadDatabase, self).__init__( - name="msu-mfsd", - protocol=protocol, - original_directory=original_directory, - original_extension=original_extension, - **kwargs - ) - - @property - def original_directory(self): - return self.db.original_directory - - @original_directory.setter - def original_directory(self, value): - self.db.original_directory = value - - def objects( - self, groups=None, protocol=None, purposes=None, model_ids=None, **kwargs - ): - """ - This function returns lists of MsuMfsdPadFile objects, which fulfill the given restrictions. - - Keyword parameters: - - ``groups`` : :py:class:`str` - OR a list of strings. - The groups of which the clients should be returned. - Usually, groups are one or more elements of ('train', 'dev', 'eval') - - ``protocol`` : :py:class:`str` - The protocol for which the clients should be retrieved. - Note: this argument is not used in the code, because ``objects`` method of the - low-level BD interface of the MSU MFSD doesn't have ``protocol`` argument. - - ``purposes`` : :py:class:`str` - OR a list of strings. - The purposes for which File objects should be retrieved. - Usually it is either 'real' or 'attack'. - - ``model_ids`` - This parameter is not supported in PAD databases yet. - - **Returns:** - - ``files`` : [MsuMfsdPadFile] - A list of MsuMfsdPadFile objects. - """ - - # Convert group names to low-level group names here. - groups = self.convert_names_to_lowlevel( - groups, self.low_level_group_names, self.high_level_group_names - ) - # Since this database was designed for PAD experiments, nothing special - # needs to be done here. - files = self.db.objects(group=groups, cls=purposes, **kwargs) - - files = [MsuMfsdPadFile(f) for f in files] - for f in files: - f.original_directory = self.original_directory - f.annotation_directory = self.annotation_directory - f.annotation_extension = self.annotation_extension - f.annotation_type = self.annotation_type - - return files - - def annotations(self, f): - """ - Return annotations for a given file object ``f``, which is an instance - of ``MsuMfsdPadFile`` defined in the HLDI of the MSU MFSD DB. - The ``load()`` method of ``MsuMfsdPadFile`` class (see above) - returns a video, therefore this method returns bounding-box annotations - for each video frame. The annotations are returned as dictionary of dictionaries. - - **Parameters:** - - ``f`` : :py:class:`object` - An instance of ``MsuMfsdPadFile`` defined above. - - **Returns:** - - ``annotations`` : :py:class:`dict` - A dictionary containing the annotations for each frame in the video. - Dictionary structure: ``annotations = {'1': frame1_dict, '2': frame1_dict, ...}``. - Where ``frameN_dict = {'topleft': (row, col), 'bottomright': (row, col)}`` - is the dictionary defining the coordinates of the face bounding box in frame N. - """ - - annots = f.f.bbx( - directory=self.original_directory - ) # numpy array containing the face bounding box data for each video frame, returned data format described in the f.bbx() method of the low level interface - - annotations = {} # dictionary to return - - for frame_annots in annots: - - topleft = (np.int(frame_annots[2]), np.int(frame_annots[1])) - bottomright = ( - np.int(frame_annots[2] + frame_annots[4]), - np.int(frame_annots[1] + frame_annots[3]), - ) - - annotations[str(np.int(frame_annots[0]))] = { - "topleft": topleft, - "bottomright": bottomright, - } - - return annotations diff --git a/bob/pad/face/test/test_databases.py b/bob/pad/face/test/test_databases.py index 0dd94cdc2cca4f5b77c80a44d1d3702430c16c51..66852f13f339ca681e4e7f5e7db6b6a0516f91aa 100644 --- a/bob/pad/face/test/test_databases.py +++ b/bob/pad/face/test/test_databases.py @@ -77,38 +77,6 @@ def test_replaymobile(): % e) -@db_available('msu_mfsd_mod') -def test_msu_mfsd(): - msu_mfsd = bob.bio.base.load_resource( - 'msu-mfsd', - 'database', - preferred_package='bob.pad.face', - package_prefix='bob.pad.') - try: - - assert len(msu_mfsd.objects(groups=['train', 'dev', 'eval'])) == 280 - assert len(msu_mfsd.objects(groups=['train', 'dev'])) == 160 - assert len(msu_mfsd.objects(groups=['train'])) == 80 - assert len( - msu_mfsd.objects( - groups=['train', 'dev', 'eval'], protocol='grandtest')) == 280 - assert len( - msu_mfsd.objects( - groups=['train', 'dev', 'eval'], - protocol='grandtest', - purposes='real')) == 70 - assert len( - msu_mfsd.objects( - groups=['train', 'dev', 'eval'], - protocol='grandtest', - purposes='attack')) == 210 - - except IOError as e: - raise SkipTest( - "The database could not be queried; probably the db.sql3 file is missing. Here is the error: '%s'" - % e) - - # Test the maskattack database @db_available('maskattack') def test_maskattack(): @@ -145,70 +113,6 @@ def test_maskattack(): "The database could not be queried; probably the db.sql3 file is missing. Here is the error: '%s'" % e) -# Test the Aggregated database, which doesn't have a package - -@db_available('replay') -@db_available('replaymobile') -@db_available('msu_mfsd_mod') -@db_available('mobio') -def test_aggregated_db(): - aggregated_db = bob.bio.base.load_resource( - 'aggregated-db', - 'database', - preferred_package='bob.pad.face', - package_prefix='bob.pad.') - try: - - assert len( - aggregated_db.objects(groups=['train', 'dev', 'eval'])) == 2510 - assert len(aggregated_db.objects(groups=['train', 'dev'])) == 1608 - assert len(aggregated_db.objects(groups=['train'])) == 752 - - assert len(aggregated_db.objects(groups='train')) == 752 - assert len(aggregated_db.objects(groups='dev')) == 856 - assert len(aggregated_db.objects(groups='eval')) == 902 - - assert len( - aggregated_db.objects( - groups=['train', 'dev', 'eval'], protocol='grandtest')) == 2510 - assert len( - aggregated_db.objects( - groups=['train', 'dev', 'eval'], - protocol='grandtest', - purposes='real')) == 660 - assert len( - aggregated_db.objects( - groups=['train', 'dev', 'eval'], - protocol='grandtest', - purposes='attack')) == 1850 - - assert len( - aggregated_db.objects( - groups=['train', 'dev', 'eval'], - protocol='photo-photo-video')) == 1664 - assert len( - aggregated_db.objects( - groups=['train', 'dev'], protocol='photo-photo-video')) == 1176 - assert len( - aggregated_db.objects(groups='eval', - protocol='photo-photo-video')) == 488 - - assert len( - aggregated_db.objects( - groups=['train', 'dev', 'eval'], - protocol='video-video-photo')) == 1506 - assert len( - aggregated_db.objects( - groups=['train', 'dev'], protocol='video-video-photo')) == 872 - assert len( - aggregated_db.objects(groups='eval', - protocol='video-video-photo')) == 634 - - except IOError as e: - raise SkipTest( - "The database could not be queried; probably the db.sql3 file is missing. Here is the error: '%s'" - % e) - # Test the casiasurf database @db_available('casiasurf') diff --git a/conda/meta.yaml b/conda/meta.yaml index c1ef93124c441501c20ebb2f9bdf6d60b144ebf8..7e692c2ee6b213e1034685ab9215fd997b61bb40 100644 --- a/conda/meta.yaml +++ b/conda/meta.yaml @@ -66,7 +66,6 @@ test: - gridtk - bob.db.replay - bob.db.replaymobile - - bob.db.msu_mfsd_mod - bob.db.casia_fasd - bob.db.mobio - bob.db.maskattack diff --git a/doc/api.rst b/doc/api.rst index 04e403c56f78a833559fa1b07102fc28f03e0f65..cdd7949294cd90cf8b2b8deb05b2671a1e179473 100644 --- a/doc/api.rst +++ b/doc/api.rst @@ -30,18 +30,6 @@ REPLAY-MOBILE Database .. autoclass:: bob.pad.face.database.replay_mobile.ReplayMobilePadFile .. autoclass:: bob.pad.face.database.replay_mobile.ReplayMobilePadDatabase -MSU MFSD Database -======================== - -.. autoclass:: bob.pad.face.database.msu_mfsd.MsuMfsdPadFile -.. autoclass:: bob.pad.face.database.msu_mfsd.MsuMfsdPadDatabase - -Aggregated Database -======================== - -.. autoclass:: bob.pad.face.database.aggregated_db.AggregatedDbPadFile -.. autoclass:: bob.pad.face.database.aggregated_db.AggregatedDbPadDatabase - MIFS Database ======================== diff --git a/doc/baselines.rst b/doc/baselines.rst index fb08dc5201e358b426a5752066cf1b69891ca79c..bbe86cf5fb1b35ae4a60a76aa1cccf8baca12559 100644 --- a/doc/baselines.rst +++ b/doc/baselines.rst @@ -388,310 +388,6 @@ The ROC curves for the particular experiment can be downloaded from here: ------------ -.. _bob.pad.face.baselines.msu_mfsd: - -Baselines on MSU MFSD database --------------------------------------- - -This section summarizes the results of baseline face PAD experiments on the `MSU MFSD`_ database. -The description of the database-related settings, which are used to run face PAD baselines on the MSU MFSD is given here :ref:`bob.pad.face.resources.databases.msu_mfsd`. To understand the settings in more details you can check the corresponding configuration file : ``bob/pad/face/config/msu_mfsd.py``. - - -LBP features of facial region + SVM classifier -======================================================================== - -Detailed description of this PAD pipe-line is given at :ref:`bob.pad.face.resources.face_pad.lbp_svm_replayattack`. -Note, that the same PAD pipe-line was used to run experiments on the Replay-Attack database. - -To run this baseline on the `MSU MFSD`_ database, using the ``grandtest`` protocol, execute the following: - -.. code-block:: sh - - $ spoof.py msu-mfsd lbp-svm \ - --sub-directory <PATH_TO_STORE_THE_RESULTS> - -.. tip:: - - Similarly to the tip above you can run this baseline in parallel. - -To understand the settings of this baseline PAD experiment you can check the -corresponding configuration file: ``bob/pad/face/config/lbp_svm.py`` - -To evaluate the results computing EER, HTER and plotting ROC you can use the -following command: - -.. code-block:: sh - - bob pad evaluate \ - <PATH_TO_STORE_THE_RESULTS>/grandtest/scores/scores-dev \ - <PATH_TO_STORE_THE_RESULTS>/grandtest/scores/scores-eval \ - --legends "LBP features of facial region + SVM classifier + MSU MFSD database" \ - -e \ - --criterion eer \ - -o <PATH_TO_STORE_THE_RESULTS>/ROC.pdf - -The EER/HTER errors for the `MSU MFSD`_ database are summarized in the Table below: - -+-------------------+----------+----------+ -| Protocol | EER,\% | HTER,\% | -+===================+==========+==========+ -| ``grandtest`` | 27.402 | 21.399 | -+-------------------+----------+----------+ - -The ROC curves for the particular experiment can be downloaded from here: - -:download:`ROC curve <img/ROC_lbp_svm_msu_mfsd.pdf>` - ------------- - - -Image Quality Measures as features of facial region + SVM classifier -======================================================================== - -Detailed description of this PAD pipe-line is given at :ref:`bob.pad.face.resources.face_pad.qm_svm_replayattack`. -Note, that the same PAD pipe-line was used to run experiments on the Replay-Attack database. - -To run this baseline on the `MSU MFSD`_ database, using the ``grandtest`` protocol, execute the following: - -.. code-block:: sh - - $ spoof.py msu-mfsd qm-svm \ - --sub-directory <PATH_TO_STORE_THE_RESULTS> - -.. tip:: - - Similarly to the tip above you can run this baseline in parallel. - -To understand the settings of this baseline PAD experiment you can check the -corresponding configuration file: ``bob/pad/face/config/qm_svm.py`` - -To evaluate the results computing EER, HTER and plotting ROC you can use the -following command: - -.. code-block:: sh - - bob pad evaluate \ - <PATH_TO_STORE_THE_RESULTS>/grandtest/scores/scores-dev \ - <PATH_TO_STORE_THE_RESULTS>/grandtest/scores/scores-eval \ - --legends "IQM features of facial region + SVM classifier + MSU MFSD database" \ - -e \ - --criterion eer \ - -o <PATH_TO_STORE_THE_RESULTS>/ROC.pdf - -The EER/HTER errors for the `MSU MFSD`_ database are summarized in the Table below: - -+-------------------+----------+----------+ -| Protocol | EER,\% | HTER,\% | -+===================+==========+==========+ -| ``grandtest`` | 3.665 | 4.944 | -+-------------------+----------+----------+ - -The ROC curves for the particular experiment can be downloaded from here: - -:download:`ROC curve <img/ROC_iqm_svm_msu_mfsd.pdf>` - ------------- - - -Frame differences based features (motion analysis) + SVM classifier -======================================================================== - -Detailed description of this PAD pipe-line is given at :ref:`bob.pad.face.resources.face_pad.frame_diff_svm_replayattack`. -Note, that the same PAD pipe-line was used to run experiments on the Replay-Attack database. - -To run this baseline on the `MSU MFSD`_ database, using the ``grandtest`` protocol, execute the following: - -.. code-block:: sh - - $ spoof.py msu-mfsd frame-diff-svm \ - --sub-directory <PATH_TO_STORE_THE_RESULTS> - -.. tip:: - - Similarly to the tip above you can run this baseline in parallel. - -To understand the settings of this baseline PAD experiment you can check the -corresponding configuration file: ``bob/pad/face/config/frame_diff_svm.py`` - -To evaluate the results computing EER, HTER and plotting ROC you can use the -following command: - -.. code-block:: sh - - bob pad evaluate \ - <PATH_TO_STORE_THE_RESULTS>/grandtest/scores/scores-dev \ - <PATH_TO_STORE_THE_RESULTS>/grandtest/scores/scores-eval \ - --legends "10 features for each window in Frame Differences + SVM classifier + MSU MFSD database" \ - -e \ - --criterion eer \ - -o <PATH_TO_STORE_THE_RESULTS>/ROC.pdf - -The EER/HTER errors for the `MSU MFSD`_ database are summarized in the Table below: - -+-------------------+----------+----------+ -| Protocol | EER,\% | HTER,\% | -+===================+==========+==========+ -| ``grandtest`` | 25.839 | 17.050 | -+-------------------+----------+----------+ - -The ROC curves for the particular experiment can be downloaded from here: - -:download:`ROC curve <img/ROC_frame_diff_svm_msu_mfsd.pdf>` - ------------- - - -.. _bob.pad.face.baselines.aggregated_db: - -Baselines on Aggregated Database --------------------------------------- - -This section summarizes the results of baseline face PAD experiments on the Aggregated Database. -The description of the database-related settings, which are used to run face PAD baselines on the Aggregated Db is given here :ref:`bob.pad.face.resources.databases.aggregated_db`. To understand the settings in more details you can check the corresponding configuration file : ``bob/pad/face/config/aggregated_db.py``. - ------------- - - -LBP features of facial region + SVM classifier -======================================================================== - -Detailed description of this PAD pipe-line is given at :ref:`bob.pad.face.resources.face_pad.lbp_svm_aggregated_db`. - -To run this baseline on the :ref:`bob.pad.face.resources.databases.aggregated_db` database, using the ``grandtest`` protocol, execute the following: - -.. code-block:: sh - - $ spoof.py aggregated-db lbp-svm-aggregated-db \ - --sub-directory <PATH_TO_STORE_THE_RESULTS> - -.. tip:: - - Similarly to the tip above you can run this baseline in parallel. - -To understand the settings of this baseline PAD experiment you can check the -corresponding configuration file: ``bob/pad/face/config/lbp_svm_aggregated_db.py`` - -To evaluate the results computing EER, HTER and plotting ROC you can use the -following command: - -.. code-block:: sh - - bob pad evaluate \ - <PATH_TO_STORE_THE_RESULTS>/grandtest/scores/scores-dev \ - <PATH_TO_STORE_THE_RESULTS>/grandtest/scores/scores-eval \ - --legends "LBP features of facial region + SVM classifier + Aggregated database" \ - -e \ - --criterion eer \ - -o <PATH_TO_STORE_THE_RESULTS>/ROC.pdf - -The EER/HTER errors for the :ref:`bob.pad.face.resources.databases.aggregated_db` database are summarized in the Table below: - -+-------------------+----------+----------+ -| Protocol | EER,\% | HTER,\% | -+===================+==========+==========+ -| ``grandtest`` | 17.490 | 19.705 | -+-------------------+----------+----------+ - -The ROC curves for the particular experiment can be downloaded from here: - -:download:`ROC curve <img/ROC_lbp_svm_aggregated_db.pdf>` - ------------- - - -Image Quality Measures as features of facial region + SVM classifier -======================================================================== - -Detailed description of this PAD pipe-line is given at :ref:`bob.pad.face.resources.face_pad.qm_svm_aggregated_db`. - -To run this baseline on the :ref:`bob.pad.face.resources.databases.aggregated_db` database, using the ``grandtest`` protocol, execute the following: - -.. code-block:: sh - - $ spoof.py aggregated-db qm-svm-aggregated-db \ - --sub-directory <PATH_TO_STORE_THE_RESULTS> - -.. tip:: - - Similarly to the tip above you can run this baseline in parallel. - -To understand the settings of this baseline PAD experiment you can check the -corresponding configuration file: ``bob/pad/face/config/qm_svm_aggregated_db.py`` - -To evaluate the results computing EER, HTER and plotting ROC you can use the -following command: - -.. code-block:: sh - - bob pad evaluate \ - <PATH_TO_STORE_THE_RESULTS>/grandtest/scores/scores-dev \ - <PATH_TO_STORE_THE_RESULTS>/grandtest/scores/scores-eval \ - --legends "IQM features of facial region + SVM classifier + Aggregated database" \ - -e \ - --criterion eer \ - -o <PATH_TO_STORE_THE_RESULTS>/ROC.pdf - -The EER/HTER errors for the :ref:`bob.pad.face.resources.databases.aggregated_db` database are summarized in the Table below: - -+-------------------+----------+----------+ -| Protocol | EER,\% | HTER,\% | -+===================+==========+==========+ -| ``grandtest`` | 12.710 | 15.253 | -+-------------------+----------+----------+ - -The ROC curves for the particular experiment can be downloaded from here: - -:download:`ROC curve <img/ROC_qm_svm_aggregated_db.pdf>` - ------------- - - -Frame differences based features (motion analysis) + SVM classifier -======================================================================== - -Detailed description of this PAD pipe-line is given at :ref:`bob.pad.face.resources.face_pad.frame_diff_svm_aggregated_db`. - -To run this baseline on the :ref:`bob.pad.face.resources.databases.aggregated_db` database, using the ``grandtest`` protocol, execute the following: - -.. code-block:: sh - - $ spoof.py aggregated-db frame-diff-svm-aggregated-db \ - --sub-directory <PATH_TO_STORE_THE_RESULTS> - -.. tip:: - - Similarly to the tip above you can run this baseline in parallel. - -To understand the settings of this baseline PAD experiment you can check the -corresponding configuration file: ``bob/pad/face/config/frame_diff_svm_aggregated_db.py`` - -To evaluate the results computing EER, HTER and plotting ROC you can use the -following command: - -.. code-block:: sh - - bob pad evaluate \ - <PATH_TO_STORE_THE_RESULTS>/grandtest/scores/scores-dev \ - <PATH_TO_STORE_THE_RESULTS>/grandtest/scores/scores-eval \ - --legends "10 features for each window in Frame Differences + SVM classifier + Aggregated Db" \ - -e \ - --criterion eer \ - -o <PATH_TO_STORE_THE_RESULTS>/ROC.pdf - -The EER/HTER errors for the :ref:`bob.pad.face.resources.databases.aggregated_db` database are summarized in the Table below: - -+-------------------+----------+----------+ -| Protocol | EER,\% | HTER,\% | -+===================+==========+==========+ -| ``grandtest`` | 35.219 | 43.029 | -+-------------------+----------+----------+ - -The ROC curves for the particular experiment can be downloaded from here: - -:download:`ROC curve <img/ROC_frame_diff_svm_aggregated_db.pdf>` - ------------- - .. _bob.pad.face.baselines.other_db: diff --git a/doc/installation.rst b/doc/installation.rst index 19849aa9263e622d0e0afca1757c57f360f6843e..d1a91ddfa8922cfb275f6e7db2949fcb0a7cb121 100644 --- a/doc/installation.rst +++ b/doc/installation.rst @@ -25,8 +25,6 @@ The current system readily supports the following freely available datasets: * `REPLAYATTACK`_ * `REPLAY-MOBILE`_ -* `MSU MFSD`_ -* ``Aggregated DB`` After downloading the databases, annotate the base directories in which they are installed. Then, follow the instructions in diff --git a/doc/links.rst b/doc/links.rst index edcab972d9aac9b197a193ae8a48b72009d601c0..cd652a07f1baf7c55dcfffae9ba14ee847d2c817 100644 --- a/doc/links.rst +++ b/doc/links.rst @@ -12,6 +12,5 @@ .. _replayattack: https://www.idiap.ch/dataset/replayattack .. _replay-mobile: https://www.idiap.ch/dataset/replay-mobile .. _dependencies: https://gitlab.idiap.ch/bob/bob/wikis/Dependencies -.. _MSU MFSD: http://biometrics.cse.msu.edu/Publications/Databases/MSUMobileFaceSpoofing/index.htm .. _MIFS: http://www.antitza.com/makeup-datasets.html .. _CELEBA: http://mmlab.ie.cuhk.edu.hk/projects/CelebA.html diff --git a/doc/other_pad_algorithms.rst b/doc/other_pad_algorithms.rst index 9a515284eaec53d497460430ee7f06cf39f001cd..39e6b918854a2dde993d878a7dbd564fffe797d6 100644 --- a/doc/other_pad_algorithms.rst +++ b/doc/other_pad_algorithms.rst @@ -84,256 +84,6 @@ is available on the section :ref:`bob.pad.face.resources`. Once this step is done, you can proceed with the instructions below. ------------- - - -.. _bob.pad.face.other_pad_algorithms.aggregated_db: - -Anomaly detection based PAD on Aggregated Database --------------------------------------------------------- - -This section summarizes the results of *anomaly detection* based face PAD experiments on the Aggregated Database. -The description of the database-related settings, which are used to run face PAD algorithms on the Aggregated Db is given here :ref:`bob.pad.face.resources.databases.aggregated_db`. To understand the settings in more details you can check the corresponding configuration file : ``bob/pad/face/config/aggregated_db.py``. - ------------- - - -Results for *grandtest* protocol -======================================================================== - -This section summarizes the evaluation results on the **grandtest** protocol of the Aggregated database for the following face PAD algorithms (for more details click on the corresponding algorithm): - -- :ref:`bob.pad.face.resources.face_pad.qm_one_class_gmm`, -- :ref:`bob.pad.face.resources.face_pad.qm_one_class_svm_aggregated_db`, -- :ref:`bob.pad.face.resources.face_pad.qm_lr`, -- :ref:`bob.pad.face.resources.face_pad.qm_svm_aggregated_db`. - -For a more detailed understanding of above pipe-lines you can also check corresponding configuration files: - -- ``bob/pad/face/config/qm_one_class_gmm.py``, -- ``bob/pad/face/config/qm_one_class_svm_aggregated_db.py``, -- ``bob/pad/face/config/qm_lr.py``, -- ``bob/pad/face/config/qm_svm_aggregated_db.py``. - -To run above algorithms on the :ref:`bob.pad.face.resources.databases.aggregated_db` database, using the ``grandtest`` protocol, execute the following: - -.. code-block:: sh - - $ spoof.py aggregated-db qm-one-class-gmm \ - --sub-directory <PATH_TO_STORE_THE_RESULTS_1> - - $ spoof.py aggregated-db qm-one-class-svm-aggregated-db \ - --sub-directory <PATH_TO_STORE_THE_RESULTS_2> - - $ spoof.py aggregated-db qm-lr \ - --sub-directory <PATH_TO_STORE_THE_RESULTS_3> - - $ spoof.py aggregated-db qm-svm-aggregated-db \ - --sub-directory <PATH_TO_STORE_THE_RESULTS_4> - -.. tip:: - - If you are in `idiap`_ you can use SGE grid to speed-up the calculations. - Simply add ``--grid idiap`` argument to the above command. For example: - - -To evaluate the results computing EER, HTER and plotting ROC you can use the -following command: - -.. code-block:: sh - - bob pad evaluate \ - <PATH_TO_STORE_THE_RESULTS>_{1,2,3,4}/grandtest/scores/scores-{dev,eval} \ - --legends \ - "IQM + one-class GMM + Aggregated Db" \ - "IQM + one-class SVM + Aggregated Db" \ - "IQM + two-class LR + Aggregated Db" \ - "IQM + two-class SVM + Aggregated Db" \ - -e \ - --c eer \ - -o <PATH_TO_STORE_THE_RESULTS>/ROC.pdf - -The EER/HTER errors for the :ref:`bob.pad.face.resources.databases.aggregated_db` database are summarized in the Table below: - -+------------------------+----------+----------+ -| Algorithm | EER,\% | HTER,\% | -+========================+==========+==========+ -| IQM + one-class GMM | 19.336 | 20.769 | -+------------------------+----------+----------+ -| IQM + one-class SVM | 28.137 | 34.776 | -+------------------------+----------+----------+ -| IQM + two-class LR | 10.354 | 11.856 | -+------------------------+----------+----------+ -| IQM + two-class SVM | 12.710 | 15.253 | -+------------------------+----------+----------+ - -The ROC curves for the particular experiment can be downloaded from here: - -:download:`ROC curve <img/ROC_iqm_anomaly_detection_aggr_db_grandtest.pdf>` - ------------- - - -Results for *photo-photo-video* protocol -======================================================================== - -This section summarizes the evaluation results on the **photo-photo-video** protocol of the Aggregated database for the following face PAD algorithms (for more details click on the corresponding algorithm): - -- :ref:`bob.pad.face.resources.face_pad.qm_one_class_gmm`, -- :ref:`bob.pad.face.resources.face_pad.qm_one_class_svm_aggregated_db`, -- :ref:`bob.pad.face.resources.face_pad.qm_lr`, -- :ref:`bob.pad.face.resources.face_pad.qm_svm_aggregated_db`. - -For a more detailed understanding of above pipe-lines you can also check corresponding configuration files: - -- ``bob/pad/face/config/qm_one_class_gmm.py``, -- ``bob/pad/face/config/qm_one_class_svm_aggregated_db.py``, -- ``bob/pad/face/config/qm_lr.py``, -- ``bob/pad/face/config/qm_svm_aggregated_db.py``. - -To run above algorithms on the :ref:`bob.pad.face.resources.databases.aggregated_db` database, using the ``photo-photo-video`` protocol, execute the following: - -.. code-block:: sh - - $ spoof.py aggregated-db qm-one-class-gmm \ - --protocol photo-photo-video \ - --sub-directory <PATH_TO_STORE_THE_RESULTS_1> - - $ spoof.py aggregated-db qm-one-class-svm-aggregated-db \ - --protocol photo-photo-video \ - --sub-directory <PATH_TO_STORE_THE_RESULTS_2> - - $ spoof.py aggregated-db qm-lr \ - --protocol photo-photo-video \ - --sub-directory <PATH_TO_STORE_THE_RESULTS_3> - - $ spoof.py aggregated-db qm-svm-aggregated-db \ - --protocol photo-photo-video \ - --sub-directory <PATH_TO_STORE_THE_RESULTS_4> - -.. tip:: - - If you are in `idiap`_ you can use SGE grid to speed-up the calculations. - Simply add ``--grid idiap`` argument to the above command. For example: - - -To evaluate the results computing EER, HTER and plotting ROC you can use the -following command: - -.. code-block:: sh - - bob pad evaluate \ - <PATH_TO_STORE_THE_RESULTS>_{1,2,3,4}/photo-photo-video/scores/scores-{dev,eval} \ - --legends \ - "IQM + one-class GMM + Aggregated Db" \ - "IQM + one-class SVM + Aggregated Db" \ - "IQM + two-class LR + Aggregated Db" \ - "IQM + two-class SVM + Aggregated Db" \ - -e \ - --criterion eer \ - -o <PATH_TO_STORE_THE_RESULTS>/ROC.pdf - -The EER/HTER errors for the :ref:`bob.pad.face.resources.databases.aggregated_db` database are summarized in the Table below: - -+------------------------+----------+----------+ -| Algorithm | EER,\% | HTER,\% | -+========================+==========+==========+ -| IQM + one-class GMM | 22.075 | 14.470 | -+------------------------+----------+----------+ -| IQM + one-class SVM | 35.537 | 24.317 | -+------------------------+----------+----------+ -| IQM + two-class LR | 10.184 | 30.132 | -+------------------------+----------+----------+ -| IQM + two-class SVM | 10.527 | 21.926 | -+------------------------+----------+----------+ - -The ROC curves for the particular experiment can be downloaded from here: - -:download:`ROC curve <img/ROC_iqm_anomaly_detection_aggr_db_ph_ph_vid.pdf>` - ------------- - - -Results for *video-video-photo* protocol -======================================================================== - -This section summarizes the evaluation results on the **video-video-photo** protocol of the Aggregated database for the following face PAD algorithms (for more details click on the corresponding algorithm): - -- :ref:`bob.pad.face.resources.face_pad.qm_one_class_gmm`, -- :ref:`bob.pad.face.resources.face_pad.qm_one_class_svm_aggregated_db`, -- :ref:`bob.pad.face.resources.face_pad.qm_lr`, -- :ref:`bob.pad.face.resources.face_pad.qm_svm_aggregated_db`. - -For a more detailed understanding of above pipe-lines you can also check corresponding configuration files: - -- ``bob/pad/face/config/qm_one_class_gmm.py``, -- ``bob/pad/face/config/qm_one_class_svm_aggregated_db.py``, -- ``bob/pad/face/config/qm_lr.py``, -- ``bob/pad/face/config/qm_svm_aggregated_db.py``. - -To run above algorithms on the :ref:`bob.pad.face.resources.databases.aggregated_db` database, using the ``video-video-photo`` protocol, execute the following: - -.. code-block:: sh - - $ spoof.py aggregated-db qm-one-class-gmm \ - --protocol video-video-photo \ - --sub-directory <PATH_TO_STORE_THE_RESULTS_1> - - $ spoof.py aggregated-db qm-one-class-svm-aggregated-db \ - --protocol video-video-photo \ - --sub-directory <PATH_TO_STORE_THE_RESULTS_2> - - $ spoof.py aggregated-db qm-lr \ - --protocol video-video-photo \ - --sub-directory <PATH_TO_STORE_THE_RESULTS_3> - - $ spoof.py aggregated-db qm-svm-aggregated-db \ - --protocol video-video-photo \ - --sub-directory <PATH_TO_STORE_THE_RESULTS_4> - -.. tip:: - - If you are in `idiap`_ you can use SGE grid to speed-up the calculations. - Simply add ``--grid idiap`` argument to the above command. For example: - - -To evaluate the results computing EER, HTER and plotting ROC you can use the -following command: - -.. code-block:: sh - - bob pad evaluate \ - <PATH_TO_STORE_THE_RESULTS>_{1,2,3,4}/video-video-photo/scores/scores-{dev,eval} \ - --legends \ - "IQM + one-class GMM + Aggregated Db" \ - "IQM + one-class SVM + Aggregated Db" \ - "IQM + two-class LR + Aggregated Db" \ - "IQM + two-class SVM + Aggregated Db" \ - -e \ - --criterion eer \ - -o <PATH_TO_STORE_THE_RESULTS>/ROC.pdf - -The EER/HTER errors for the :ref:`bob.pad.face.resources.databases.aggregated_db` database are summarized in the Table below: - -+------------------------+----------+----------+ -| Algorithm | EER,\% | HTER,\% | -+========================+==========+==========+ -| IQM + one-class GMM | 13.503 | 29.794 | -+------------------------+----------+----------+ -| IQM + one-class SVM | 18.234 | 39.502 | -+------------------------+----------+----------+ -| IQM + two-class LR | 1.499 | 30.268 | -+------------------------+----------+----------+ -| IQM + two-class SVM | 1.422 | 24.901 | -+------------------------+----------+----------+ - -The ROC curves for the particular experiment can be downloaded from here: - -:download:`ROC curve <img/ROC_iqm_anomaly_detection_aggr_db_vid_vid_ph.pdf>` - ------------- - - .. include:: links.rst diff --git a/doc/resources.rst b/doc/resources.rst index 971e96dea904df398e70508f8866ada22efe82b0..581e8cb5da61a947f96d5e5aa2a33812f5e26c04 100644 --- a/doc/resources.rst +++ b/doc/resources.rst @@ -43,23 +43,6 @@ Replay-Mobile Database :members: -.. _bob.pad.face.resources.databases.msu_mfsd: - -MSU MFSD Database -================================================================================ - -.. automodule:: bob.pad.face.config.msu_mfsd - :members: - - -.. _bob.pad.face.resources.databases.aggregated_db: - -Aggregated Database -================================================================================ - -.. automodule:: bob.pad.face.config.aggregated_db - :members: - MIFS Database ================================================================================ @@ -110,33 +93,6 @@ Frame differences based features (motion analysis) + SVM for REPLAY-ATTACK :members: -.. _bob.pad.face.resources.face_pad.lbp_svm_aggregated_db: - -LBP features of facial region + SVM for Aggregated Database -=================================================================================== - -.. automodule:: bob.pad.face.config.lbp_svm_aggregated_db - :members: - - -.. _bob.pad.face.resources.face_pad.qm_svm_aggregated_db: - -Image Quality Measures as features of facial region + SVM for Aggregated Database -=================================================================================== - -.. automodule:: bob.pad.face.config.qm_svm_aggregated_db - :members: - - -.. _bob.pad.face.resources.face_pad.frame_diff_svm_aggregated_db: - -Frame differences based features (motion analysis) + SVM for Aggregated Database -=================================================================================== - -.. automodule:: bob.pad.face.config.frame_diff_svm_aggregated_db - :members: - - .. _bob.pad.face.resources.face_pad.qm_lr: Image Quality Measures as features of facial region + Logistic Regression @@ -154,13 +110,3 @@ Image Quality Measures as features of facial region + GMM-based one-class classi .. automodule:: bob.pad.face.config.qm_one_class_gmm :members: - -.. _bob.pad.face.resources.face_pad.qm_one_class_svm_aggregated_db: - -Image Quality Measures as features of facial region + one-class SVM classifier (anomaly detector) for Aggregated Database -============================================================================================================================ - -.. automodule:: bob.pad.face.config.qm_one_class_svm_aggregated_db - :members: - - diff --git a/setup.py b/setup.py index 35e05f389bc56d1e2a9fdf0ccf3bc9e3a5e89605..a3a8e5e729f0f75f381d7e63963e47329496b83b 100644 --- a/setup.py +++ b/setup.py @@ -65,9 +65,7 @@ setup( 'bob.pad.database': [ 'replay-attack = bob.pad.face.config.replay_attack:database', 'replay-mobile = bob.pad.face.config.replay_mobile:database', - 'msu-mfsd = bob.pad.face.config.msu_mfsd:database', 'casiafasd = bob.pad.face.config.casiafasd:database', - 'aggregated-db = bob.pad.face.config.aggregated_db:database', 'mifs = bob.pad.face.config.mifs:database', 'batl-db = bob.pad.face.config.database.batl.batl_db:database', 'batl-db-infrared = bob.pad.face.config.database.batl.batl_db_infrared:database', @@ -86,9 +84,7 @@ setup( # databases 'replay-attack = bob.pad.face.config.replay_attack', 'replay-mobile = bob.pad.face.config.replay_mobile', - 'msu-mfsd = bob.pad.face.config.msu_mfsd', 'casiafasd = bob.pad.face.config.casiafasd', - 'aggregated-db = bob.pad.face.config.aggregated_db', 'mifs = bob.pad.face.config.mifs', 'batl-db = bob.pad.face.config.database.batl.batl_db', 'batl-db-infrared = bob.pad.face.config.database.batl.batl_db_infrared', @@ -100,22 +96,15 @@ setup( # baselines using SVM: 'lbp-svm = bob.pad.face.config.lbp_svm', - 'lbp-svm-aggregated-db = bob.pad.face.config.lbp_svm_aggregated_db', 'qm-svm = bob.pad.face.config.qm_svm', - 'qm-svm-aggregated-db = bob.pad.face.config.qm_svm_aggregated_db', 'frame-diff-svm = bob.pad.face.config.frame_diff_svm', - 'frame-diff-svm-aggregated-db = bob.pad.face.config.frame_diff_svm_aggregated_db', - - # baselines using one-class SVM - 'qm-one-class-svm-aggregated-db = bob.pad.face.config.qm_one_class_svm_aggregated_db', - 'qm-one-class-svm-cascade-aggregated-db = bob.pad.face.config.qm_one_class_svm_cascade_aggregated_db', # baselines using LR: - 'qm-lr = bob.pad.face.config.qm_lr', # this pipe-line can be used both for individual and Aggregated databases. + 'qm-lr = bob.pad.face.config.qm_lr', 'lbp-lr-batl-D-T-IR = bob.pad.face.config.lbp_lr_batl_D_T_IR', # this pipe-line can be used both for BATL databases, Depth, Thermal and Infrared channels. # baselines using GMM: - 'qm-one-class-gmm = bob.pad.face.config.qm_one_class_gmm', # this pipe-line can be used both for individual and Aggregated databases. + 'qm-one-class-gmm = bob.pad.face.config.qm_one_class_gmm', ], # registered preprocessors: diff --git a/test-requirements.txt b/test-requirements.txt index fae37ea3fb6ed9f6464be836218e5eb9547cc4d6..aa9448073ae335e55e6249104f3bec8128f27fcf 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -1,7 +1,6 @@ nose bob.db.replay bob.db.replaymobile -bob.db.msu_mfsd_mod bob.db.casia_fasd bob.db.mobio bob.db.maskattack