| 1 |  |  | from fuel.datasets import H5PYDataset | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  | from fuel.transformers.defaults import uint8_pixels_to_floatX | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | from fuel.utils import find_in_data_path | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  | class CelebA(H5PYDataset): | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |     """The CelebFaces Attributes Dataset (CelebA) dataset. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |     CelebA is a large-scale face | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |     attributes dataset with more than 200K celebrity images, each | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |     with 40 attribute annotations. The images in this dataset cover | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |     large pose variations and background clutter. CelebA has large | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |     diversities, large quantities, and rich annotations, including: | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |     * 10,177 number of identities | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |     * 202,599 number of face images | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |     * 5 landmark locations per image | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |     * 40 binary attributes annotations per image. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |     The dataset can be employed as the training and test sets for | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |     the following computer vision tasks: | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |     * face attribute recognition | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |     * face detection | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |     * landmark (or facial part) localization | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |     Parameters | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |     ---------- | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |     which_format : {'aligned_cropped, '64'} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |         Either the aligned and cropped version of CelebA, or | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |         a 64x64 version of it. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |     which_sets : tuple of str | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |         Which split to load. Valid values are 'train', 'valid' and | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |         'test' corresponding to the training set (162,770 examples), the | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |         validation set (19,867 examples) and the test set (19,962 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |         examples). | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |     """ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |     _filename = 'celeba_{}.hdf5' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |     default_transformers = uint8_pixels_to_floatX(('features',)) | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 41 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 42 |  |  |     def __init__(self, which_format, which_sets, **kwargs): | 
            
                                                                        
                            
            
                                    
            
            
                | 43 |  |  |         self.which_format = which_format | 
            
                                                                        
                            
            
                                    
            
            
                | 44 |  |  |         super(CelebA, self).__init__( | 
            
                                                                        
                            
            
                                    
            
            
                | 45 |  |  |             file_or_path=find_in_data_path(self.filename), | 
            
                                                                        
                            
            
                                    
            
            
                | 46 |  |  |             which_sets=which_sets, **kwargs) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |     @property | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |     def filename(self): | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 50 |  |  |         return self._filename.format(self.which_format) | 
            
                                                        
            
                                    
            
            
                | 51 |  |  |  |