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

14 statements  

« prev     ^ index     » next       coverage.py v7.6.0, created at 2024-07-18 22:01 +0200

1#!/usr/bin/env python 

2# vim: set fileencoding=utf-8 : 

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

4 

5""" 

6 AR Face 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 ARFaceDatabase(CSVDatabase): 

21 """ 

22 This package contains the access API and descriptions for the AR face database. 

23 It only contains the Bob_ accessor methods to use the DB directly from python, with our certified protocols. 

24 The actual raw data for the database should be downloaded from the original URL (though we were not able to contact the corresponding Professor). 

25 

26 Our version of the AR face database contains 3312 images from 136 persons, 76 men and 60 women. 

27 We split the database into several protocols that we have designed ourselves. 

28 The identities are split up into three groups: 

29 

30 * the 'world' group for training your algorithm 

31 * the 'dev' group to optimize your algorithm parameters on 

32 * the 'eval' group that should only be used to report results 

33 

34 Additionally, there are different protocols: 

35 

36 * ``'expression'``: only the probe files with different facial expressions are selected 

37 * ``'illumination'``: only the probe files with different illuminations are selected 

38 * ``'occlusion'``: only the probe files with normal illumination and different accessories (scarf, sunglasses) are selected 

39 * ``'occlusion_and_illumination'``: only the probe files with strong illumination and different accessories (scarf, sunglasses) are selected 

40 * ``'all'``: all files are used as probe 

41 

42 In any case, the images with neutral facial expression, neutral illumination and without accessories are used for enrollment. 

43 

44 

45 .. warning:: 

46 

47 To use this dataset protocol, you need to have the original files of the Mobio dataset. 

48 Once you have it downloaded, please run the following command to set the path for Bob 

49 

50 .. code-block:: sh 

51 

52 bob config set bob.bio.face.arface.directory [ARFACE DATA PATH] 

53 

54 

55 .. code-block:: latex 

56 

57 @article{martinez1998ar, 

58 title={The AR Face Database: CVC Technical Report, 24}, 

59 author={Martinez, Aleix and Benavente, Robert}, 

60 year={1998} 

61 } 

62 

63 

64 """ 

65 

66 name = "arface" 

67 category = "face" 

68 dataset_protocols_name = "arface.tar.gz" 

69 dataset_protocols_urls = [ 

70 "https://www.idiap.ch/software/bob/databases/latest/face/arface-7078bd96.tar.gz", 

71 "http://www.idiap.ch/software/bob/databases/latest/face/arface-7078bd96.tar.gz", 

72 ] 

73 dataset_protocols_hash = "7078bd96" 

74 

75 def __init__( 

76 self, protocol, annotation_type="eyes-center", fixed_positions=None 

77 ): 

78 super().__init__( 

79 name=self.name, 

80 protocol=protocol, 

81 transformer=make_pipeline( 

82 FileSampleLoader( 

83 data_loader=bob.io.base.load, 

84 dataset_original_directory=rc.get( 

85 "bob.bio.face.arface.directory", "" 

86 ), 

87 extension=rc.get("bob.bio.face.arface.extension", ".ppm"), 

88 ), 

89 EyesAnnotations(), 

90 ), 

91 annotation_type=annotation_type, 

92 fixed_positions=fixed_positions, 

93 )