From 11d0d66656406bc330da9a58f61bf440add8cd3a Mon Sep 17 00:00:00 2001 From: Amir MOHAMMADI <amir.mohammadi@idiap.ch> Date: Thu, 12 Nov 2020 17:25:03 +0100 Subject: [PATCH] update config files --- bob/pad/face/config/brsu.py | 8 +------- bob/pad/face/config/casiasurf.py | 11 ++-------- bob/pad/face/config/casiasurf_color.py | 9 +-------- bob/pad/face/config/celeb_a.py | 10 +-------- bob/pad/face/config/lbp_64.py | 28 +++++++++----------------- bob/pad/face/config/maskattack.py | 9 +-------- bob/pad/face/config/mifs.py | 9 +-------- bob/pad/face/config/qm_64.py | 20 +++++------------- bob/pad/face/config/replay_attack.py | 9 +-------- bob/pad/face/config/replay_mobile.py | 9 +-------- bob/pad/face/config/svm_frames.py | 13 +++++++----- 11 files changed, 31 insertions(+), 104 deletions(-) diff --git a/bob/pad/face/config/brsu.py b/bob/pad/face/config/brsu.py index 29ec93b1..b49a7ea9 100644 --- a/bob/pad/face/config/brsu.py +++ b/bob/pad/face/config/brsu.py @@ -1,10 +1,4 @@ from bob.pad.face.database import BRSUPadDatabase from bob.pad.base.pipelines.vanilla_pad import DatabaseConnector -from bob.extension import rc -database = DatabaseConnector( - BRSUPadDatabase( - protocol="test", - original_directory=rc["bob.db.brsu.directory"], - ) -) +database = DatabaseConnector(BRSUPadDatabase()) diff --git a/bob/pad/face/config/casiasurf.py b/bob/pad/face/config/casiasurf.py index 6a848940..1e0d9be6 100644 --- a/bob/pad/face/config/casiasurf.py +++ b/bob/pad/face/config/casiasurf.py @@ -1,11 +1,4 @@ -#!/usr/bin/env python -# encoding: utf-8 - from bob.pad.face.database import CasiaSurfPadDatabase -from bob.extension import rc +from bob.pad.base.pipelines.vanilla_pad import DatabaseConnector -database = CasiaSurfPadDatabase( - protocol='all', - original_directory=rc['bob.db.casiasurf.directory'], - original_extension=".jpg", -) +database = DatabaseConnector(CasiaSurfPadDatabase()) diff --git a/bob/pad/face/config/casiasurf_color.py b/bob/pad/face/config/casiasurf_color.py index d4495930..1e0d9be6 100644 --- a/bob/pad/face/config/casiasurf_color.py +++ b/bob/pad/face/config/casiasurf_color.py @@ -1,11 +1,4 @@ from bob.pad.face.database import CasiaSurfPadDatabase from bob.pad.base.pipelines.vanilla_pad import DatabaseConnector -from bob.extension import rc -database = DatabaseConnector( - CasiaSurfPadDatabase( - protocol="color", - original_directory=rc.get("bob.db.casiasurf.directory"), - original_extension=".jpg", - ) -) +database = DatabaseConnector(CasiaSurfPadDatabase()) diff --git a/bob/pad/face/config/celeb_a.py b/bob/pad/face/config/celeb_a.py index dd104bb0..0b9e42c3 100644 --- a/bob/pad/face/config/celeb_a.py +++ b/bob/pad/face/config/celeb_a.py @@ -8,15 +8,7 @@ the link. """ -from bob.extension import rc from bob.pad.base.pipelines.vanilla_pad import DatabaseConnector from bob.pad.face.database.celeb_a import CELEBAPadDatabase -database = DatabaseConnector( - CELEBAPadDatabase( - protocol="grandtest", - original_directory=rc.get("bob.db.celeba.directory"), - original_extension="", - training_depends_on_protocol=True, - ) -) +database = DatabaseConnector(CELEBAPadDatabase()) diff --git a/bob/pad/face/config/lbp_64.py b/bob/pad/face/config/lbp_64.py index a8e60ab3..38a8649b 100644 --- a/bob/pad/face/config/lbp_64.py +++ b/bob/pad/face/config/lbp_64.py @@ -1,7 +1,6 @@ import bob.pipelines as mario from bob.bio.face.helpers import face_crop_solver -from bob.bio.video import VideoLikeContainer -from bob.bio.video.transformer import Wrapper as TransformerWrapper +from bob.bio.video.transformer import VideoWrapper from bob.pad.face.extractor import LBPHistogram database = globals().get("database") @@ -16,31 +15,22 @@ else: cropper = face_crop_solver( cropped_image_size=64, cropped_positions=annotation_type, color_channel="gray" ) -preprocessor = TransformerWrapper(cropper) +preprocessor = VideoWrapper(cropper) preprocessor = mario.wrap( - ["sample", "checkpoint"], + ["sample"], preprocessor, transform_extra_arguments=(("annotations", "annotations"),), - features_dir="temp/faces-64", - save_func=VideoLikeContainer.save, - load_func=VideoLikeContainer.load, ) # Extractor # -extractor = TransformerWrapper( +extractor = VideoWrapper( LBPHistogram( - lbptype="uniform", - elbptype="regular", - rad=1, + lbp_type="uniform", + elbp_type="regular", + radius=1, neighbors=8, - circ=False, + circular=False, dtype=None, ) ) -extractor = mario.wrap( - ["sample", "checkpoint"], - extractor, - features_dir="temp/iqm-features", - save_func=VideoLikeContainer.save, - load_func=VideoLikeContainer.load, -) +extractor = mario.wrap(["sample"], extractor) diff --git a/bob/pad/face/config/maskattack.py b/bob/pad/face/config/maskattack.py index 9f7cfa02..2d05fa79 100644 --- a/bob/pad/face/config/maskattack.py +++ b/bob/pad/face/config/maskattack.py @@ -1,11 +1,4 @@ from bob.pad.face.database import MaskAttackPadDatabase from bob.pad.base.pipelines.vanilla_pad import DatabaseConnector -from bob.extension import rc -database = DatabaseConnector( - MaskAttackPadDatabase( - protocol="classification", - original_directory=rc.get("bob.db.maskattack.directory"), - original_extension=".avi", - ) -) +database = DatabaseConnector(MaskAttackPadDatabase()) diff --git a/bob/pad/face/config/mifs.py b/bob/pad/face/config/mifs.py index b1a8572d..d6ab6e96 100644 --- a/bob/pad/face/config/mifs.py +++ b/bob/pad/face/config/mifs.py @@ -17,12 +17,5 @@ the link. """ from bob.pad.face.database import MIFSPadDatabase from bob.pad.base.pipelines.vanilla_pad import DatabaseConnector -from bob.extension import rc -database = DatabaseConnector( - MIFSPadDatabase( - protocol="grandtest", - original_directory=rc.get("bob.db.mifs.directory"), - original_extension="", - ) -) +database = DatabaseConnector(MIFSPadDatabase()) diff --git a/bob/pad/face/config/qm_64.py b/bob/pad/face/config/qm_64.py index cc4326ea..a3d31173 100644 --- a/bob/pad/face/config/qm_64.py +++ b/bob/pad/face/config/qm_64.py @@ -1,7 +1,6 @@ import bob.pipelines as mario from bob.bio.face.helpers import face_crop_solver -from bob.bio.video import VideoLikeContainer -from bob.bio.video.transformer import Wrapper as TransformerWrapper +from bob.bio.video.transformer import VideoWrapper from bob.pad.face.extractor import ImageQualityMeasure database = globals().get("database") @@ -14,22 +13,13 @@ else: # Preprocessor # cropper = face_crop_solver(cropped_image_size=64, cropped_positions=annotation_type) -preprocessor = TransformerWrapper(cropper) +preprocessor = VideoWrapper(cropper) preprocessor = mario.wrap( - ["sample", "checkpoint"], + ["sample"], preprocessor, transform_extra_arguments=(("annotations", "annotations"),), - features_dir="temp/faces-64", - save_func=VideoLikeContainer.save, - load_func=VideoLikeContainer.load, ) # Extractor # -extractor = TransformerWrapper(ImageQualityMeasure(galbally=True, msu=True, dtype=None)) -extractor = mario.wrap( - ["sample", "checkpoint"], - extractor, - features_dir="temp/iqm-features", - save_func=VideoLikeContainer.save, - load_func=VideoLikeContainer.load, -) +extractor = VideoWrapper(ImageQualityMeasure(galbally=True, msu=True, dtype=None)) +extractor = mario.wrap(["sample"], extractor) diff --git a/bob/pad/face/config/replay_attack.py b/bob/pad/face/config/replay_attack.py index 9ced9d6d..737a4b9b 100644 --- a/bob/pad/face/config/replay_attack.py +++ b/bob/pad/face/config/replay_attack.py @@ -11,12 +11,5 @@ the link. """ from bob.pad.face.database import ReplayPadDatabase from bob.pad.base.pipelines.vanilla_pad import DatabaseConnector -from bob.extension import rc -database = DatabaseConnector( - ReplayPadDatabase( - protocol="grandtest", - original_directory=rc.get("bob.db.replay.directory"), - original_extension=".mov", - ) -) +database = DatabaseConnector(ReplayPadDatabase()) diff --git a/bob/pad/face/config/replay_mobile.py b/bob/pad/face/config/replay_mobile.py index 3c9942f8..14408e89 100644 --- a/bob/pad/face/config/replay_mobile.py +++ b/bob/pad/face/config/replay_mobile.py @@ -14,12 +14,5 @@ the link. """ from bob.pad.face.database import ReplayMobilePadDatabase from bob.pad.base.pipelines.vanilla_pad import DatabaseConnector -from bob.extension import rc -database = DatabaseConnector( - ReplayMobilePadDatabase( - protocol="grandtest", - original_directory=rc.get("bob.db.replaymobile.directory"), - original_extension=".mov", - ) -) +database = DatabaseConnector(ReplayMobilePadDatabase()) diff --git a/bob/pad/face/config/svm_frames.py b/bob/pad/face/config/svm_frames.py index 32a95d43..52d0caac 100644 --- a/bob/pad/face/config/svm_frames.py +++ b/bob/pad/face/config/svm_frames.py @@ -1,7 +1,7 @@ import bob.pipelines as mario from bob.pad.face.transformer import VideoToFrames from sklearn.model_selection import GridSearchCV -from sklearn.pipeline import make_pipeline +from sklearn.pipeline import Pipeline from sklearn.svm import SVC preprocessor = globals().get("preprocessor") @@ -20,13 +20,16 @@ param_grid = [ classifier = GridSearchCV(SVC(), param_grid=param_grid, cv=3) classifier = mario.wrap( - ["sample", "checkpoint"], + ["sample"], classifier, fit_extra_arguments=[("y", "is_bonafide")], - model_path="temp/svm.pkl", ) # Pipeline # -frames_classifier = make_pipeline(frame_cont_to_array, classifier) -pipeline = make_pipeline(preprocessor, extractor, frames_classifier) +frames_classifier = Pipeline([("frame_cont_to_array", frame_cont_to_array), ("classifier", classifier)]) +pipeline = Pipeline([ + ("preprocessor", preprocessor), + ("extractor", extractor), + ("svm", frames_classifier), +]) -- GitLab