Coverage for src/bob/bio/face/database/morph.py: 100%

14 statements  

« prev     ^ index     » next       coverage.py v7.6.0, created at 2024-07-13 00:04 +0200

1#!/usr/bin/env python 

2# vim: set fileencoding=utf-8 : 

3# Tiago de Freitas Pereira <tiago.pereira@idiap.ch> 

4 

5""" 

6 MORPH database implementation 

7""" 

8 

9from clapper.rc import UserDefaults 

10from sklearn.pipeline import make_pipeline 

11 

12import bob.io.base 

13 

14from bob.bio.base.database import CSVDatabase, FileSampleLoader 

15from bob.bio.face.database.sample_loaders import EyesAnnotations 

16 

17rc = UserDefaults("bobrc.toml") 

18 

19 

20class MorphDatabase(CSVDatabase): 

21 """ 

22 The MORPH dataset is relatively old, but is getting some traction recently mostly because its richness 

23 with respect to sensitive attributes. 

24 It is composed by 55,000 samples from 13,000 subjects from men and women and five 

25 race clusters (called ancestry) and they are the following: African, European, Asian, Hispanic and Others. Figure 8 

26 present some samples from this database. 

27 

28 This dataset contains faces from five ethnicities (African, European, Asian, Hispanic, "Other") 

29 and two genders (Male and Female). 

30 Furthermore, this interface contains three verification protocols and they are: 

31 `verification_fold1`, `verification_fold2` and `verification_fold1`. 

32 Follow below the identities distribution in each set for the for each protocol: 

33 

34 +--------------------+---------------+-----------+-----------+-----------+ 

35 | | Training set | Dev. Set | Eval. Set | 

36 +--------------------+---------------+-----------+ + + 

37 | | T-References | Z-Probes | | | 

38 +====================+===============+===========+===========+===========+ 

39 | verification_fold1 | 69 | 66 | 6738 | 6742 | 

40 +--------------------+---------------+-----------+-----------+-----------+ 

41 | verification_fold2 | 69 | 67 | 6734 | 6737 | 

42 +--------------------+---------------+-----------+-----------+-----------+ 

43 | verification_fold3 | 70 | 66 | 6736 | 6740 | 

44 +--------------------+---------------+-----------+-----------+-----------+ 

45 

46 .. warning:: 

47 Use the command below to set the path of the real data:: 

48 

49 $ bob config set bob.db.morph.directory [PATH-TO-MORPH-DATA] 

50 

51 Parameters 

52 ---------- 

53 

54 protocol: str 

55 One of the database protocols. Options are `verification_fold1`, `verification_fold2` and `verification_fold3` 

56 

57 """ 

58 

59 name = "morph" 

60 category = "face" 

61 dataset_protocols_name = "morph.tar.gz" 

62 dataset_protocols_urls = [ 

63 "https://www.idiap.ch/software/bob/databases/latest/face/morph-1200b906.tar.gz", 

64 "http://www.idiap.ch/software/bob/databases/latest/face/morph-1200b906.tar.gz", 

65 ] 

66 dataset_protocols_hash = "1200b906" 

67 

68 def __init__( 

69 self, 

70 protocol, 

71 annotation_type="eyes-center", 

72 fixed_positions=None, 

73 dataset_original_directory=rc.get("bob.db.morph.directory", ""), 

74 dataset_original_extension=rc.get("bob.db.morph.extension", ".JPG"), 

75 ): 

76 super().__init__( 

77 name=self.name, 

78 protocol=protocol, 

79 transformer=make_pipeline( 

80 FileSampleLoader( 

81 data_loader=bob.io.base.load, 

82 dataset_original_directory=dataset_original_directory 

83 if dataset_original_directory 

84 else "", 

85 extension=dataset_original_extension, 

86 ), 

87 EyesAnnotations(), 

88 ), 

89 templates_metadata=["date_of_birth", "sex", "rac"], 

90 annotation_type=annotation_type, 

91 fixed_positions=fixed_positions, 

92 )