Commit 18e00bbf authored by Olegs NIKISINS's avatar Olegs NIKISINS
Browse files

Updated the doc in data_folder to match the numpy format

parent 2da69255
Pipeline #26274 failed with stage
in 7 minutes and 5 seconds
......@@ -31,25 +31,27 @@ def get_file_names_and_labels(files, data_folder, extension = ".hdf5", hldi_type
Get absolute names of the corresponding file objects and their class labels,
as well as keys defining name of the frame to load the data from.
**Parameters:**
Attributes
----------
``files`` : [File]
files : [File]
A list of files objects defined in the High Level Database Interface
of the particular datbase.
``data_folder`` : str
data_folder : str
A directory containing the training data.
``extension`` : str
extension : str
Extension of the data files. Default: ".hdf5" .
``hldi_type`` : str
hldi_type : str
Type of the high level database interface. Default: "pad".
Note: this is the only type supported at the moment.
**Returns:**
Returns
-------
``file_names_labels_keys`` : [(str, int, str)]
file_names_labels_keys : [(str, int, str)]
A list of tuples, where each tuple contain an absolute filename,
a corresponding label of the class, and a key defining the name of the
frame to extract the data from.
......@@ -92,6 +94,47 @@ class DataFolder(data.Dataset):
"""
A generic data loader compatible with Bob High Level Database Interfaces
(HLDI). Only HLDI's of bob.pad.face are currently supported.
Attributes
----------
data_folder : str
A directory containing the training data.
transform : callable
A function/transform that takes in a PIL image, and returns a
transformed version. E.g, ``transforms.RandomCrop``. Default: None.
extension : str
Extension of the data files. Default: ".hdf5".
Note: this is the only extension supported at the moment.
bob_hldi_instance : object
An instance of the HLDI interface. Only HLDI's of bob.pad.face
are currently supported.
hldi_type : str
String defining the type of the HLDI. Default: "pad".
Note: this is the only option currently supported.
groups : str or [str]
The groups for which the clients should be returned.
Usually, groups are one or more elements of ['train', 'dev', 'eval'].
Default: ['train', 'dev', 'eval'].
protocol : str
The protocol for which the clients should be retrieved.
Default: 'grandtest'.
purposes : str or [str]
The purposes for which File objects should be retrieved.
Usually it is either 'real' or 'attack'.
Default: ['real', 'attack'].
allow_missing_files : bool
The missing files in the ``data_folder`` will not break the
execution if set to True.
Default: True.
"""
def __init__(self, data_folder,
......@@ -104,47 +147,6 @@ class DataFolder(data.Dataset):
purposes=['real', 'attack'],
allow_missing_files = True,
**kwargs):
"""
**Parameters:**
``data_folder`` : str
A directory containing the training data.
``transform`` : callable
A function/transform that takes in a PIL image, and returns a
transformed version. E.g, ``transforms.RandomCrop``. Default: None.
``extension`` : str
Extension of the data files. Default: ".hdf5".
Note: this is the only extension supported at the moment.
``bob_hldi_instance`` : object
An instance of the HLDI interface. Only HLDI's of bob.pad.face
are currently supported.
``hldi_type`` : str
String defining the type of the HLDI. Default: "pad".
Note: this is the only option currently supported.
``groups`` : str or [str]
The groups for which the clients should be returned.
Usually, groups are one or more elements of ['train', 'dev', 'eval'].
Default: ['train', 'dev', 'eval'].
``protocol`` : str
The protocol for which the clients should be retrieved.
Default: 'grandtest'.
``purposes`` : str or [str]
The purposes for which File objects should be retrieved.
Usually it is either 'real' or 'attack'.
Default: ['real', 'attack'].
``allow_missing_files`` : str or [str]
The missing files in the ``data_folder`` will not break the
execution if set to True.
Default: True.
"""
self.data_folder = data_folder
self.transform = transform
......@@ -185,18 +187,20 @@ class DataFolder(data.Dataset):
"""
Returns an image, possibly transformed, and a target class given index.
**Parameters:**
Attributes
----------
``index`` : int.
index : int.
An index of the sample to return.
**Returns:**
Returns
-------
``pil_img`` : Tensor or PIL Image
pil_img : Tensor or PIL Image
If ``self.transform`` is defined the output is the torch.Tensor,
otherwise the output is an instance of the PIL.Image.Image class.
``target`` : int
target : int
Index of the class.
"""
......@@ -235,9 +239,10 @@ class DataFolder(data.Dataset):
#==========================================================================
def __len__(self):
"""
**Returns:**
Attributes
----------
``len`` : int
len : int
The length of the file list.
"""
return len(self.file_names_labels_keys)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment