Coverage for src/bob/pad/face/config/deep_pix_bis.py: 92%
24 statements
« prev ^ index » next coverage.py v7.6.0, created at 2024-07-13 01:19 +0200
« prev ^ index » next coverage.py v7.6.0, created at 2024-07-13 01:19 +0200
1""" Deep Pixel-wise Binary Supervision for Face PAD
3This baseline includes the models to replicate the experimental results published in the following publication::
5 @INPROCEEDINGS{GeorgeICB2019,
6 author = {Anjith George, Sebastien Marcel},
7 title = {Deep Pixel-wise Binary Supervision for Face Presentation Attack Detection},
8 year = {2019},
9 booktitle = {ICB 2019},
10 }
12"""
14from sklearn.pipeline import Pipeline
16import bob.pipelines
18from bob.bio.face.preprocessor import FaceCrop
19from bob.bio.face.utils import get_default_cropped_positions
20from bob.bio.video.transformer import VideoWrapper
21from bob.pad.face.deep_pix_bis import DeepPixBisClassifier
22from bob.pad.face.transformer import VideoToFrames
24database = globals().get("database")
25annotation_type, fixed_positions = None, None
26if database is not None:
27 annotation_type = database.annotation_type
28 fixed_positions = database.fixed_positions
30if annotation_type is None:
31 annotation_type = "eyes-center"
32 fixed_positions = None
35# Preprocessor #
36cropped_image_size = (224, 224)
37cropped_positions = get_default_cropped_positions(
38 "pad", cropped_image_size, annotation_type
39)
40cropper = FaceCrop(
41 cropped_image_size=cropped_image_size,
42 cropped_positions=cropped_positions,
43 color_channel="rgb",
44 fixed_positions=fixed_positions,
45 dtype="uint8",
46 annotator="mtcnn",
47)
49preprocessor = VideoWrapper(cropper)
50preprocessor = bob.pipelines.wrap(
51 ["sample"],
52 preprocessor,
53 transform_extra_arguments=(("annotations", "annotations"),),
54)
56# Classifier #
57classifier = DeepPixBisClassifier(model_file="oulu-npu-p1")
58classifier = bob.pipelines.wrap(["sample"], classifier)
59# change the decision_function
60decision_function = "predict_proba"
63pipeline = Pipeline(
64 [
65 ("preprocessor", preprocessor),
66 ("video_to_frames", VideoToFrames()),
67 ("classifier", classifier),
68 ]
69)