Python API¶
-
class
bob.db.celeba.
Annotation
(file_id, labels)[source]¶ Annotations of the CelebA database consists of the locations of the two eyes, the nose tip and the mouth corners. There is exactly one annotation for each
File
, which after creation of the database can be obtained usingself.file
.Note
The eye and mouth locations given in the original annotation file are in observer perspective (i.e., the right eye is to the right of the left eye). To be consistent with other databases of Bob, here we change them to be in subject perspective (i.e., the right eye is to the left of the left eye). Also, as usual for Bob, coordinates are specified in
(y,x)
order, opposite to how they are written in the list file.
-
class
bob.db.celeba.
Attributes
(file_id, attributes)[source]¶ Attributes of the CelebA database consist of a list of binary labels for the face, such as
Smiling
,Wavy_Hair
,Young
orPointy_Nose
. Each attribute is binary, i.e., it either exists (+1
) or it does not exist (-1
). There is exactly one set of attributes for eachFile
, which after creation of the database can be obtained usingself.file
.-
attribute_indices
= {'Sideburns': 30, 'Black_Hair': 8, 'Wavy_Hair': 33, 'Young': 39, 'Heavy_Makeup': 18, 'Blond_Hair': 9, 'Attractive': 2, '5_o_Clock_Shadow': 0, 'Wearing_Necktie': 38, 'Blurry': 10, 'Double_Chin': 14, 'Brown_Hair': 11, 'Mouth_Slightly_Open': 21, 'Goatee': 16, 'Bald': 4, 'Pointy_Nose': 27, 'Gray_Hair': 17, 'Pale_Skin': 26, 'Arched_Eyebrows': 1, 'Wearing_Hat': 35, 'Receding_Hairline': 28, 'Straight_Hair': 32, 'Big_Nose': 7, 'Rosy_Cheeks': 29, 'Oval_Face': 25, 'Bangs': 5, 'Male': 20, 'Mustache': 22, 'High_Cheekbones': 19, 'No_Beard': 24, 'Eyeglasses': 15, 'Bags_Under_Eyes': 3, 'Wearing_Necklace': 37, 'Wearing_Lipstick': 36, 'Big_Lips': 6, 'Narrow_Eyes': 23, 'Chubby': 13, 'Smiling': 31, 'Bushy_Eyebrows': 12, 'Wearing_Earrings': 34}¶
-
attribute_names
= ('5_o_Clock_Shadow', 'Arched_Eyebrows', 'Attractive', 'Bags_Under_Eyes', 'Bald', 'Bangs', 'Big_Lips', 'Big_Nose', 'Black_Hair', 'Blond_Hair', 'Blurry', 'Brown_Hair', 'Bushy_Eyebrows', 'Chubby', 'Double_Chin', 'Eyeglasses', 'Goatee', 'Gray_Hair', 'Heavy_Makeup', 'High_Cheekbones', 'Male', 'Mouth_Slightly_Open', 'Mustache', 'Narrow_Eyes', 'No_Beard', 'Oval_Face', 'Pale_Skin', 'Pointy_Nose', 'Receding_Hairline', 'Rosy_Cheeks', 'Sideburns', 'Smiling', 'Straight_Hair', 'Wavy_Hair', 'Wearing_Earrings', 'Wearing_Hat', 'Wearing_Lipstick', 'Wearing_Necklace', 'Wearing_Necktie', 'Young')¶
-
-
class
bob.db.celeba.
Database
(original_directory=None, original_extension='.jpg')[source]¶ Wrapper class for the MNIST database of handwritten digits (http://yann.lecun.com/exdb/mnist/).
Creates the database
-
annotations
(self, file) → annotations[source]¶ Returns the annotations for the given file.
Note
The annotations are returned in the default way comparable with other bob databases, i.e., in (y,x) order. Please also note that the name of the annotations have been changed to be in subject perspective (e.g., the x-coordinate of the left eye is larger than the x coordintae of the right eye), while the original database contains eye locations in observer perspective.
Parameters:
file
:File
- The file object to get the annotations for.
Returns:
annotations
: {}- The dictionary of annotations, which include the coordinated for ‘reye’, ‘leye’, ‘nose’, ‘rmouth’, ‘lmouth’.
-
attributes
(self, file, attribute_names=None) → attributes[source]¶ Returns the list of attributes for the given file. If
attribute_names
are specified, only the attributes for the givenattribute_names
are returned – in exactly the same order.Parameters:
file
:File
- The file object to get the attributes for.
attribute_names
: str or [str] orNone
- The list of attribute names (see
Attribute.attribute_names
for a list of valid names) which should be retrieved. IfNone
, all attributes are returned.
Returns:
attributes
: [int]- The list of attributes, which are either +1 (in case the attribute is present) or -1 (in case the attribute is absent).
-
objects
(self, purposes=None, with_attributes=None, without_attributes=None) → files[source]¶ Returns a list of
File
objects for the given purposes.Parameters:
purposes
: str or [str] orNone
A purpose or a list of purposes, which might be("training", "validation", "test")
, or("world", "dev", "eval")
. IfNone
, the full list of purposes will be used.with_attributes
: str or [str] orNone
- If given, the resulting list is filtered to contain only objects with the given list of attributes.
If several attributes are specified, the are combined with a logical
and
. without_attributes
: str or [str] orNone
- If given, the resulting list is filtered to contain only objects that do not possess the given list of attributes.
If several attributes are specified, the are combined with a logical
and
.
Returns:
files
: [File
]- A list of files for the given purpose(s), where the given attributes are filtered.
-
original_file_name
(self, file) → image_name[source]¶ Returns the full path of the original image name. This function requires that the
original_directory
was specified in the constructor of this class.Parameters:
file
: :File
- The file object to get the original file name for.
Returns:
- image_name : str
- The full path to the image belonging to the given
File
object.
-
test_set
(self) → files[source]¶ Returns a list of
File
objects that can be used for testingReturns:
files
: [File
]- A list of test files.
-
-
class
bob.db.celeba.
File
(file_id, purpose)[source]¶ Information about the files of the CelebA database.
Each file includes only a numerical ID (which is identical to the file path).
Additionally, some fields will be available, once the database is created:
annotation
: theAnnotation
, which belongs to this fileattributes
: theAttributes
, which belongs to this filepurpose
: thePurpose
, for which this file is used
-
make_path
(directory=None, extension=None)[source]¶ Wraps the current path so that a complete path is formed. To get the original file name, please use the
Database.original_file_name()
function instead, or set theadd_sighting_id
flag toFalse
.Keyword parameters:
directory
: str orNone
- An optional directory name that will be prefixed to the returned result.
extension
: str orNone
- An optional extension that will be suffixed to the returned filename.
The extension normally includes the leading
.
character as in.jpg
or.hdf5
.
Returns a string containing the newly generated file path, which by default is unique.