Coverage for src/bob/pad/face/database/swan.py: 100%
19 statements
« prev ^ index » next coverage.py v7.3.2, created at 2023-12-06 23:20 +0100
« prev ^ index » next coverage.py v7.3.2, created at 2023-12-06 23:20 +0100
1import logging
3from clapper.rc import UserDefaults
5from bob.bio.base.database.utils import download_file
6from bob.pad.base.database import FileListPadDatabase
7from bob.pad.face.database import VideoPadSample
9logger = logging.getLogger(__name__)
10rc = UserDefaults("bobrc.toml")
13def SwanPadDatabase(
14 protocol="pad_p2_face_f1",
15 selection_style=None,
16 max_number_of_frames=None,
17 step_size=None,
18 annotation_directory=None,
19 annotation_type=None,
20 fixed_positions=None,
21 **kwargs,
22):
23 name = "pad-face-swan-ce83ebd8.tar.gz"
24 dataset_protocols_path = download_file(
25 urls=[f"http://www.idiap.ch/software/bob/data/bob/bob.pad.face/{name}"],
26 destination_filename=name,
27 destination_sub_directory="protocols",
28 checksum="ce83ebd8",
29 )
31 if annotation_directory is None:
32 name = "annotations-swan-mtcnn-9f9e12d8.tar.gz"
33 annotation_directory = download_file(
34 urls=[
35 f"http://www.idiap.ch/software/bob/data/bob/bob.pad.face/{name}"
36 ],
37 destination_filename=name,
38 destination_sub_directory="annotations",
39 checksum="9f9e12d8",
40 )
41 annotation_type = "eyes-center"
43 transformer = VideoPadSample(
44 original_directory=rc.get("bob.db.swan.directory"),
45 annotation_directory=annotation_directory,
46 selection_style=selection_style,
47 max_number_of_frames=max_number_of_frames,
48 step_size=step_size,
49 keep_extension_for_annotation=True,
50 )
52 database = FileListPadDatabase(
53 name="swan",
54 dataset_protocols_path=dataset_protocols_path,
55 protocol=protocol,
56 transformer=transformer,
57 **kwargs,
58 )
59 database.annotation_type = annotation_type
60 database.fixed_positions = fixed_positions
61 return database