lbp_64.py 1.25 KB
Newer Older
Amir MOHAMMADI's avatar
Amir MOHAMMADI committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
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.pad.face.extractor import LBPHistogram

database = globals().get("database")
if database is not None:
    annotation_type = database.annotation_type
    fixed_positions = database.fixed_positions
else:
    annotation_type = None
    fixed_positions = None

# Preprocessor #
cropper = face_crop_solver(
    cropped_image_size=64, cropped_positions=annotation_type, color_channel="gray"
)
preprocessor = TransformerWrapper(cropper)
preprocessor = mario.wrap(
    ["sample", "checkpoint"],
    preprocessor,
    transform_extra_arguments=(("annotations", "annotations"),),
    features_dir="temp/faces-64",
    save_func=VideoLikeContainer.save,
    load_func=VideoLikeContainer.load,
)

# Extractor #
extractor = TransformerWrapper(
    LBPHistogram(
        lbptype="uniform",
        elbptype="regular",
        rad=1,
        neighbors=8,
        circ=False,
        dtype=None,
    )
)
extractor = mario.wrap(
    ["sample", "checkpoint"],
    extractor,
    features_dir="temp/iqm-features",
    save_func=VideoLikeContainer.save,
    load_func=VideoLikeContainer.load,
)